diff options
Diffstat (limited to 'cli')
| -rw-r--r-- | cli/src/cli-cmd-parser.c | 16 | ||||
| -rw-r--r-- | cli/src/cli-cmd-volume.c | 36 | 
2 files changed, 44 insertions, 8 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index daec9c8d6..479df9386 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -322,12 +322,16 @@ cli_cmd_volume_set_parse (const char **words, int wordcount, dict_t **options)          if (ret)                  goto out; -        for (i = 3; i < wordcount; i++) { -                key = strtok ((char *)words[i], "="); -                value = strtok (NULL, "="); - -                GF_ASSERT (key); -                GF_ASSERT (value); +        for (i = 3; i < wordcount; i+=2) { + +		key = (char *) words[i]; +		value = (char *) words[i+1]; +                 +		if ( !key || !value) { +			ret = -1; +			cli_out ("Usage: volume set <VOLNAME> <KEY> <VALUE>"); +			goto out; +        	}                  count++; diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index b8a5df6d6..fc7fda9df 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -71,6 +71,11 @@ cli_cmd_volume_info_usage ()          cli_out ("Usage: volume info [all|<VOLNAME>]");  } +void  +cli_cmd_volume_set_usage () +{ +	cli_out ("Usage: volume set <VOLNAME> <KEY> <VALUE>"); +}  int  cli_cmd_volume_info_cbk (struct cli_state *state, struct cli_cmd_word *word,                           const char **words, int wordcount) @@ -424,8 +429,35 @@ int  cli_cmd_volume_set_cbk (struct cli_state *state, struct cli_cmd_word *word,                          const char **words, int wordcount)  { -        cli_cmd_broadcast_response (0); -        return 0; + +	int                     ret = -1; +        rpc_clnt_procedure_t    *proc = NULL; +        call_frame_t            *frame = NULL; +        dict_t                  *options = NULL; + +        proc = &cli_rpc_prog->proctable[GF1_CLI_SET_VOLUME]; + +        frame = create_frame (THIS, THIS->ctx->pool); +        if (!frame) +                goto out; + +        ret = cli_cmd_volume_set_parse (words, wordcount, &options); + +        if (ret) { +                cli_cmd_volume_set_usage (); +                goto out; +        } + +        if (proc->fn) { +                ret = proc->fn (frame, THIS, options); +        } + +out: +        if (options) +                dict_unref (options); + +        return ret; +  }  void  | 
