summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cli/Makefile.am6
-rw-r--r--configure.ac6
-rw-r--r--daemon/Makefile.am6
-rw-r--r--daemon/gluster-blockd.c22
-rw-r--r--rpc/Makefile.am6
-rw-r--r--utils/Makefile.am2
-rw-r--r--utils/common.h11
7 files changed, 49 insertions, 10 deletions
diff --git a/cli/Makefile.am b/cli/Makefile.am
index 4d908a9..27a9a8a 100644
--- a/cli/Makefile.am
+++ b/cli/Makefile.am
@@ -2,9 +2,11 @@ sbin_PROGRAMS = gluster-block
gluster_block_SOURCES = gluster-block.c
-gluster_block_LDADD = $(top_srcdir)/rpc/libgbxdr.la $(top_srcdir)/utils/libgb.la
+gluster_block_LDADD = $(top_srcdir)/rpc/libgbxdr.la \
+ $(top_srcdir)/utils/libgb.la
-gluster_block_CFLAGS = -I$(top_srcdir)/utils/ -I$(top_srcdir)/rpc
+gluster_block_CFLAGS = -DDATADIR=\"$(localstatedir)\" \
+ -I$(top_srcdir)/utils/ -I$(top_srcdir)/rpc
DISTCLEANFILES = Makefile.in
diff --git a/configure.ac b/configure.ac
index 0f89e66..2285c29 100644
--- a/configure.ac
+++ b/configure.ac
@@ -61,6 +61,12 @@ AC_CHECK_LIB([pthread], [pthread_mutex_init],[PTHREAD="-lpthread"],
AC_MSG_ERROR([Posix threads library is required to build gluster-block]))
AC_SUBST(PTHREAD)
+# Dirty hacky stuff to make STATEDIR work
+if test "x$prefix" = xNONE; then
+ test $localstatedir = '${prefix}/var' && localstatedir=$ac_default_prefix/var
+ localstatedir=/var
+fi
+
# Checks for typedefs, structures, and compiler characteristics.
AC_CHECK_HEADER_STDBOOL
AC_TYPE_SIZE_T
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 <sys/stat.h>
# include <pthread.h>
# include <rpc/pmap_clnt.h>
@@ -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);
diff --git a/rpc/Makefile.am b/rpc/Makefile.am
index 51beeb8..9f85e23 100644
--- a/rpc/Makefile.am
+++ b/rpc/Makefile.am
@@ -1,10 +1,12 @@
noinst_LTLIBRARIES = libgbxdr.la
-libgbxdr_la_SOURCES = block_clnt.c block_xdr.c block_svc.c block_svc_routines.c glfs-operations.c
+libgbxdr_la_SOURCES = block_clnt.c block_xdr.c block_svc.c \
+ block_svc_routines.c glfs-operations.c
noinst_HEADERS = block.h glfs-operations.h
-libgbxdr_la_CFLAGS = -I$(top_srcdir)/utils/
+libgbxdr_la_CFLAGS = -DDATADIR=\"$(localstatedir)\" \
+ -I$(top_srcdir)/utils/
libgbxdr_la_LIBADD = $(GFAPI) $(UUID)
diff --git a/utils/Makefile.am b/utils/Makefile.am
index 461c73c..9a79c29 100644
--- a/utils/Makefile.am
+++ b/utils/Makefile.am
@@ -4,6 +4,8 @@ libgb_la_SOURCES = common.c utils.c
noinst_HEADERS = common.h utils.h
+libgb_la_CFLAGS = -DDATADIR=\"$(localstatedir)\"
+
libgb_ladir = $(includedir)/gluster-block/utils
DISTCLEANFILES = Makefile.in
diff --git a/utils/common.h b/utils/common.h
index 83fc580..90702b9 100644
--- a/utils/common.h
+++ b/utils/common.h
@@ -14,13 +14,16 @@
# include "utils.h"
-# define GB_UNIX_ADDRESS "/var/run/gluster-block.socket"
+# define GB_LOGDIR DATADIR "/log/gluster-block"
+# define GB_INFODIR DATADIR "/run"
+
+# define GB_UNIX_ADDRESS GB_INFODIR "/gluster-block.socket"
# define GB_TCP_PORT 24006
-# define DAEMON_LOG_FILE "/var/log/gluster-block/gluster-blockd.log"
-# define CLI_LOG_FILE "/var/log/gluster-block/gluster-block-cli.log"
+# define DAEMON_LOG_FILE GB_LOGDIR "/gluster-blockd.log"
+# define CLI_LOG_FILE GB_LOGDIR "/gluster-block-cli.log"
-# define GFAPI_LOG_FILE "/var/log/gluster-block/gluster-block-gfapi.log"
+# define GFAPI_LOG_FILE GB_LOGDIR "/gluster-block-gfapi.log"
# define GFAPI_LOG_LEVEL 7
# define GB_METADIR "/block-meta"