diff options
author | Avra Sengupta <asengupt@redhat.com> | 2013-02-27 16:55:09 +0530 |
---|---|---|
committer | Anand Avati <avati@redhat.com> | 2013-07-27 21:27:15 -0700 |
commit | c6b8143b9f61f59326563dd5274f9d1849577cef (patch) | |
tree | 6f777593ce70200cfec376ad8acec2870b0a1282 /cli/src/cli-cmd-parser.c | |
parent | 67cd7b9274b076750f768cd0994e58e36199f2b5 (diff) |
cli : Display error messages if virt file has been deleted or is invalid.
"gluster volume set <VOLNAME> group virt" will display error message
if virt file is deleted or is invalid.
Change-Id: Icb202b6a445597fcd9a3dcef8001891f2601a115
BUG: 916127
Signed-off-by: Avra Sengupta <asengupt@redhat.com>
Reviewed-on: http://review.gluster.org/4586
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'cli/src/cli-cmd-parser.c')
-rw-r--r-- | cli/src/cli-cmd-parser.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index c3f2cca9bb2..26ac6f384eb 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -712,7 +712,7 @@ cli_is_key_spl (char *key) #define GLUSTERD_DEFAULT_WORKDIR "/var/lib/glusterd" static int -cli_add_key_group (dict_t *dict, char *key, char *value) +cli_add_key_group (dict_t *dict, char *key, char *value, char **op_errstr) { int ret = -1; int opt_count = 0; @@ -726,6 +726,7 @@ cli_add_key_group (dict_t *dict, char *key, char *value) char *tagpath = NULL; char *buf = NULL; char line[PATH_MAX + 256] = {0,}; + char errstr[2048] = ""; FILE *fp = NULL; ret = gf_asprintf (&tagpath, "%s/groups/%s", @@ -738,6 +739,10 @@ cli_add_key_group (dict_t *dict, char *key, char *value) fp = fopen (tagpath, "r"); if (!fp) { ret = -1; + snprintf(errstr, sizeof(errstr), "Unable to open file '%s'." + " Error: %s", tagpath, strerror (errno)); + if (op_errstr) + *op_errstr = gf_strdup(errstr); goto out; } @@ -750,6 +755,10 @@ cli_add_key_group (dict_t *dict, char *key, char *value) tok_val = strtok_r (NULL, "=", &saveptr); if (!tok_key || !tok_val) { ret = -1; + snprintf(errstr, sizeof(errstr), "'%s' file format " + "not valid.", tagpath); + if (op_errstr) + *op_errstr = gf_strdup(errstr); goto out; } @@ -771,6 +780,10 @@ cli_add_key_group (dict_t *dict, char *key, char *value) if (!opt_count) { ret = -1; + snprintf(errstr, sizeof(errstr), "'%s' file format " + "not valid.", tagpath); + if (op_errstr) + *op_errstr = gf_strdup(errstr); goto out; } ret = dict_set_int32 (dict, "count", opt_count); @@ -791,7 +804,8 @@ out: #undef GLUSTERD_DEFAULT_WORKDIR int32_t -cli_cmd_volume_set_parse (const char **words, int wordcount, dict_t **options) +cli_cmd_volume_set_parse (const char **words, int wordcount, dict_t **options, + char **op_errstr) { dict_t *dict = NULL; char *volname = NULL; @@ -849,7 +863,7 @@ cli_cmd_volume_set_parse (const char **words, int wordcount, dict_t **options) goto out; } - ret = cli_add_key_group (dict, key, value); + ret = cli_add_key_group (dict, key, value, op_errstr); if (ret == 0) *options = dict; goto out; |