From e34c133ec6053025124416a3861f9f4c4f7fd772 Mon Sep 17 00:00:00 2001 From: Dees_Troy Date: Wed, 6 Feb 2013 19:13:00 +0000 Subject: Add write buffer for tar writes update fuse to 2.9.2 catch return from unlink so that we don't print error messages when things work Change-Id: I1115039a0fa5d9d73f78ef1abd79755d7ffd9d96 --- fuse/helper.c | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) (limited to 'fuse/helper.c') diff --git a/fuse/helper.c b/fuse/helper.c index 7b994fd3b..ace19dd70 100644 --- a/fuse/helper.c +++ b/fuse/helper.c @@ -179,14 +179,38 @@ err: int fuse_daemonize(int foreground) { - int res; - if (!foreground) { - res = daemon(0, 0); - if (res == -1) { - perror("fuse: failed to daemonize program\n"); + int nullfd; + + /* + * demonize current process by forking it and killing the + * parent. This makes current process as a child of 'init'. + */ + switch(fork()) { + case -1: + perror("fuse_daemonize: fork"); + return -1; + case 0: + break; + default: + _exit(0); + } + + if (setsid() == -1) { + perror("fuse_daemonize: setsid"); return -1; } + + (void) chdir("/"); + + nullfd = open("/dev/null", O_RDWR, 0); + if (nullfd != -1) { + (void) dup2(nullfd, 0); + (void) dup2(nullfd, 1); + (void) dup2(nullfd, 2); + if (nullfd > 2) + close(nullfd); + } } return 0; } @@ -227,7 +251,8 @@ static void fuse_unmount_common(const char *mountpoint, struct fuse_chan *ch) { int fd = ch ? fuse_chan_fd(ch) : -1; fuse_kern_unmount(mountpoint, fd); - fuse_chan_destroy(ch); + if (ch) + fuse_chan_destroy(ch); } void fuse_unmount(const char *mountpoint, struct fuse_chan *ch) @@ -324,11 +349,9 @@ static int fuse_main_common(int argc, char *argv[], if (fuse == NULL) return 1; -#ifdef __MULTI_THREAD if (multithreaded) res = fuse_loop_mt(fuse); else -#endif res = fuse_loop(fuse); fuse_teardown_common(fuse, mountpoint); @@ -359,7 +382,7 @@ int fuse_version(void) #include "fuse_compat.h" -#ifndef __FreeBSD__ +#if !defined(__FreeBSD__) && !defined(__NetBSD__) struct fuse *fuse_setup_compat22(int argc, char *argv[], const struct fuse_operations_compat22 *op, @@ -417,7 +440,7 @@ FUSE_SYMVER(".symver fuse_teardown,__fuse_teardown@"); FUSE_SYMVER(".symver fuse_main_compat2,fuse_main@"); FUSE_SYMVER(".symver fuse_main_real_compat22,fuse_main_real@FUSE_2.2"); -#endif /* __FreeBSD__ */ +#endif /* __FreeBSD__ || __NetBSD__ */ struct fuse *fuse_setup_compat25(int argc, char *argv[], -- cgit v1.2.3