diff options
Diffstat (limited to 'lib/fuse_lowlevel.c')
-rw-r--r-- | lib/fuse_lowlevel.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c index e6e3d8d..844e797 100644 --- a/lib/fuse_lowlevel.c +++ b/lib/fuse_lowlevel.c @@ -16,6 +16,7 @@ #include "fuse_kernel.h" #include "fuse_opt.h" #include "fuse_misc.h" +#include "mount_util.h" #include <stdio.h> #include <stdlib.h> @@ -2891,6 +2892,24 @@ int fuse_session_mount(struct fuse_session *se, const char *mountpoint) close(fd); } while (fd >= 0 && fd <= 2); + /* + * To allow FUSE daemons to run without privileges, the caller may open + * /dev/fuse before launching the file system and pass on the file + * descriptor by specifying /dev/fd/N as the mount point. Note that the + * parent process takes care of performing the mount in this case. + */ + fd = fuse_mnt_parse_fuse_fd(mountpoint); + if (fd != -1) { + if (fcntl(fd, F_GETFD) == -1) { + fprintf(stderr, + "fuse: Invalid file descriptor /dev/fd/%u\n", + fd); + return -1; + } + se->fd = fd; + return 0; + } + /* Open channel */ fd = fuse_kern_mount(mountpoint, se->mo); if (fd == -1) @@ -2916,9 +2935,11 @@ int fuse_session_fd(struct fuse_session *se) void fuse_session_unmount(struct fuse_session *se) { - fuse_kern_unmount(se->mountpoint, se->fd); - free(se->mountpoint); - se->mountpoint = NULL; + if (se->mountpoint != NULL) { + fuse_kern_unmount(se->mountpoint, se->fd); + free(se->mountpoint); + se->mountpoint = NULL; + } } #ifdef linux |