diff options
| author | Csaba Henk <csaba@gluster.com> | 2011-04-18 17:25:25 +0000 | 
|---|---|---|
| committer | Anand Avati <avati@gluster.com> | 2011-04-19 02:30:18 -0700 | 
| commit | 184fba37889b87c27af90adf357b38fa95f1e78d (patch) | |
| tree | f87f0cef7efeac01a7cd0bc520e640928f221004 /cli/src | |
| parent | cc6d5c66090f576383c26bd0bdefadbcad708435 (diff) | |
cli: implement "system:: getwd" command
Signed-off-by: Csaba Henk <csaba@lowlife.hu>
Signed-off-by: Anand Avati <avati@gluster.com>
BUG: 2785 (gsyncd logs on slave side go to /dev/null)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2785
Diffstat (limited to 'cli/src')
| -rw-r--r-- | cli/src/cli-cmd-system.c | 28 | ||||
| -rw-r--r-- | cli/src/cli-rpc-ops.c | 56 | 
2 files changed, 83 insertions, 1 deletions
diff --git a/cli/src/cli-cmd-system.c b/cli/src/cli-cmd-system.c index e9d017f1d16..36300248909 100644 --- a/cli/src/cli-cmd-system.c +++ b/cli/src/cli-cmd-system.c @@ -154,6 +154,30 @@ out:          return ret;  } +int +cli_cmd_getwd_cbk (struct cli_state *state, struct cli_cmd_word *word, +                   const char **words, int wordcount) +{ +        int                             ret = -1; +        rpc_clnt_procedure_t            *proc = NULL; +        call_frame_t                    *frame = NULL; + +        if (wordcount != 2) { +                cli_usage_out (word->pattern); +                goto out; +        } + +        proc = &cli_rpc_prog->proctable[GLUSTER_CLI_GETWD]; +        if (proc && proc->fn) { +                frame = create_frame (THIS, THIS->ctx->pool); +                if (!frame) +                        goto out; +                ret = proc->fn (frame, THIS, NULL); +        } +out: +        return ret; +} +  struct cli_cmd cli_system_cmds[] = {          { "system:: getspec <VOLID>",            cli_cmd_getspec_cbk, @@ -167,6 +191,10 @@ struct cli_cmd cli_system_cmds[] = {            cli_cmd_fsm_log_cbk,            "display fsm transitions"}, +        { "system:: getwd", +          cli_cmd_getwd_cbk, +          "query glusterd work directory"}, +          { "system:: help",             cli_cmd_system_help_cbk,             "display help for system commands"}, diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 20d4c6f4a04..d6c507d2c9d 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -3348,6 +3348,59 @@ out:          return ret;  } + +int +gf_cli3_1_getwd_cbk (struct rpc_req *req, struct iovec *iov, +                       int count, void *myframe) +{ +        gf1_cli_getwd_rsp rsp   = {0,}; +        int               ret   = 0; + +        if (-1 == req->rpc_status) { +                goto out; +        } + +        ret = gf_xdr_to_cli_getwd_rsp (*iov, &rsp); +        if (ret < 0 || rsp.op_ret == -1) { +                gf_log ("", GF_LOG_ERROR, "error"); +                goto out; +        } + +        gf_log ("cli", GF_LOG_INFO, "Received resp to getwd"); + +        cli_out (rsp.wd); + +        ret = 0; + +out: +        cli_cmd_broadcast_response (ret); +        return ret; +} + +int32_t +gf_cli3_1_getwd (call_frame_t *frame, xlator_t *this, void *data) +{ +        int                      ret = -1; +        gf1_cli_getwd_req        req = {0,}; + +        GF_ASSERT (frame); +        GF_ASSERT (this); + +        if (!frame || !this) +                goto out; + +        ret = cli_cmd_submit (&req, frame, cli_rpc_prog, +                              GLUSTER_CLI_GETWD, NULL, +                              gf_xdr_from_cli_getwd_req, +                              this, gf_cli3_1_getwd_cbk); + +out: +        gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret); + +        return ret; +} + +  struct rpc_clnt_procedure gluster_cli_actors[GLUSTER_CLI_MAXVALUE] = {          [GLUSTER_CLI_NULL]             = {"NULL", NULL },          [GLUSTER_CLI_PROBE]            = {"PROBE_QUERY", gf_cli3_1_probe}, @@ -3376,7 +3429,8 @@ struct rpc_clnt_procedure gluster_cli_actors[GLUSTER_CLI_MAXVALUE] = {          [GLUSTER_CLI_GSYNC_SET]        = {"GSYNC_SET", gf_cli3_1_gsync_set},          [GLUSTER_CLI_PROFILE_VOLUME]   = {"PROFILE_VOLUME", gf_cli3_1_profile_volume},          [GLUSTER_CLI_QUOTA]            = {"QUOTA", gf_cli3_1_quota}, -        [GLUSTER_CLI_TOP_VOLUME]       = {"TOP_VOLUME", gf_cli3_1_top_volume} +        [GLUSTER_CLI_TOP_VOLUME]       = {"TOP_VOLUME", gf_cli3_1_top_volume}, +        [GLUSTER_CLI_GETWD]            = {"GETWD", gf_cli3_1_getwd}  };  struct rpc_clnt_program cli_prog = {  | 
