From 86ae67f117bc2a8c385144065c01e63027248a50 Mon Sep 17 00:00:00 2001 From: Prasanna Kumar Kalever Date: Wed, 15 Feb 2017 15:20:22 +0530 Subject: gluster-blockd: create logging directories Signed-off-by: Prasanna Kumar Kalever --- daemon/Makefile.am | 6 ++++-- daemon/gluster-blockd.c | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) (limited to 'daemon') diff --git a/daemon/Makefile.am b/daemon/Makefile.am index 1e018a8..038fce8 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -2,9 +2,11 @@ sbin_PROGRAMS = gluster-blockd gluster_blockd_SOURCES = gluster-blockd.c -gluster_blockd_CFLAGS = -I$(top_srcdir)/utils/ -I$(top_srcdir)/rpc +gluster_blockd_CFLAGS = -DDATADIR=\"$(localstatedir)\" \ + -I$(top_srcdir)/utils/ -I$(top_srcdir)/rpc -gluster_blockd_LDADD = $(PTHREAD) $(top_srcdir)/rpc/libgbxdr.la $(top_srcdir)/utils/libgb.la +gluster_blockd_LDADD = $(PTHREAD) $(top_srcdir)/rpc/libgbxdr.la \ + $(top_srcdir)/utils/libgb.la DISTCLEANFILES = Makefile.in diff --git a/daemon/gluster-blockd.c b/daemon/gluster-blockd.c index 01efbbb..24fde90 100644 --- a/daemon/gluster-blockd.c +++ b/daemon/gluster-blockd.c @@ -9,6 +9,7 @@ */ +# include # include # include @@ -17,6 +18,24 @@ +static bool +glusterBlockLogdirCreate(void) +{ + struct stat st = {0}; + + if (stat(GB_LOGDIR, &st) == -1) { + if (mkdir(GB_LOGDIR, 0755) == -1) { + LOG("mgmt", GB_LOG_ERROR, "mkdir(%s) failed (%s)", + GB_LOGDIR, strerror (errno)); + + return FALSE; + } + } + + return TRUE; +} + + void * glusterBlockCliThreadProc (void *vargp) { @@ -135,6 +154,9 @@ main (int argc, char **argv) pthread_t cli_thread; pthread_t server_thread; + if (glusterBlockLogdirCreate()) { + return -1; + } pmap_unset(GLUSTER_BLOCK_CLI, GLUSTER_BLOCK_CLI_VERS); pmap_unset(GLUSTER_BLOCK, GLUSTER_BLOCK_VERS); -- cgit