From b8d5fd2b88db7e18a10e57a0edf1a41eda4f5314 Mon Sep 17 00:00:00 2001 From: Avra Sengupta Date: Thu, 24 Jan 2013 11:39:48 +0530 Subject: glusterfs : Moved option files, and statedumps from /tmp Change-Id: Ibdede396c4d6859225937316b7a59a661bcaf9f5 BUG: 764890 Signed-off-by: Avra Sengupta Reviewed-on: http://review.gluster.org/4422 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- libglusterfs/src/Makefile.am | 3 ++- libglusterfs/src/glusterfs.h | 2 ++ libglusterfs/src/run.c | 2 +- libglusterfs/src/statedump.c | 43 +++++++++++++++++++++++++------------------ 4 files changed, 30 insertions(+), 20 deletions(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/Makefile.am b/libglusterfs/src/Makefile.am index 0503e97f6b0..d0a617e7b71 100644 --- a/libglusterfs/src/Makefile.am +++ b/libglusterfs/src/Makefile.am @@ -1,5 +1,6 @@ libglusterfs_la_CFLAGS = -Wall $(GF_CFLAGS) \ - $(GF_DARWIN_LIBGLUSTERFS_CFLAGS) + $(GF_DARWIN_LIBGLUSTERFS_CFLAGS) \ + -DDATADIR=\"$(localstatedir)\" libglusterfs_la_CPPFLAGS = $(GF_CPPFLAGS) -D__USE_FILE_OFFSET64 \ -DXLATORDIR=\"$(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator\" \ diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h index dae5398415e..74e6847a0fd 100644 --- a/libglusterfs/src/glusterfs.h +++ b/libglusterfs/src/glusterfs.h @@ -134,6 +134,8 @@ #define ZR_FILE_CONTENT_REQUEST(key) (!strncmp(key, ZR_FILE_CONTENT_STR, \ ZR_FILE_CONTENT_STRLEN)) +#define DEFAULT_VAR_RUN_DIRECTORY DATADIR "/run/gluster" + /* GlusterFS's maximum supported Auxilary GIDs */ /* TODO: Keeping it to 200, so that we can fit in 2KB buffer for auth data * in RPC server code, if there is ever need for having more aux-gids, then diff --git a/libglusterfs/src/run.c b/libglusterfs/src/run.c index 94511b1c356..ebe7f396299 100644 --- a/libglusterfs/src/run.c +++ b/libglusterfs/src/run.c @@ -490,7 +490,7 @@ main (int argc, char **argv) printf ("%d %d [%s]\n", ret, errno, strerror (errno)); TBANNER ("output redirection"); - fd = open ("/tmp/foof", O_WRONLY|O_CREAT|O_TRUNC, 0600); + fd = mkstemp ("/tmp/foof"); assert (fd != -1); runinit (&runner); runner_add_args (&runner, "echo", "foo", NULL); diff --git a/libglusterfs/src/statedump.c b/libglusterfs/src/statedump.c index b8ba882f3e4..8175faba49b 100644 --- a/libglusterfs/src/statedump.c +++ b/libglusterfs/src/statedump.c @@ -541,7 +541,7 @@ out: return all_disabled; } -/* These options are dumped by default if /tmp/glusterdump.options +/* These options are dumped by default if glusterdump.options file exists and it is emtpty */ static int @@ -635,21 +635,22 @@ gf_proc_dump_options_init () char *saveptr = NULL; char dump_option_file[PATH_MAX]; - /* glusterd will create a file /tmp/glusterdump..options and + /* glusterd will create a file glusterdump..options and sets the statedump options for the process and the file is removed after the statedump is taken. Direct issue of SIGUSR1 does not have mechanism for considering the statedump options. So to have a way of configuring the statedump of all the glusterfs processes through - both cli command and SIGUSR1, /tmp/glusterdump.options file - is searched and the options mentioned in it are given the higher - priority. + both cli command and SIGUSR1, glusterdump.options file is searched + and the options mentioned in it are given the higher priority. */ snprintf (dump_option_file, sizeof (dump_option_file), - "/tmp/glusterdump.options"); + DEFAULT_VAR_RUN_DIRECTORY + "/glusterdump.options"); fp = fopen (dump_option_file, "r"); if (!fp) { snprintf (dump_option_file, sizeof (dump_option_file), - "/tmp/glusterdump.%d.options", getpid ()); + DEFAULT_VAR_RUN_DIRECTORY + "/glusterdump.%d.options", getpid ()); fp = fopen (dump_option_file, "r"); @@ -696,15 +697,15 @@ gf_proc_dump_options_init () void gf_proc_dump_info (int signum, glusterfs_ctx_t *ctx) { - int i = 0; - int ret = -1; - glusterfs_graph_t *trav = NULL; - char brick_name[PATH_MAX] = {0,}; - struct timeval tv = {0,}; - char timestr[256] = {0,}; - char sign_string[512] = {0,}; - char tmp_dump_name[] = "/tmp/dumpXXXXXX"; - char path[PATH_MAX] = {0,}; + int i = 0; + int ret = -1; + glusterfs_graph_t *trav = NULL; + char brick_name[PATH_MAX] = {0,}; + char timestr[256] = {0,}; + char sign_string[512] = {0,}; + char tmp_dump_name[PATH_MAX] = {0,}; + char path[PATH_MAX] = {0,}; + struct timeval tv = {0,}; gf_proc_dump_lock (); @@ -722,8 +723,14 @@ gf_proc_dump_info (int signum, glusterfs_ctx_t *ctx) snprintf (path, sizeof (path), "%s/%s.%d.dump.%"PRIu64, ((dump_options.dump_path != NULL)?dump_options.dump_path: - ((ctx->statedump_path != NULL)?ctx->statedump_path:"/tmp")), - brick_name, getpid(), (uint64_t) time (NULL)); + ((ctx->statedump_path != NULL)?ctx->statedump_path: + DEFAULT_VAR_RUN_DIRECTORY)), brick_name, getpid(), + (uint64_t) time (NULL)); + + snprintf (tmp_dump_name, PATH_MAX, "%s/dumpXXXXXX", + ((dump_options.dump_path != NULL)?dump_options.dump_path: + ((ctx->statedump_path != NULL)?ctx->statedump_path: + DEFAULT_VAR_RUN_DIRECTORY))); ret = gf_proc_dump_open (tmp_dump_name); if (ret < 0) -- cgit