+2006-04-23 Csaba Henk <csaba.henk@creo.hu>
+
+ * 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 <miklos@szeredi.hu>
* kernel: fix fput deadlock fix, the lockless solution could lead
#include <sys/stat.h>
#include <sys/wait.h>
+#include <sys/sysctl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
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;
}
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) {