[Ocfs2-tools-devel] [PATCH 2/6] o2cb_config: Add o2cb_config_remove_cluster()

Sunil Mushran sunil.mushran at oracle.com
Wed Dec 15 18:41:05 PST 2010


o2cb_config_remove_cluster() added to allow removal of cluster from the config.

Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com>
---
 o2cb_ctl/o2cb_config.c |   15 +++++++++++++++
 o2cb_ctl/o2cb_config.h |    3 +--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/o2cb_ctl/o2cb_config.c b/o2cb_ctl/o2cb_config.c
index dba6273..4a115f1 100644
--- a/o2cb_ctl/o2cb_config.c
+++ b/o2cb_ctl/o2cb_config.c
@@ -518,6 +518,21 @@ O2CBCluster *o2cb_config_add_cluster(O2CBConfig *config,
     return cluster;
 }  /* o2cb_cluster_add_cluster() */
 
+gint o2cb_config_remove_cluster(O2CBConfig *config, const gchar *name)
+{
+    O2CBCluster *cluster;
+
+    g_return_val_if_fail(config != NULL, -1);
+    cluster = o2cb_config_get_cluster_by_name(config, name);
+    if (!cluster)
+        return -ENOENT;
+
+    config->co_clusters = g_list_remove(config->co_clusters, cluster);
+    o2cb_cluster_free(cluster);
+
+    return 0;
+}
+
 O2CBCluster *o2cb_config_get_cluster_by_name(O2CBConfig *config,
                                              const gchar *name)
 {
diff --git a/o2cb_ctl/o2cb_config.h b/o2cb_ctl/o2cb_config.h
index b6af8d4..32bf07b 100644
--- a/o2cb_ctl/o2cb_config.h
+++ b/o2cb_ctl/o2cb_config.h
@@ -36,8 +36,7 @@ void o2cb_config_free(O2CBConfig *config);
 
 O2CBCluster *o2cb_config_add_cluster(O2CBConfig *config,
                                      const gchar *name);
-void o2cb_config_delete_cluster(O2CBConfig *config,
-                                O2CBCluster *cluster);
+gint o2cb_config_remove_cluster(O2CBConfig *config, const gchar *name);
 JIterator *o2cb_config_get_clusters(O2CBConfig *config);
 O2CBCluster *o2cb_config_get_cluster_by_name(O2CBConfig *config,
                                              const gchar *name);
-- 
1.7.1




More information about the Ocfs2-tools-devel mailing list