[sheepdog] [PATCH] sheep: allow working direcotry to be specified as storage directory

Liu Yuan namei.unix at gmail.com
Tue Dec 4 03:53:47 CET 2012


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

Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
 sheep/sheep.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/sheep/sheep.c b/sheep/sheep.c
index c201d88..ab0b43f 100644
--- a/sheep/sheep.c
+++ b/sheep/sheep.c
@@ -334,7 +334,8 @@ int main(int argc, char **argv)
 {
 	int ch, longindex;
 	int ret, port = SD_LISTEN_PORT;
-	const char *dir = DEFAULT_OBJECT_DIR;
+	const char *dirp = DEFAULT_OBJECT_DIR;
+	char *dir;
 	bool is_daemon = true;
 	bool to_stdout = false;
 	int log_level = SDOG_INFO;
@@ -486,8 +487,9 @@ int main(int argc, char **argv)
 	}
 
 	if (optind != argc)
-		dir = argv[optind];
+		dirp = argv[optind];
 
+	dir = realpath(dirp, NULL);
 	snprintf(path, sizeof(path), "%s/" LOG_FILE_NAME, dir);
 
 	srandom(port);
@@ -576,6 +578,7 @@ int main(int argc, char **argv)
 		exit(1);
 	}
 
+	free(dir);
 	vprintf(SDOG_NOTICE, "sheepdog daemon (version %s) started\n", PACKAGE_VERSION);
 
 	while (sys->nr_outstanding_reqs != 0 ||
-- 
1.7.9.5




More information about the sheepdog mailing list