summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-volgen.c
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-volgen.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c139
1 files changed, 5 insertions, 134 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index 7981e2977e8..7cd95fad5f2 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -18,11 +18,6 @@
#include <dlfcn.h>
#include <utime.h>
-#if (HAVE_LIB_XML)
-#include <libxml/encoding.h>
-#include <libxml/xmlwriter.h>
-#endif
-
#include "xlator.h"
#include "glusterd.h"
#include "defaults.h"
@@ -1939,7 +1934,7 @@ nfsperfxl_option_handler (volgen_graph_t *graph, struct volopt_map_entry *vme,
}
#if (HAVE_LIB_XML)
-static int
+int
end_sethelp_xml_doc (xmlTextWriterPtr writer)
{
int ret = -1;
@@ -1965,7 +1960,7 @@ end_sethelp_xml_doc (xmlTextWriterPtr writer)
}
-static int
+int
init_sethelp_xml_doc (xmlTextWriterPtr *writer, xmlBufferPtr *buf)
{
int ret;
@@ -2012,7 +2007,7 @@ init_sethelp_xml_doc (xmlTextWriterPtr *writer, xmlBufferPtr *buf)
}
-static int
+int
xml_add_volset_element (xmlTextWriterPtr writer, const char *name,
const char *def_val, const char *dscrpt)
{
@@ -2073,7 +2068,7 @@ xml_add_volset_element (xmlTextWriterPtr writer, const char *name,
#endif
-static int
+int
_get_xlator_opt_key_from_vme ( struct volopt_map_entry *vme, char **key)
{
int ret = 0;
@@ -2117,7 +2112,7 @@ _get_xlator_opt_key_from_vme ( struct volopt_map_entry *vme, char **key)
return ret;
}
-static void
+void
_free_xlator_opt_key (char *key)
{
GF_ASSERT (key);
@@ -2130,130 +2125,6 @@ _free_xlator_opt_key (char *key)
return;
}
-int
-glusterd_get_volopt_content (dict_t * ctx, gf_boolean_t xml_out)
-{
- void *dl_handle = NULL;
- volume_opt_list_t vol_opt_handle = {{0},};
- char *key = NULL;
- struct volopt_map_entry *vme = NULL;
- int ret = -1;
- char *def_val = NULL;
- char *descr = NULL;
- char output_string[51200] = {0, };
- char *output = NULL;
- char tmp_str[2048] = {0, };
-#if (HAVE_LIB_XML)
- xmlTextWriterPtr writer = NULL;
- xmlBufferPtr buf = NULL;
-
- if (xml_out) {
- ret = init_sethelp_xml_doc (&writer, &buf);
- if (ret) /*logging done in init_xml_lib*/
- goto out;
- }
-#endif
-
- INIT_LIST_HEAD (&vol_opt_handle.list);
-
- for (vme = &glusterd_volopt_map[0]; vme->key; vme++) {
-
- if ((vme->type == NO_DOC) || (vme->type == GLOBAL_NO_DOC))
- continue;
-
- if (vme->description) {
- descr = vme->description;
- def_val = vme->value;
- } else {
- if (_get_xlator_opt_key_from_vme (vme, &key)) {
- gf_log ("glusterd", GF_LOG_DEBUG, "Failed to "
- "get %s key from volume option entry",
- vme->key);
- goto out; /*Some error while geting key*/
- }
-
- ret = xlator_volopt_dynload (vme->voltype,
- &dl_handle,
- &vol_opt_handle);
-
- if (ret) {
- gf_log ("glusterd", GF_LOG_DEBUG,
- "xlator_volopt_dynload error(%d)", ret);
- ret = 0;
- goto cont;
- }
-
- ret = xlator_option_info_list (&vol_opt_handle, key,
- &def_val, &descr);
- if (ret) { /*Swallow Error i.e if option not found*/
- gf_log ("glusterd", GF_LOG_DEBUG,
- "Failed to get option for %s key", key);
- ret = 0;
- goto cont;
- }
- }
-
- if (xml_out) {
-#if (HAVE_LIB_XML)
- if (xml_add_volset_element (writer,vme->key,
- def_val, descr)) {
- ret = -1;
- goto cont;
- }
-#else
- gf_log ("glusterd", GF_LOG_ERROR, "Libxml not present");
-#endif
- } else {
- snprintf (tmp_str, sizeof (tmp_str), "Option: %s\nDefault "
- "Value: %s\nDescription: %s\n\n",
- vme->key, def_val, descr);
- strcat (output_string, tmp_str);
- }
-cont:
- if (dl_handle) {
- dlclose (dl_handle);
- dl_handle = NULL;
- vol_opt_handle.given_opt = NULL;
- }
- if (key) {
- _free_xlator_opt_key (key);
- key = NULL;
- }
- if (ret)
- goto out;
- }
-
-#if (HAVE_LIB_XML)
- if ((xml_out) &&
- (ret = end_sethelp_xml_doc (writer)))
- goto out;
-#else
- if (xml_out)
- gf_log ("glusterd", GF_LOG_ERROR, "Libxml not present");
-#endif
-
- if (!xml_out)
- output = gf_strdup (output_string);
- else
-#if (HAVE_LIB_XML)
- output = gf_strdup ((char *)buf->content);
-#else
- gf_log ("glusterd", GF_LOG_ERROR, "Libxml not present");
-#endif
-
- if (NULL == output) {
- ret = -1;
- goto out;
- }
-
- ret = dict_set_dynstr (ctx, "help-str", output);
-out:
- gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret);
- return ret;
-
-}
-
-
static xlator_t *
volgen_graph_build_client (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
char *hostname, char *subvol, char *xl_id,