summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPrashanth Pai <ppai@redhat.com>2018-04-19 12:50:20 +0530
committerPrashanth Pai <ppai@redhat.com>2018-04-19 15:18:40 +0530
commit9e7082b756058fe04d79c046fbd6dcbfa75a1716 (patch)
tree4a8134dc93284ef8eba606aa8bb773321c22d96f
parent0043c63f70776444f69667a4ef9596217ecb42b7 (diff)
Make glusterfsd binary print statedump & xlator dir
The glusterd2 needs following options, some of which are provided by gluster CLI today: --print-xlatordir --print-statedumpdir --print-logdir However, the CLI package need not be present on the machine running glusterd2. This change adds the above CLI options to glusterfsd binary which glusterd2 depends on. Reverts 9a1ae47c8d60836ae0628a04a153f28c1085c0e8 Related changes: https://review.gluster.org/#/c/19882/ https://github.com/gluster/glusterd2/pull/663 Updates: bz#1193929 Change-Id: I18c123b0d3350d2bd4f2400783e3b94e402a4e29 Signed-off-by: Prashanth Pai <ppai@redhat.com>
-rw-r--r--cli/src/Makefile.am1
-rw-r--r--cli/src/cli.c6
-rw-r--r--glusterfsd/src/glusterfsd.c43
-rw-r--r--glusterfsd/src/glusterfsd.h3
-rw-r--r--libglusterfs/src/glusterfs.h3
5 files changed, 49 insertions, 7 deletions
diff --git a/cli/src/Makefile.am b/cli/src/Makefile.am
index 63e3409165d..c6323e591de 100644
--- a/cli/src/Makefile.am
+++ b/cli/src/Makefile.am
@@ -20,7 +20,6 @@ AM_CPPFLAGS = $(GF_CPPFLAGS) \
-I$(top_builddir)/rpc/xdr/src\
-DDATADIR=\"$(localstatedir)\" \
-DCONFDIR=\"$(sysconfdir)/glusterfs\" \
- -DXLATORDIR=\"$(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator\" \
-DGSYNCD_PREFIX=\"$(GLUSTERFS_LIBEXECDIR)\"\
-DSYNCDAEMON_COMPILE=$(SYNCDAEMON_COMPILE) -DSBIN_DIR=\"$(sbindir)\"\
$(XML_CPPFLAGS)
diff --git a/cli/src/cli.c b/cli/src/cli.c
index 7903b57edb6..b58f211d3dd 100644
--- a/cli/src/cli.c
+++ b/cli/src/cli.c
@@ -338,12 +338,6 @@ cli_opt_parse (char *opt, struct cli_state *state)
exit (0);
}
- /* XLATORDIR passed through a -D flag to GCC */
- if (strcmp (opt, "print-xlatordir") == 0) {
- cli_out ("%s", XLATORDIR);
- exit (0);
- }
-
if (strcmp (opt, "xml") == 0) {
#if (HAVE_LIB_XML)
state->mode |= GLUSTER_MODE_XML;
diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c
index cb744f04fdf..b5b8e4d30a7 100644
--- a/glusterfsd/src/glusterfsd.c
+++ b/glusterfsd/src/glusterfsd.c
@@ -166,6 +166,13 @@ static struct argp_option gf_options[] = {
"Validate the netgroups file and print it out"},
{"print-exports", ARGP_PRINT_EXPORTS, "EXPORTS-FILE", 0,
"Validate the exports file and print it out"},
+ {"print-xlatordir", ARGP_PRINT_XLATORDIR_KEY, 0, OPTION_ARG_OPTIONAL,
+ "Print xlator directory path"},
+ {"print-statedumpdir", ARGP_PRINT_STATEDUMPDIR_KEY, 0,
+ OPTION_ARG_OPTIONAL,
+ "Print directory path in which statedumps shall be generated"},
+ {"print-logdir", ARGP_PRINT_LOGDIR_KEY, 0, OPTION_ARG_OPTIONAL,
+ "Print path of default log directory"},
{"volfile-max-fetch-attempts", ARGP_VOLFILE_MAX_FETCH_ATTEMPTS, "0",
OPTION_HIDDEN, "Maximum number of attempts to fetch the volfile"},
@@ -913,6 +920,18 @@ parse_opts (int key, char *arg, struct argp_state *state)
cmd_args->print_exports = arg;
break;
+ case ARGP_PRINT_XLATORDIR_KEY:
+ cmd_args->print_xlatordir = _gf_true;
+ break;
+
+ case ARGP_PRINT_STATEDUMPDIR_KEY:
+ cmd_args->print_statedumpdir = _gf_true;
+ break;
+
+ case ARGP_PRINT_LOGDIR_KEY:
+ cmd_args->print_logdir = _gf_true;
+ break;
+
case ARGP_MAC_COMPAT_KEY:
if (!arg)
arg = "on";
@@ -1982,6 +2001,13 @@ parse_cmdline (int argc, char *argv[], glusterfs_ctx_t *ctx)
}
argp_parse (&argp, argc, argv, ARGP_IN_ORDER, NULL, cmd_args);
+
+ if (cmd_args->print_xlatordir || cmd_args->print_statedumpdir ||
+ cmd_args->print_logdir) {
+ /* Just print, nothing else to do */
+ goto out;
+ }
+
if (cmd_args->print_netgroups) {
/* When this option is set we don't want to do anything else
* except for printing & verifying the netgroups file.
@@ -2578,6 +2604,23 @@ main (int argc, char *argv[])
if (ret)
goto out;
cmd = &ctx->cmd_args;
+
+ if (cmd->print_xlatordir) {
+ /* XLATORDIR passed through a -D flag to GCC */
+ printf ("%s\n", XLATORDIR);
+ goto out;
+ }
+
+ if (cmd->print_statedumpdir) {
+ printf ("%s\n", DEFAULT_VAR_RUN_DIRECTORY);
+ goto out;
+ }
+
+ if (cmd->print_logdir) {
+ printf ("%s\n", DEFAULT_LOG_FILE_DIRECTORY);
+ goto out;
+ }
+
if (cmd->print_netgroups) {
/* If this option is set we want to print & verify the file,
* set the return value (exit code in this case) and exit.
diff --git a/glusterfsd/src/glusterfsd.h b/glusterfsd/src/glusterfsd.h
index 38785441817..2a03ec09fa2 100644
--- a/glusterfsd/src/glusterfsd.h
+++ b/glusterfsd/src/glusterfsd.h
@@ -102,6 +102,9 @@ enum argp_option_keys {
ARGP_FUSE_EVENT_HISTORY_KEY = 180,
ARGP_THIN_CLIENT_KEY = 181,
ARGP_READER_THREAD_COUNT_KEY = 182,
+ ARGP_PRINT_XLATORDIR_KEY = 183,
+ ARGP_PRINT_STATEDUMPDIR_KEY = 184,
+ ARGP_PRINT_LOGDIR_KEY = 185,
};
struct _gfd_vol_top_priv {
diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h
index 5b9f2a45405..904d4b60d75 100644
--- a/libglusterfs/src/glusterfs.h
+++ b/libglusterfs/src/glusterfs.h
@@ -451,6 +451,9 @@ struct _cmd_args {
int32_t max_connect_attempts;
char *print_exports;
char *print_netgroups;
+ int print_xlatordir;
+ int print_statedumpdir;
+ int print_logdir;
/* advanced options */
uint32_t volfile_server_port;
char *volfile_server_transport;