[Ocfs2-tools-devel] [PATCH 3/6] o2cb_config: Add o2cb_cluster_delete_node()
Sunil Mushran
sunil.mushran at oracle.com
Wed Dec 15 18:41:06 PST 2010
o2cb_cluster_delete_node() added to allow removal of a node from the config.
Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com>
---
o2cb_ctl/o2cb_config.c | 18 +++++++++++++++++-
o2cb_ctl/o2cb_config.h | 2 +-
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/o2cb_ctl/o2cb_config.c b/o2cb_ctl/o2cb_config.c
index 4a115f1..85c5957 100644
--- a/o2cb_ctl/o2cb_config.c
+++ b/o2cb_ctl/o2cb_config.c
@@ -658,8 +658,24 @@ O2CBNode *o2cb_cluster_add_node(O2CBCluster *cluster,
return node;
} /* o2cb_cluster_add_node() */
-void o2cb_cluster_delete_node(O2CBCluster *cluster, O2CBNode *node)
+gint o2cb_cluster_delete_node(O2CBCluster *cluster, const gchar *name)
{
+ O2CBNode *node;
+ g_return_val_if_fail(cluster != NULL, -1);
+ g_return_val_if_fail(name != NULL, -1);
+
+ node = o2cb_cluster_get_node_by_name(cluster, name);
+ if (!node)
+ return -ENOENT;
+
+ cluster->c_nodes = g_list_remove(cluster->c_nodes, node);
+ cluster->c_num_nodes--;
+ g_free(node->n_name);
+ g_free(node->n_addr);
+ g_free(node);
+
+ return 0;
+
} /* o2cb_cluster_delete_node() */
gint o2cb_node_get_number(O2CBNode *node)
diff --git a/o2cb_ctl/o2cb_config.h b/o2cb_ctl/o2cb_config.h
index 32bf07b..f7e40a0 100644
--- a/o2cb_ctl/o2cb_config.h
+++ b/o2cb_ctl/o2cb_config.h
@@ -50,7 +50,7 @@ O2CBNode *o2cb_cluster_get_node_by_name(O2CBCluster *cluster,
const gchar *name);
O2CBNode *o2cb_cluster_add_node(O2CBCluster *cluster,
const gchar *name);
-void o2cb_cluster_delete_node(O2CBCluster *cluster, O2CBNode *node);
+gint o2cb_cluster_delete_node(O2CBCluster *cluster, const gchar *name);
gint o2cb_node_get_number(O2CBNode *node);
gchar *o2cb_node_get_name(O2CBNode *node);
--
1.7.1
More information about the Ocfs2-tools-devel
mailing list