[Sheepdog] [PATCH 1/4] logger: move init_base_path() ahead of init_log()

Liu Yuan namei.unix at gmail.com
Sat Sep 24 06:14:52 CEST 2011


From: Liu Yuan <tailai.ly at taobao.com>

We need set up base dirs for the first place, otherwise sheep daemon will
exit when there are no directories created beforhand.

Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
 sheep/sheep.c      |    4 ++++
 sheep/sheep_priv.h |    1 +
 sheep/store.c      |    6 +-----
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/sheep/sheep.c b/sheep/sheep.c
index 967a4bd..50cd841 100644
--- a/sheep/sheep.c
+++ b/sheep/sheep.c
@@ -131,6 +131,10 @@ int main(int argc, char **argv)
 	if (is_daemon && daemon(0, 0))
 		exit(1);
 
+	ret = init_base_path(dir);
+	if (ret)
+		exit(1);
+
 	ret = log_init(program_name, LOG_SPACE_SIZE, is_daemon, log_level, path);
 	if (ret)
 		exit(1);
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index 1068e03..6680f79 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -161,6 +161,7 @@ int create_listen_port(int port, void *data);
 
 int is_io_request(unsigned op);
 int init_store(const char *dir);
+int init_base_path(const char *dir);
 
 int add_vdi(uint32_t epoch, char *data, int data_len, uint64_t size,
 	    uint32_t *new_vid, uint32_t base_vid, uint32_t copies,
diff --git a/sheep/store.c b/sheep/store.c
index 91f17c6..12e54d9 100644
--- a/sheep/store.c
+++ b/sheep/store.c
@@ -1910,7 +1910,7 @@ static int attr(char *path, const char *name, void *var, int len, int set)
 	return SD_RES_SUCCESS;
 }
 
-static int init_base_path(const char *d)
+int init_base_path(const char *d)
 {
 	int new = 0;
 
@@ -2039,10 +2039,6 @@ int init_store(const char *d)
 {
 	int ret;
 
-	ret = init_base_path(d);
-	if (ret)
-		return ret;
-
 	ret = init_obj_path(d);
 	if (ret)
 		return ret;
-- 
1.7.6.1




More information about the sheepdog mailing list