summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
authorSachidananda <sac@gluster.com>2011-07-17 08:10:29 +0000
committerAnand Avati <avati@gluster.com>2011-07-17 23:19:05 -0700
commit0773f5a34e3b5c503674bceaa1902454fc841879 (patch)
tree33b1e67d826ec1fddbfe070353710d43de1e8a36 /cli
parent613a6369d63e3ec87735a5427e4e87894f884749 (diff)
Strip extra `/' from filenames.
While peforming replace-brick, delete-brick, remove-brick... and related operations resolve extra slashes as single path separator. i.e treat /foo//bar// as /foo/bar. Signed-off-by: Sachidananda Urs <sac@gluster.com> Signed-off-by: Anand Avati <avati@gluster.com> BUG: 3183 (When creating volumes brick paths are not handled properly.) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=3183
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli-cmd-parser.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index a767dfc35..c7d9c686f 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -856,7 +856,9 @@ cli_cmd_volume_remove_brick_parse (const char **words, int wordcount,
goto out;
} else {
delimiter = strrchr(words[brick_index], ':');
- cli_path_strip_trailing_slashes (delimiter + 1);
+ ret = cli_canonicalize_path (delimiter + 1);
+ if (ret)
+ goto out;
}
j = tmp_index;
@@ -944,12 +946,14 @@ cli_cmd_volume_replace_brick_parse (const char **words, int wordcount,
if (validate_brick_name ((char *)words[3])) {
cli_out ("wrong brick type: %s, use "
- "<HOSTNAME>:<export-dir-abs-path>", words[3]);
+ "<HOSTNAME>:<export-dir-abs-path>", words[3]);
ret = -1;
goto out;
} else {
delimiter = strrchr ((char *)words[3], ':');
- cli_path_strip_trailing_slashes (delimiter + 1);
+ ret = cli_canonicalize_path (delimiter + 1);
+ if (ret)
+ goto out;
}
ret = dict_set_str (dict, "src-brick", (char *)words[3]);
@@ -963,12 +967,14 @@ cli_cmd_volume_replace_brick_parse (const char **words, int wordcount,
if (validate_brick_name ((char *)words[4])) {
cli_out ("wrong brick type: %s, use "
- "<HOSTNAME>:<export-dir-abs-path>", words[4]);
+ "<HOSTNAME>:<export-dir-abs-path>", words[4]);
ret = -1;
goto out;
} else {
delimiter = strrchr ((char *)words[4], ':');
- cli_path_strip_trailing_slashes (delimiter + 1);
+ ret = cli_canonicalize_path (delimiter + 1);
+ if (ret)
+ goto out;
}
@@ -1071,7 +1077,9 @@ cli_cmd_log_filename_parse (const char **words, int wordcount, dict_t **options)
ret = -1;
goto out;
} else {
- cli_path_strip_trailing_slashes (delimiter + 1);
+ ret = cli_canonicalize_path (delimiter + 1);
+ if (ret)
+ goto out;
}
ret = dict_set_str (dict, "brick", str);
if (ret)
@@ -1185,7 +1193,9 @@ cli_cmd_log_locate_parse (const char **words, int wordcount, dict_t **options)
ret = -1;
goto out;
} else {
- cli_path_strip_trailing_slashes (delimiter + 1);
+ ret = cli_canonicalize_path (delimiter + 1);
+ if (ret)
+ goto out;
}
str = (char *)words[4];
ret = dict_set_str (dict, "brick", str);
@@ -1234,7 +1244,9 @@ cli_cmd_log_rotate_parse (const char **words, int wordcount, dict_t **options)
ret = -1;
goto out;
} else {
- cli_path_strip_trailing_slashes (delimiter + 1);
+ ret = cli_canonicalize_path (delimiter + 1);
+ if (ret)
+ goto out;
}
str = (char *)words[4];
ret = dict_set_str (dict, "brick", str);
@@ -1562,7 +1574,9 @@ cli_cmd_volume_top_parse (const char **words, int wordcount,
ret = -1;
goto out;
} else {
- cli_path_strip_trailing_slashes (delimiter + 1);
+ ret = cli_canonicalize_path (delimiter + 1);
+ if (ret)
+ goto out;
}
ret = dict_set_str (dict, "brick", value);
@@ -1582,7 +1596,7 @@ cli_cmd_volume_top_parse (const char **words, int wordcount,
if (ret || (blk_size <= 0)) {
if (blk_size < 0)
cli_out ("block size is an invalid number");
- else
+ else
cli_out ("block size should be an integer "
"greater than zero");
ret = -1;
@@ -1632,4 +1646,3 @@ out:
dict_destroy (dict);
return ret;
}
-