diff options
Diffstat (limited to 'cli')
| -rw-r--r-- | cli/src/cli-cmd-volume.c | 4 | ||||
| -rw-r--r-- | cli/src/cli-rpc-ops.c | 16 | ||||
| -rw-r--r-- | cli/src/cli.h | 2 | 
3 files changed, 17 insertions, 5 deletions
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index 18d17b4546d..b5a177a869d 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -1376,7 +1376,7 @@ cli_cmd_volume_status_cbk (struct cli_state *state,  int -cli_print_brick_status (char *brick, int port, int online, int pid) +cli_print_brick_status (char *brick, int port, int online, char *pid)  {          int  fieldlen = CLI_VOL_STATUS_BRICK_LEN;          char buf[80] = {0,}; @@ -1400,7 +1400,7 @@ cli_print_brick_status (char *brick, int port, int online, int pid)                          printf ("%s", p);                          while (num_tabs-- != 0)                                  printf ("\t"); -                        cli_out ("%d\t%c\t%d", port, online?'Y':'N', pid); +                        cli_out ("%d\t%c\t%s", port, online?'Y':'N', pid);                          bricklen = 0;                  }          } diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 2841a32d589..8a88e57d595 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -3807,7 +3807,8 @@ gf_cli3_1_status_cbk (struct rpc_req *req, struct iovec *iov,          int                             port = 0;          int                             online = 0;          char                            key[1024] = {0,}; -        int                             pid = 0; +        int                             pid = -1; +        char                            *pid_str = NULL;          char                            brick[8192] = {0,};          char                            *volname = NULL; @@ -3875,11 +3876,22 @@ gf_cli3_1_status_cbk (struct rpc_req *req, struct iovec *iov,                  memset (key, 0, sizeof (key));                  snprintf (key, sizeof (key), "brick%d.pid", i);                  ret = dict_get_int32 (dict, key, &pid); +                if (ret) +                        goto out; +                if (pid == -1) +                        ret = gf_asprintf (&pid_str, "%s", "N/A"); +                else +                        ret = gf_asprintf (&pid_str, "%d", pid); + +                if (ret == -1) +                        goto out;                  snprintf (brick, sizeof (brick) -1, "%s:%s", hostname, path);                  cli_print_line (CLI_BRICK_STATUS_LINE_LEN); -                cli_print_brick_status (brick, port, online, pid); +                cli_print_brick_status (brick, port, online, pid_str); +                if (pid_str) +                        GF_FREE (pid_str);          }          ret = rsp.op_ret; diff --git a/cli/src/cli.h b/cli/src/cli.h index 70310f103ed..1d2e069735a 100644 --- a/cli/src/cli.h +++ b/cli/src/cli.h @@ -236,7 +236,7 @@ cli_cmd_volume_status_parse (const char **words, int wordcount,                               dict_t **options);  int -cli_print_brick_status (char *brick, int port, int online, int pid); +cli_print_brick_status (char *brick, int port, int online, char *pid);  void  cli_print_line (int len);  | 
