Path: blob/main/filesystems/fusefs-libs/files/patch-lib_mount__bsd.c
18878 views
--- lib/mount_bsd.c.orig 2015-05-22 09:24:02 UTC1+++ lib/mount_bsd.c2@@ -10,6 +10,8 @@3#include "fuse_misc.h"4#include "fuse_opt.h"56+#include <sys/param.h>7+#include <sys/mount.h>8#include <sys/stat.h>9#include <sys/wait.h>10#include <sys/sysctl.h>11@@ -78,6 +80,7 @@ static const struct fuse_opt fuse_mount_12FUSE_DUAL_OPT_KEY("ro", KEY_KERN),13FUSE_DUAL_OPT_KEY("rw", KEY_KERN),14FUSE_DUAL_OPT_KEY("auto", KEY_KERN),15+ FUSE_DUAL_OPT_KEY("automounted", KEY_KERN),16/* options supported under both Linux and FBSD */17FUSE_DUAL_OPT_KEY("allow_other", KEY_KERN),18FUSE_DUAL_OPT_KEY("default_permissions",KEY_KERN),19@@ -192,56 +195,12 @@ void fuse_unmount_compat22(const char *m20free(umount_cmd);21}2223-static void do_unmount(char *dev, int fd)24-{25- char device_path[SPECNAMELEN + 12];26- const char *argv[4];27- const char umount_cmd[] = "/sbin/umount";28- pid_t pid;29-30- snprintf(device_path, SPECNAMELEN + 12, _PATH_DEV "%s", dev);31-32- argv[0] = umount_cmd;33- argv[1] = "-f";34- argv[2] = device_path;35- argv[3] = NULL;36-37- pid = fork();38-39- if (pid == -1)40- return;41-42- if (pid == 0) {43- close(fd);44- execvp(umount_cmd, (char **)argv);45- exit(1);46- }47-48- waitpid(pid, NULL, 0);49-}50-51void fuse_kern_unmount(const char *mountpoint, int fd)52{53char *ep, dev[128];54struct stat sbuf;5556- (void)mountpoint;57-58- if (fstat(fd, &sbuf) == -1)59- goto out;60-61- devname_r(sbuf.st_rdev, S_IFCHR, dev, 128);62-63- if (strncmp(dev, "fuse", 4))64- goto out;65-66- strtol(dev + 4, &ep, 10);67- if (*ep != '\0')68- goto out;69-70- do_unmount(dev, fd);71-72-out:73+ unmount(mountpoint, MNT_FORCE);74close(fd);75}76777879