aboutsummaryrefslogtreecommitdiffstats
path: root/lib/mount_util.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mount_util.c')
-rw-r--r--lib/mount_util.c29
1 files changed, 29 insertions, 0 deletions
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];