diff options
-rw-r--r-- | cli/src/cli-cmd-system.c | 28 | ||||
-rw-r--r-- | cli/src/cli-rpc-ops.c | 56 | ||||
-rw-r--r-- | rpc/rpc-lib/src/protocol-common.h | 1 | ||||
-rw-r--r-- | rpc/xdr/src/cli1-xdr.c | 20 | ||||
-rw-r--r-- | rpc/xdr/src/cli1-xdr.h | 16 | ||||
-rw-r--r-- | rpc/xdr/src/cli1-xdr.x | 12 | ||||
-rw-r--r-- | rpc/xdr/src/cli1.c | 28 | ||||
-rw-r--r-- | rpc/xdr/src/cli1.h | 12 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-handler.c | 27 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd.h | 3 |
10 files changed, 201 insertions, 2 deletions
diff --git a/cli/src/cli-cmd-system.c b/cli/src/cli-cmd-system.c index e9d017f1d..363002489 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 20d4c6f4a..d6c507d2c 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 = { diff --git a/rpc/rpc-lib/src/protocol-common.h b/rpc/rpc-lib/src/protocol-common.h index 8483fbcf4..a54c29fc5 100644 --- a/rpc/rpc-lib/src/protocol-common.h +++ b/rpc/rpc-lib/src/protocol-common.h @@ -198,6 +198,7 @@ enum gluster_cli_procnum { GLUSTER_CLI_PROFILE_VOLUME, GLUSTER_CLI_QUOTA, GLUSTER_CLI_TOP_VOLUME, + GLUSTER_CLI_GETWD, GLUSTER_CLI_MAXVALUE, }; diff --git a/rpc/xdr/src/cli1-xdr.c b/rpc/xdr/src/cli1-xdr.c index f1594eb96..0f5dc9866 100644 --- a/rpc/xdr/src/cli1-xdr.c +++ b/rpc/xdr/src/cli1-xdr.c @@ -796,3 +796,23 @@ xdr_gf1_cli_stats_volume_rsp (XDR *xdrs, gf1_cli_stats_volume_rsp *objp) return FALSE; return TRUE; } + +bool_t +xdr_gf1_cli_getwd_req (XDR *xdrs, gf1_cli_getwd_req *objp) +{ + if (!xdr_int (xdrs, &objp->unused)) + return FALSE; + return TRUE; +} + +bool_t +xdr_gf1_cli_getwd_rsp (XDR *xdrs, gf1_cli_getwd_rsp *objp) +{ + if (!xdr_int (xdrs, &objp->op_ret)) + return FALSE; + if (!xdr_int (xdrs, &objp->op_errno)) + return FALSE; + if (!xdr_string (xdrs, &objp->wd, ~0)) + return FALSE; + return TRUE; +} diff --git a/rpc/xdr/src/cli1-xdr.h b/rpc/xdr/src/cli1-xdr.h index 0a4b4ebd5..96f8def58 100644 --- a/rpc/xdr/src/cli1-xdr.h +++ b/rpc/xdr/src/cli1-xdr.h @@ -512,6 +512,18 @@ struct gf1_cli_stats_volume_rsp { }; typedef struct gf1_cli_stats_volume_rsp gf1_cli_stats_volume_rsp; +struct gf1_cli_getwd_req { + int unused; +}; +typedef struct gf1_cli_getwd_req gf1_cli_getwd_req; + +struct gf1_cli_getwd_rsp { + int op_ret; + int op_errno; + char *wd; +}; +typedef struct gf1_cli_getwd_rsp gf1_cli_getwd_rsp; + /* the xdr functions */ #if defined(__STDC__) || defined(__cplusplus) @@ -572,6 +584,8 @@ extern bool_t xdr_gf1_cli_gsync_set_req (XDR *, gf1_cli_gsync_set_req*); extern bool_t xdr_gf1_cli_gsync_set_rsp (XDR *, gf1_cli_gsync_set_rsp*); extern bool_t xdr_gf1_cli_stats_volume_req (XDR *, gf1_cli_stats_volume_req*); extern bool_t xdr_gf1_cli_stats_volume_rsp (XDR *, gf1_cli_stats_volume_rsp*); +extern bool_t xdr_gf1_cli_getwd_req (XDR *, gf1_cli_getwd_req*); +extern bool_t xdr_gf1_cli_getwd_rsp (XDR *, gf1_cli_getwd_rsp*); #else /* K&R C */ extern bool_t xdr_gf1_cluster_type (); @@ -631,6 +645,8 @@ extern bool_t xdr_gf1_cli_gsync_set_req (); extern bool_t xdr_gf1_cli_gsync_set_rsp (); extern bool_t xdr_gf1_cli_stats_volume_req (); extern bool_t xdr_gf1_cli_stats_volume_rsp (); +extern bool_t xdr_gf1_cli_getwd_req (); +extern bool_t xdr_gf1_cli_getwd_rsp (); #endif /* K&R C */ diff --git a/rpc/xdr/src/cli1-xdr.x b/rpc/xdr/src/cli1-xdr.x index fc38cf7b2..99344a949 100644 --- a/rpc/xdr/src/cli1-xdr.x +++ b/rpc/xdr/src/cli1-xdr.x @@ -57,7 +57,7 @@ enum gf1_cli_stats_op { GF_CLI_STATS_NONE = 0, GF_CLI_STATS_START = 1, GF_CLI_STATS_STOP = 2, - GF_CLI_STATS_INFO = 3 + GF_CLI_STATS_INFO = 3, GF_CLI_STATS_TOP = 4 }; @@ -375,3 +375,13 @@ struct gf1_cli_quota_rsp { string limit_list<>; gf_quota_type type; }; + +struct gf1_cli_getwd_req { + int unused; +} ; + +struct gf1_cli_getwd_rsp { + int op_ret; + int op_errno; + string wd<>; +}; diff --git a/rpc/xdr/src/cli1.c b/rpc/xdr/src/cli1.c index bd3cbf0c7..e917929b3 100644 --- a/rpc/xdr/src/cli1.c +++ b/rpc/xdr/src/cli1.c @@ -712,3 +712,31 @@ gf_xdr_from_cli_stats_volume_rsp (struct iovec outmsg, void *args) return xdr_serialize_generic (outmsg, (void *)args, (xdrproc_t)xdr_gf1_cli_stats_volume_rsp); } + +ssize_t +gf_xdr_to_cli_getwd_req (struct iovec inmsg, void *args) +{ + return xdr_to_generic (inmsg, (void *)args, + (xdrproc_t)xdr_gf1_cli_getwd_req); +} + +ssize_t +gf_xdr_from_cli_getwd_req (struct iovec outmsg, void *args) +{ + return xdr_serialize_generic (outmsg, (void *)args, + (xdrproc_t)xdr_gf1_cli_getwd_req); +} + +ssize_t +gf_xdr_to_cli_getwd_rsp (struct iovec inmsg, void *args) +{ + return xdr_to_generic (inmsg, (void *)args, + (xdrproc_t)xdr_gf1_cli_getwd_rsp); +} + +ssize_t +gf_xdr_from_cli_getwd_rsp (struct iovec outmsg, void *args) +{ + return xdr_serialize_generic (outmsg, (void *)args, + (xdrproc_t)xdr_gf1_cli_getwd_rsp); +} diff --git a/rpc/xdr/src/cli1.h b/rpc/xdr/src/cli1.h index 9bc3a196a..32e310aae 100644 --- a/rpc/xdr/src/cli1.h +++ b/rpc/xdr/src/cli1.h @@ -315,4 +315,16 @@ gf_xdr_to_cli_stats_volume_rsp (struct iovec inmsg, void *args); ssize_t gf_xdr_from_cli_stats_volume_rsp (struct iovec outmsg, void *args); + +ssize_t +gf_xdr_to_cli_getwd_req (struct iovec inmsg, void *args); + +ssize_t +gf_xdr_from_cli_getwd_req (struct iovec outmsg, void *args); + +ssize_t +gf_xdr_to_cli_getwd_rsp (struct iovec inmsg, void *args); + +ssize_t +gf_xdr_from_cli_getwd_rsp (struct iovec outmsg, void *args); #endif /* !_CLI1_H */ diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c index 42909136a..a78c876e3 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handler.c +++ b/xlators/mgmt/glusterd/src/glusterd-handler.c @@ -3202,6 +3202,32 @@ out: } int +glusterd_handle_getwd (rpcsvc_request_t *req) +{ + int32_t ret = -1; + gf1_cli_getwd_rsp rsp = {0,}; + glusterd_conf_t *priv = NULL; + + GF_ASSERT (req); + + priv = THIS->private; + GF_ASSERT (priv); + + gf_log ("glusterd", GF_LOG_INFO, "Received getwd req"); + + rsp.wd = priv->workdir; + + ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL, + gf_xdr_from_cli_getwd_rsp); + + glusterd_friend_sm (); + glusterd_op_sm (); + + return ret; +} + + +int glusterd_friend_remove (uuid_t uuid, char *hostname) { int ret = 0; @@ -3899,6 +3925,7 @@ rpcsvc_actor_t gd_svc_cli_actors[] = { [GLUSTER_CLI_GSYNC_SET] = { "GSYNC_SET", GLUSTER_CLI_GSYNC_SET, glusterd_handle_gsync_set, NULL, NULL}, [GLUSTER_CLI_PROFILE_VOLUME] = { "STATS_VOLUME", GLUSTER_CLI_PROFILE_VOLUME, glusterd_handle_cli_profile_volume, NULL, NULL}, [GLUSTER_CLI_QUOTA] = { "QUOTA", GLUSTER_CLI_QUOTA, glusterd_handle_quota, NULL, NULL}, + [GLUSTER_CLI_GETWD] = { "GETWD", GLUSTER_CLI_GETWD, glusterd_handle_getwd, NULL, NULL}, }; diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h index 9175983c7..2fcd11c11 100644 --- a/xlators/mgmt/glusterd/src/glusterd.h +++ b/xlators/mgmt/glusterd/src/glusterd.h @@ -495,6 +495,9 @@ glusterd_validate_reconfopts (glusterd_volinfo_t *volinfo, dict_t *val_dict, cha int glusterd_handle_cli_profile_volume (rpcsvc_request_t *req); +int +glusterd_handle_getwd (rpcsvc_request_t *req); + int32_t glusterd_set_volume (rpcsvc_request_t *req, dict_t *dict); int |