diff options
author | Csaba Henk <csaba.henk@creo.hu> | 2006-04-22 22:46:52 +0000 |
---|---|---|
committer | Csaba Henk <csaba.henk@creo.hu> | 2006-04-22 22:46:52 +0000 |
commit | 2efe48fc775fbc66e63694e365078f22092251a8 (patch) | |
tree | c6d68e89d74e8c5bf01e59214cfd6060bb57b1bb /lib/mount_bsd.c | |
parent | 5fe07d61983e16d6311d9c1a19d0a3b0a8a25266 (diff) |
run mount util foregrounded on FreeBSD if kernel features backgrounded init
Diffstat (limited to 'lib/mount_bsd.c')
-rw-r--r-- | lib/mount_bsd.c | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/lib/mount_bsd.c b/lib/mount_bsd.c index aefc69f..ea4140a 100644 --- a/lib/mount_bsd.c +++ b/lib/mount_bsd.c @@ -11,6 +11,7 @@ #include <sys/stat.h> #include <sys/wait.h> +#include <sys/sysctl.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -225,6 +226,20 @@ void fuse_kern_unmount(const char *mountpoint, int fd) system(umount_cmd); } +/* Check if kernel is doing init in background */ +static int init_backgrounded(void) +{ + int ibg, len; + + len = sizeof(ibg); + + if (sysctlbyname("vfs.fuse.init_backgrounded", &ibg, &len, NULL, 0)) + return 0; + + return ibg; +} + + static int fuse_mount_core(const char *mountpoint, const char *opts) { const char *mountprog = FUSERMOUNT_PROG; @@ -273,12 +288,19 @@ mount: } if (pid == 0) { - pid = fork(); - - if (pid == -1) { - perror("fuse: fork() failed"); - close(fd); - exit(1); + if (! init_backgrounded()) { + /* + * If init is not backgrounded, we have to call the mount util + * backgrounded, to avoid deadlock. + */ + + pid = fork(); + + if (pid == -1) { + perror("fuse: fork() failed"); + close(fd); + exit(1); + } } if (pid == 0) { |