summaryrefslogtreecommitdiffstats
path: root/cli/src/cli-cmd-parser.c
diff options
context:
space:
mode:
authorJunaid <junaid@gluster.com>2011-04-11 01:15:53 +0000
committerAnand Avati <avati@gluster.com>2011-04-11 05:43:57 -0700
commitf5625e628f1959331eed85082cb6bfdc324db3c2 (patch)
tree3c94c87ac97358e571c2e785b5af2dbb301e5f4f /cli/src/cli-cmd-parser.c
parent974be663a9113d4aed684dce00f5288669d511e8 (diff)
cli: Validating the cli quota options.
Signed-off-by: Junaid <junaid@gluster.com> Signed-off-by: Anand Avati <avati@gluster.com> BUG: 2612 (quota limit-set not in line with help) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2612
Diffstat (limited to 'cli/src/cli-cmd-parser.c')
-rw-r--r--cli/src/cli-cmd-parser.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index 300091d978b..c476638ba77 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;