diff options
-rw-r--r-- | cli/src/cli-cmd-parser.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index 8e914fa87..0a2bb5318 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -2833,24 +2833,37 @@ cli_snap_create_parse (dict_t *dict, const char **words, int wordcount, int ret = -1; uint64_t volcount = 0; char key[PATH_MAX] = ""; + char *snapname = NULL; GF_ASSERT (words); GF_ASSERT (dict); if (wordcount <= cmdi + 1) { + cli_err ("Invalid Syntax."); gf_log ("cli", GF_LOG_ERROR, "Too less words for snap create command"); goto out; } if (strlen(words[cmdi]) >= GLUSTERD_MAX_SNAP_NAME) { - cli_out ("snapshot create: failed: snapname cannot exceed " + cli_err ("snapshot create: failed: snapname cannot exceed " "256 characters."); gf_log ("cli", GF_LOG_ERROR, "Snapname too long"); goto out; } + snapname = (char *) words[cmdi]; + for (i = 0 ; i < strlen (snapname); i++) { + /* Following volume name convention */ + if (!isalnum (snapname[i]) && (snapname[i] != '_' + && (snapname[i] != '-'))) { + /* TODO : Is this message enough?? */ + cli_err ("Please provide a valid snapname"); + goto out; + } + } + ret = dict_set_str (dict, "snapname", (char *)words[cmdi]); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Could not save snap " @@ -2878,7 +2891,7 @@ cli_snap_create_parse (dict_t *dict, const char **words, int wordcount, if (i >= cmdi + 2) { ret = -1; - cli_out("Creating multiple volume snapshot is not " + cli_err("Creating multiple volume snapshot is not " "supported as of now"); goto out; } @@ -2888,7 +2901,7 @@ cli_snap_create_parse (dict_t *dict, const char **words, int wordcount, if (volcount == 0) { ret = -1; - cli_out ("Please provide the volume name"); + cli_err ("Please provide the volume name"); gf_log ("cli", GF_LOG_ERROR, "Invalid Syntax"); goto out; } @@ -2912,6 +2925,7 @@ cli_snap_create_parse (dict_t *dict, const char **words, int wordcount, ++i; if (i > (wordcount - 1)) { ret = -1; + cli_err ("Please provide a description"); gf_log ("cli", GF_LOG_ERROR, "Description not provided"); goto out; @@ -2935,6 +2949,7 @@ cli_snap_create_parse (dict_t *dict, const char **words, int wordcount, if ((strcmp (words[i], "force") != 0)) { ret = -1; + cli_err ("Invalid Syntax."); gf_log ("cli", GF_LOG_ERROR, "Invalid Syntax"); goto out; } |