diff options
| author | Pranith Kumar K <pranithk@gluster.com> | 2010-09-22 04:21:02 +0000 | 
|---|---|---|
| committer | Vijay Bellur <vijay@dev.gluster.com> | 2010-09-22 04:14:32 -0700 | 
| commit | d42f248c58b2ca73fb56a3e091c8e967e2435546 (patch) | |
| tree | c7fb8d6a35206faa42e8d008f37a8aa2fc0a42e0 /cli/src/cli-cmd-parser.c | |
| parent | f47b0c55de9941823fbefe4b3a7e37179d6d4329 (diff) | |
mgmt/glusterd: replace-brick validations
Signed-off-by: Pranith Kumar K <pranithk@gluster.com>
Signed-off-by: Vijay Bellur <vijay@dev.gluster.com>
BUG: 1657 (validations for replace-brick while stage op)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1657
Diffstat (limited to 'cli/src/cli-cmd-parser.c')
| -rw-r--r-- | cli/src/cli-cmd-parser.c | 59 | 
1 files changed, 31 insertions, 28 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index 2b7cdd9f612..9de13e56ce7 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -729,42 +729,45 @@ cli_cmd_volume_replace_brick_parse (const char **words, int wordcount,          }          delimiter = strchr ((char *)words[3], ':'); -        if (delimiter && delimiter != words[3] -            && *(delimiter+1) == '/') { +        if (!delimiter || delimiter == words[3] +            || *(delimiter+1) != '/') { +                cli_out ("wrong brick type: %s, use " +                        "<HOSTNAME>:<export-dir-abs-path>", words[3]); +                ret = -1; +                goto out; +        } else {                  cli_path_strip_trailing_slashes (delimiter + 1); -                ret = dict_set_str (dict, "src-brick", (char *)words[3]); - -                if (ret) -                        goto out; +        } +        ret = dict_set_str (dict, "src-brick", (char *)words[3]); -                if (wordcount < 5) { -                        ret = -1; -                        goto out; -                } +        if (ret) +                goto out; -                delimiter = strchr ((char *)words[4], ':'); -                if (!delimiter || delimiter == words[4] -                    || *(delimiter+1) != '/') { -                        cli_out ("wrong brick type: %s, use " -                                "<HOSTNAME>:<export-dir-abs-path>", words[4]); -                        ret = -1; -                        goto out; -                } else { -                        cli_path_strip_trailing_slashes (delimiter + 1); -                } +        if (wordcount < 5) { +                ret = -1; +                goto out; +        } +        delimiter = strchr ((char *)words[4], ':'); +        if (!delimiter || delimiter == words[4] +            || *(delimiter+1) != '/') { +                cli_out ("wrong brick type: %s, use " +                        "<HOSTNAME>:<export-dir-abs-path>", words[4]); +                ret = -1; +                goto out; +        } else { +                cli_path_strip_trailing_slashes (delimiter + 1); +        } -                ret = dict_set_str (dict, "dst-brick", (char *)words[4]); -                if (ret) -                        goto out; +        ret = dict_set_str (dict, "dst-brick", (char *)words[4]); -                op_index = 5; -        } else { -                op_index = 3; -        } +        if (ret) +                goto out; -        if (wordcount < (op_index + 1)) { +        op_index = 5; +        if ((wordcount < (op_index + 1)) || +            (wordcount > (op_index + 1))) {                  ret = -1;                  goto out;          }  | 
