summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli-cmd-parser.c15
-rw-r--r--cli/src/cli-cmd-volume.c11
-rw-r--r--cli/src/cli.h3
3 files changed, 21 insertions, 8 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index 7d6fd3c28d0..984ce5bbad0 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -1759,7 +1759,11 @@ parse_bricks:
&brick_count);
if (ret)
goto out;
-
+ if (!brick_count) {
+ cli_err ("No bricks specified");
+ ret = -1;
+ goto out;
+ }
ret = dict_set_dynstr (dict, "bricks", bricks);
if (ret)
goto out;
@@ -1932,14 +1936,15 @@ out:
int32_t
cli_cmd_volume_remove_brick_parse (const char **words, int wordcount,
- dict_t **options, int *question)
+ dict_t **options, int *question,
+ int *brick_count)
{
dict_t *dict = NULL;
char *volname = NULL;
char *delimiter = NULL;
int ret = -1;
char key[50];
- int brick_count = 0, brick_index = 0;
+ int brick_index = 0;
int32_t tmp_index = 0;
int32_t j = 0;
char *tmp_brick = NULL;
@@ -2072,7 +2077,7 @@ cli_cmd_volume_remove_brick_parse (const char **words, int wordcount,
}
j++;
}
- snprintf (key, 50, "brick%d", ++brick_count);
+ snprintf (key, 50, "brick%d", ++(*brick_count));
ret = dict_set_str (dict, key, (char *)words[brick_index++]);
if (ret)
@@ -2080,7 +2085,7 @@ cli_cmd_volume_remove_brick_parse (const char **words, int wordcount,
}
if (command != GF_OP_CMD_STATUS && command != GF_OP_CMD_STOP) {
- ret = dict_set_int32 (dict, "count", brick_count);
+ ret = dict_set_int32 (dict, "count", *brick_count);
if (ret)
goto out;
}
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index 81b273e2777..a83e281a23c 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -1980,6 +1980,7 @@ cli_cmd_volume_remove_brick_cbk (struct cli_state *state,
call_frame_t *frame = NULL;
dict_t *options = NULL;
gf_answer_t answer = GF_ANSWER_NO;
+ int brick_count = 0;
int sent = 0;
int parse_error = 0;
int need_question = 0;
@@ -1998,13 +1999,19 @@ cli_cmd_volume_remove_brick_cbk (struct cli_state *state,
goto out;
ret = cli_cmd_volume_remove_brick_parse (words, wordcount, &options,
- &need_question);
+ &need_question, &brick_count);
if (ret) {
cli_usage_out (word->pattern);
parse_error = 1;
goto out;
}
-
+ if (!brick_count) {
+ cli_err ("No bricks specified");
+ cli_usage_out (word->pattern);
+ parse_error = 1;
+ ret = -1;
+ goto out;
+ }
ret = dict_get_str (options, "volname", &volname);
if (ret || !volname) {
gf_log ("cli", GF_LOG_ERROR, "Failed to fetch volname");
diff --git a/cli/src/cli.h b/cli/src/cli.h
index 1e92d675199..a1be2b62d06 100644
--- a/cli/src/cli.h
+++ b/cli/src/cli.h
@@ -278,7 +278,8 @@ cli_cmd_volume_old_tier_parse (const char **words, int wordcount,
int32_t
cli_cmd_volume_remove_brick_parse (const char **words, int wordcount,
- dict_t **options, int *question);
+ dict_t **options, int *question,
+ int *brick_count);
int32_t
cli_cmd_volume_replace_brick_parse (const char **words, int wordcount,