From 2efe48fc775fbc66e63694e365078f22092251a8 Mon Sep 17 00:00:00 2001 From: Csaba Henk Date: Sat, 22 Apr 2006 22:46:52 +0000 Subject: [PATCH] run mount util foregrounded on FreeBSD if kernel features backgrounded init --- ChangeLog | 6 ++++++ lib/mount_bsd.c | 34 ++++++++++++++++++++++++++++------ 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 32df258..7007037 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-04-23 Csaba Henk + + * lib: make FreeBSD mount routine recognize if kernel features + backgrounded init and if it does, run the mount util in foreground + (similarly to Linux) + 2006-04-21 Miklos Szeredi * kernel: fix fput deadlock fix, the lockless solution could lead 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 #include +#include #include #include #include @@ -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) { -- 2.30.2