summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src
diff options
context:
space:
mode:
authorKaushik BV <kaushikbv@gluster.com>2011-07-15 01:20:08 +0000
committerAnand Avati <avati@gluster.com>2011-07-17 07:46:18 -0700
commit3c6138dbf2ed6ebba6b8108be8f4999ff8226964 (patch)
treeb0d4f0f18b2cee10785cd823fe2b387a0cdb3a4d /libglusterfs/src
parentf1b0e963976208cc93e69fc627a81a6f4ab1640b (diff)
mgmt/Glusterd: Implementation volume set help/help-xml
Signed-off-by: Kaushik BV <kaushikbv@gluster.com> Signed-off-by: Anand Avati <avati@gluster.com> BUG: 2041 (volume set help option) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2041
Diffstat (limited to 'libglusterfs/src')
-rw-r--r--libglusterfs/src/xlator.c107
-rw-r--r--libglusterfs/src/xlator.h6
2 files changed, 113 insertions, 0 deletions
diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c
index d38754ecd..3674bddd9 100644
--- a/libglusterfs/src/xlator.c
+++ b/libglusterfs/src/xlator.c
@@ -569,6 +569,65 @@ xlator_set_type_virtual (xlator_t *xl, const char *type)
return -1;
}
+int32_t
+xlator_volopt_dynload (char *xlator_type, void **dl_handle,
+ volume_opt_list_t *opt_list)
+{
+ int ret = -1;
+ char *name = NULL;
+ void *handle = NULL;
+ volume_opt_list_t *vol_opt = NULL;
+
+ GF_VALIDATE_OR_GOTO ("xlator", xlator_type, out);
+
+ GF_ASSERT (dl_handle);
+
+ if (*dl_handle)
+ if (dlclose (*dl_handle))
+ gf_log ("xlator", GF_LOG_WARNING, "Unable to close "
+ "previously opened handle( may be stale)."
+ "Ignoring the invalid handle");
+
+ ret = gf_asprintf (&name, "%s/%s.so", XLATORDIR, xlator_type);
+ if (-1 == ret) {
+ gf_log ("xlator", GF_LOG_ERROR, "asprintf failed");
+ goto out;
+ }
+
+ ret = -1;
+
+ gf_log ("xlator", GF_LOG_TRACE, "attempt to load file %s", name);
+
+ handle = dlopen (name, RTLD_NOW|RTLD_GLOBAL);
+ if (!handle) {
+ gf_log ("xlator", GF_LOG_WARNING, "%s", dlerror ());
+ goto out;
+ }
+ *dl_handle = handle;
+
+ INIT_LIST_HEAD (&opt_list->list);
+
+ vol_opt = GF_CALLOC (1, sizeof (volume_opt_list_t),
+ gf_common_mt_volume_opt_list_t);
+
+ if (!vol_opt) {
+ goto out;
+ }
+
+ if (!(vol_opt->given_opt = dlsym (handle, "options"))) {
+ dlerror ();
+ gf_log ("xlator", GF_LOG_DEBUG,
+ "Strict option validation not enforced -- neglecting");
+ }
+ list_add_tail (&vol_opt->list, &opt_list->list);
+
+ ret = 0;
+ out:
+ gf_log ("xlator", GF_LOG_DEBUG, "Returning %d", ret);
+ return ret;
+
+}
+
int32_t
xlator_dynload (xlator_t *xl)
@@ -1226,3 +1285,51 @@ glusterd_check_log_level (const char *value)
return log_level;
}
+
+int
+xlator_get_volopt_info (struct list_head *opt_list, char *key, char **def_val,
+ char **descr)
+{
+
+ int index = 0;
+ int ret = -1;
+ volume_opt_list_t *vol_list = NULL;
+ volume_option_t *opt = NULL;
+
+ if (!opt_list || !key || !def_val ) {
+ gf_log ("", GF_LOG_WARNING, " Parameters to the function not "
+ "valid");
+ ret = -1;
+ goto out;
+ }
+
+ if (list_empty (opt_list)) {
+ gf_log ("xlator", GF_LOG_WARNING, "No elements in Volume option"
+ " list");
+ ret = -1;
+ goto out;
+ }
+
+
+ vol_list = list_entry (opt_list->next, volume_opt_list_t, list);
+
+ opt = vol_list->given_opt;
+
+ for (index = 0; opt[index].key && opt[index].key[0] ; index++) {
+ if (strncmp (key, opt[index].key[0], strlen (key)))
+ continue;
+
+ *def_val = opt[index].default_value;
+ if (descr)
+ *descr = opt[index].description;
+ ret = 0;
+ goto out;
+ }
+
+ ret = -1;
+
+out:
+ gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ return ret;
+
+}
diff --git a/libglusterfs/src/xlator.h b/libglusterfs/src/xlator.h
index 0a2dcbafd..2af1012ab 100644
--- a/libglusterfs/src/xlator.h
+++ b/libglusterfs/src/xlator.h
@@ -787,6 +787,7 @@ typedef struct volume_options {
char *value[ZR_OPTION_MAX_ARRAY_SIZE];
/* If specified, will check for one of
the value from this array */
+ char *default_value;
char *description; /* about the key */
} volume_option_t;
@@ -876,6 +877,11 @@ int is_gf_log_command (xlator_t *trans, const char *name, char *value);
int xlator_validate_rec (xlator_t *xlator, char **op_errstr);
int graph_reconf_validateopt (glusterfs_graph_t *graph, char **op_errstr);
int glusterd_check_log_level (const char *value);
+int32_t xlator_volopt_dynload (char *xlator_type, void **dl_handle,
+ volume_opt_list_t *vol_opt_handle);
+int xlator_get_volopt_info (struct list_head *opt_list, char *key,
+ char **def_val, char **descr);
+
#define GF_STAT_PRINT_FMT_STR "%"PRIx64",%"PRIx64",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx64",%"PRIx64",%"PRIx32",%"PRIx64",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32"\n"