Patchwork [03/11] fedfsd: Change the working directory to the default state dir

login
register
mail settings
Submitter Chuck Lever
Date Oct. 19, 2012, 9:08 p.m.
Message ID <20121019210802.53119.90861.stgit@seurat.1015granger.net>
Download mbox | patch
Permalink /patch/192808/
State Accepted
Headers show

Comments

Chuck Lever - Oct. 19, 2012, 9:08 p.m.
Follow conventional practice of other RPC service daemons.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---

 src/fedfsd/main.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

Patch

diff --git a/src/fedfsd/main.c b/src/fedfsd/main.c
index f0a39d6..fd6bee5 100644
--- a/src/fedfsd/main.c
+++ b/src/fedfsd/main.c
@@ -219,6 +219,10 @@  int main(int argc, char **argv)
 		exit(EXIT_FAILURE);
 
 	if (!foreground) {
+		if (chdir(FEDFS_DEFAULT_STATEDIR) == -1) {
+			xlog(L_ERROR, "chdir: %m");
+			exit(EXIT_FAILURE);
+		}
 		if (daemon(0, 0) == -1) {
 			xlog(L_ERROR, "daemon: %m");
 			exit(EXIT_FAILURE);