From f5625e628f1959331eed85082cb6bfdc324db3c2 Mon Sep 17 00:00:00 2001 From: Junaid Date: Mon, 11 Apr 2011 01:15:53 +0000 Subject: cli: Validating the cli quota options. Signed-off-by: Junaid Signed-off-by: Anand Avati BUG: 2612 (quota limit-set not in line with help) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2612 --- cli/src/cli-cmd-parser.c | 16 ++++++++++------ cli/src/cli-cmd-volume.c | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'cli') diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index 300091d97..c476638ba 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -373,6 +373,7 @@ cli_cmd_quota_parse (const char **words, int wordcount, dict_t **options) int ret = -1; int i = 0; char key[20] = {0, }; + uint64_t value = 0; gf_quota_type type = GF_QUOTA_OPTION_TYPE_NONE; GF_ASSERT (words); @@ -418,17 +419,16 @@ cli_cmd_quota_parse (const char **words, int wordcount, dict_t **options) } ret = dict_set_str (dict, "volname", volname); - if (ret) goto out; - if ((strcasecmp (words[3], "enable")) == 0) { + if ((strcasecmp (words[3], "enable")) == 0 && wordcount == 4) { type = GF_QUOTA_OPTION_TYPE_ENABLE; goto set_type; } - if (strcasecmp (words[3], "disable") == 0) { + if (strcasecmp (words[3], "disable") == 0 && wordcount == 4) { type = GF_QUOTA_OPTION_TYPE_DISABLE; goto set_type; } @@ -447,17 +447,21 @@ cli_cmd_quota_parse (const char **words, int wordcount, dict_t **options) return -2; } ret = dict_set_str (dict, "path", (char *) words[4]); - if (ret) goto out; if (!words[5]) { - gf_log ("cli", GF_LOG_ERROR, "Please enter the limit value " - "to be set"); + cli_out ("Please enter the limit value to be set"); return -2; } + ret = gf_string2bytesize (words[5], &value); + if (ret != 0) { + cli_out ("Please enter a correct value"); + return -1; + } + ret = dict_set_str (dict, "limit", (char *) words[5]); if (ret) goto out; diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index f008384ae..3f639300f 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -1171,7 +1171,7 @@ struct cli_cmd volume_cmds[] = { cli_cmd_volume_profile_cbk, "volume profile operations"}, - { "volume quota [args] [path]", + { "volume quota [path] [value]", cli_cmd_quota_cbk, "quota translator specific operations"}, -- cgit