summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli-cmd-volume.c10
-rw-r--r--cli/src/cli3_1-cops.c13
2 files changed, 20 insertions, 3 deletions
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index 34651ae1..d2820768 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -85,6 +85,14 @@ cli_cmd_volume_info_cbk (struct cli_state *state, struct cli_cmd_word *word,
!strcmp (words[2], "all"))) {
ctx.flags = GF_CLI_GET_NEXT_VOLUME;
proc = &cli_rpc_prog->proctable[GF1_CLI_GET_NEXT_VOLUME];
+ } else if (wordcount == 3) {
+ ctx.flags = GF_CLI_GET_VOLUME;
+ ctx.volname = (char *)words[2];
+ if (strlen (ctx.volname) > 1024) {
+ cli_out ("Invalid volume name");
+ goto out;
+ }
+ proc = &cli_rpc_prog->proctable[GF1_CLI_GET_VOLUME];
}
local = cli_local_get ();
@@ -93,6 +101,8 @@ cli_cmd_volume_info_cbk (struct cli_state *state, struct cli_cmd_word *word,
goto out;
local->u.get_vol.flags = ctx.flags;
+ if (ctx.volname)
+ local->u.get_vol.volname = gf_strdup (ctx.volname);
frame->local = local;
diff --git a/cli/src/cli3_1-cops.c b/cli/src/cli3_1-cops.c
index 5bf0e367..67d46920 100644
--- a/cli/src/cli3_1-cops.c
+++ b/cli/src/cli3_1-cops.c
@@ -249,7 +249,7 @@ gf_cli3_1_get_volume_cbk (struct rpc_req *req, struct iovec *iov,
int ret = 0;
dict_t *dict = NULL;
char *volname = NULL;
- int32_t i = 1;
+ int32_t i = 0;
char key[1024] = {0,};
int32_t status = 0;
int32_t type = 0;
@@ -309,13 +309,20 @@ gf_cli3_1_get_volume_cbk (struct rpc_req *req, struct iovec *iov,
local = ((call_frame_t *)myframe)->local;
//cli_out ("Number of Volumes: %d", count);
- if (!count) {
+ if (!count && (local->u.get_vol.flags ==
+ GF_CLI_GET_NEXT_VOLUME)) {
local->u.get_vol.volname = NULL;
ret = 0;
goto out;
+ } else if (!count && (local->u.get_vol.flags ==
+ GF_CLI_GET_VOLUME)) {
+ cli_out ("Volume %s not present",
+ local->u.get_vol.volname);
+ ret = 0;
+ goto out;
}
- while ( i <= count) {
+ while ( i < count) {
cli_out ("");
snprintf (key, 256, "volume%d.name", i);
ret = dict_get_str (dict, key, &volname);