From 3f2b73105c5e09e17744ec249eed93c60124bd2d Mon Sep 17 00:00:00 2001 From: Goldwyn Rodrigues Date: Mon, 19 Aug 2013 18:05:04 -0500 Subject: [PATCH 3/7] Get cluster name from corosync cmap --- libo2cb/o2cb_abi.c | 20 ++++++++++++++++++++ o2cb.pc.in | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/libo2cb/o2cb_abi.c b/libo2cb/o2cb_abi.c index 8e5d6ce..d00dd46 100644 --- a/libo2cb/o2cb_abi.c +++ b/libo2cb/o2cb_abi.c @@ -37,6 +37,7 @@ #include #include +#include #include "o2cb/o2cb.h" #include "o2cb/o2cb_client_proto.h" @@ -1711,6 +1712,25 @@ static errcode_t classic_list_clusters(char ***clusters) static errcode_t user_list_clusters(char ***clusters) { + cmap_handle_t handle; + char **list; + int rv; + + rv = cmap_initialize(&handle); + if (rv != CS_OK) + return O2CB_ET_SERVICE_UNAVAILABLE; + + /* We supply only one cluster_name */ + list = (char **)malloc(sizeof(char *) * 2); + rv = cmap_get_string(handle, "totem.cluster_name", &list[0]); + if (rv != CS_OK) { + free(list); + return O2CB_ET_INTERNAL_FAILURE; + } + + list[1] = NULL; + *clusters = list; + return 0; } diff --git a/o2cb.pc.in b/o2cb.pc.in index be94b8a..3a47c36 100644 --- a/o2cb.pc.in +++ b/o2cb.pc.in @@ -7,5 +7,5 @@ Name: o2cb Description: Library for accessing the ocfs2 cluster base (o2cb) Version: @VERSION@ Requires: com_err -Libs: -L${libdir} -lo2cb +Libs: -L${libdir} -lo2cb -lcmap Cflags: -I${includedir} -- 1.8.1.4