From af7b57b3099d07be2469895e4c83e3fa4442777e Mon Sep 17 00:00:00 2001 From: shishir gowda Date: Thu, 26 Aug 2010 04:10:19 +0000 Subject: Cli volume create detect dup bricks Signed-off-by: shishir gowda Signed-off-by: Anand V. Avati BUG: 1184 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1184 --- cli/src/cli-cmd-parser.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'cli/src/cli-cmd-parser.c') diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index f914e4e522e..d8464067dcd 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -48,6 +48,9 @@ cli_cmd_volume_create_parse (const char **words, int wordcount, dict_t **options int brick_list_size = 1; char brick_list[120000] = {0,}; int i = 0; + char *tmp_list = NULL; + char *tmpptr = NULL; + int j = 0; GF_ASSERT (words); GF_ASSERT (options); @@ -159,6 +162,19 @@ cli_cmd_volume_create_parse (const char **words, int wordcount, dict_t **options ret = -1; goto out; } + tmp_list = strdup(brick_list+1); + j = 0; + while(( brick_count != 0) && (j < brick_count)) { + strtok_r (tmp_list, " ", &tmpptr); + if (!(strcmp (tmp_list, words[brick_index]))) { + ret = -1; + cli_out ("Found duplicate" + " exports %s",words[brick_index]); + goto out; + } + tmp_list = tmpptr; + j++; + } strcat (brick_list, words[brick_index]); strcat (brick_list, " "); brick_list_size += (strlen (words[brick_index]) + 1); -- cgit