aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMiklos Szeredi <miklos@szeredi.hu>2007-04-27 18:08:15 +0000
committerMiklos Szeredi <miklos@szeredi.hu>2007-04-27 18:08:15 +0000
commitccd1fa686cc1fc2faf067c8ceb10b90950175cc9 (patch)
treefee61fb474e225010e173e514015b0299bf093e3 /lib
parentccf0be03c3f6ec094b18c53c0606dafadb1e5423 (diff)
downloadlibfuse-ccd1fa686cc1fc2faf067c8ceb10b90950175cc9.tar.gz
libfuse: call umount(8) directly...
Diffstat (limited to 'lib')
-rw-r--r--lib/mount.c5
-rw-r--r--lib/mount_util.c29
-rw-r--r--lib/mount_util.h1
3 files changed, 35 insertions, 0 deletions
diff --git a/lib/mount.c b/lib/mount.c
index 0587bac..24bcf8c 100644
--- a/lib/mount.c
+++ b/lib/mount.c
@@ -276,6 +276,11 @@ void fuse_kern_unmount(const char *mountpoint, int fd)
return;
}
+ if (geteuid() == 0) {
+ fuse_mnt_umount("fuse", mountpoint, 1);
+ return;
+ }
+
res = umount2(mountpoint, 2);
if (res == 0)
return;
diff --git a/lib/mount_util.c b/lib/mount_util.c
index 8aafa33..b82ab3b 100644
--- a/lib/mount_util.c
+++ b/lib/mount_util.c
@@ -72,6 +72,35 @@ int fuse_mnt_add_mount(const char *progname, const char *fsname,
return 0;
}
+int fuse_mnt_umount(const char *progname, const char *mnt, int lazy)
+{
+ int res;
+ int status;
+
+ res = fork();
+ if (res == -1) {
+ fprintf(stderr, "%s: fork: %s\n", progname, strerror(errno));
+ return -1;
+ }
+ if (res == 0) {
+ setuid(geteuid());
+ execl("/bin/umount", "/bin/umount", "-i", mnt, lazy ? "-l" : NULL,
+ NULL);
+ fprintf(stderr, "%s: failed to execute /bin/umount: %s\n", progname,
+ strerror(errno));
+ exit(1);
+ }
+ res = waitpid(res, &status, 0);
+ if (res == -1) {
+ fprintf(stderr, "%s: waitpid: %s\n", progname, strerror(errno));
+ return -1;
+ }
+ if (status != 0)
+ return -1;
+
+ return 0;
+}
+
char *fuse_mnt_resolve_path(const char *progname, const char *orig)
{
char buf[PATH_MAX];
diff --git a/lib/mount_util.h b/lib/mount_util.h
index c64423b..106a6f8 100644
--- a/lib/mount_util.h
+++ b/lib/mount_util.h
@@ -10,6 +10,7 @@
int fuse_mnt_add_mount(const char *progname, const char *fsname,
const char *mnt, const char *type, const char *opts);
+int fuse_mnt_umount(const char *progname, const char *mnt, int lazy);
char *fuse_mnt_resolve_path(const char *progname, const char *orig);
int fuse_mnt_check_empty(const char *progname, const char *mnt,
mode_t rootmode, off_t rootsize);