diff options
author | Kaushik BV <kaushikbv@gluster.com> | 2011-04-13 01:46:09 +0000 |
---|---|---|
committer | Anand Avati <avati@gluster.com> | 2011-04-13 04:43:22 -0700 |
commit | ebd99e25bf811ab14540f74dd50b445c217e7ee0 (patch) | |
tree | 0a48a8db6d30390b0fb959163a644d48966a0b7b /cli/src | |
parent | 72f88e50dbf1f492db7bcc70b074bc64e6b994cb (diff) |
cli: join value arguments of "gsync config-set" with spaces
When a given gsync tunable is supposed to hold a command (which
can take options), it's quite possible that it spaces in its value.
Try to approximate this situation by joining the leftover arguments.
Signed-off-by: Kaushik BV <kaushikbv@gluster.com>
Signed-off-by: Csaba Henk <csaba@gluster.com>
Signed-off-by: Anand Avati <avati@gluster.com>
BUG: 2713 ([glusterfs-3.2.0qa10]: config-set works only for one value)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2713
Diffstat (limited to 'cli/src')
-rw-r--r-- | cli/src/cli-cmd-parser.c | 37 | ||||
-rw-r--r-- | cli/src/cli-mem-types.h | 1 |
2 files changed, 34 insertions, 4 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index a0219a04ad7..ca4c8d315ce 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -1122,8 +1122,11 @@ cli_cmd_gsync_set_parse (const char **words, int wordcount, dict_t **options) { int32_t ret = 0; int32_t config_type = 0; - dict_t *dict = NULL; - gf1_cli_gsync_set type = GF_GSYNC_OPTION_TYPE_NONE; + dict_t *dict = NULL; + gf1_cli_gsync_set type = GF_GSYNC_OPTION_TYPE_NONE; + char *append_str = NULL; + size_t append_len = 0; + int i = 0; GF_ASSERT (words); GF_ASSERT (options); @@ -1164,11 +1167,34 @@ cli_cmd_gsync_set_parse (const char **words, int wordcount, dict_t **options) if (strcmp (words [5], "config-set") == 0) { config_type = GF_GSYNC_OPTION_TYPE_CONFIG_SET; + if (wordcount < 8) { + ret = -1; + + goto out; + } + ret = dict_set_str (dict, "op_name", (char *)words[6]); if (ret < 0) goto out; + /*XXX hack to get around the fact, where parsing of + * args is done based on spaces */ + for (i = 7; i < wordcount; i++) + append_len += (strlen (words[i]) + 1); + append_len++; /* trailing strcat will add two bytes, make space for that */ + + append_str = GF_CALLOC (1, append_len, cli_mt_append_str); + if (!append_str) { + ret = -1; + goto out; + } + + for (i = 7; i< wordcount; i++) { + strcat (append_str, words[i]); + strcat (append_str, " "); + } + append_str[append_len - 2] = '\0'; - ret = dict_set_str (dict, "op_value", (char *)words[7]); + ret = dict_set_dynstr (dict, "op_value", append_str); if (ret < 0) goto out; } @@ -1205,9 +1231,12 @@ set_type: *options = dict; out: - if (ret) + if (ret) { if (dict) dict_destroy (dict); + if (append_str) + GF_FREE (append_str); + } return ret; } diff --git a/cli/src/cli-mem-types.h b/cli/src/cli-mem-types.h index 86e346641ff..a3d74d31ad8 100644 --- a/cli/src/cli-mem-types.h +++ b/cli/src/cli-mem-types.h @@ -32,6 +32,7 @@ enum cli_mem_types_ { cli_mt_call_pool_t, cli_mt_cli_local_t, cli_mt_cli_get_vol_ctx_t, + cli_mt_append_str, cli_mt_end }; |