summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCsaba Henk <csaba@gluster.com>2011-04-18 17:25:25 +0000
committerAnand Avati <avati@gluster.com>2011-04-19 02:30:18 -0700
commit184fba37889b87c27af90adf357b38fa95f1e78d (patch)
treef87f0cef7efeac01a7cd0bc520e640928f221004
parentcc6d5c66090f576383c26bd0bdefadbcad708435 (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
-rw-r--r--cli/src/cli-cmd-system.c28
-rw-r--r--cli/src/cli-rpc-ops.c56
-rw-r--r--rpc/rpc-lib/src/protocol-common.h1
-rw-r--r--rpc/xdr/src/cli1-xdr.c20
-rw-r--r--rpc/xdr/src/cli1-xdr.h16
-rw-r--r--rpc/xdr/src/cli1-xdr.x12
-rw-r--r--rpc/xdr/src/cli1.c28
-rw-r--r--rpc/xdr/src/cli1.h12
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c27
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.h3
10 files changed, 201 insertions, 2 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 = {
diff --git a/rpc/rpc-lib/src/protocol-common.h b/rpc/rpc-lib/src/protocol-common.h
index 8483fbcf459..a54c29fc55a 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 f1594eb9662..0f5dc98669c 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 0a4b4ebd5f5..96f8def58c7 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 fc38cf7b252..99344a94909 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 bd3cbf0c7bd..e917929b349 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 9bc3a196ae5..32e310aae83 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 42909136a8c..a78c876e3f5 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 9175983c7c9..2fcd11c11f1 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