From 7f571e320e39a5dd0bb7ab2c1b2a40b174879b18 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Wed, 25 Jul 2007 09:36:52 +0000 Subject: Don't call /bin/[u]mount if /etc/mtab is a symlink --- lib/mount_util.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'lib/mount_util.c') diff --git a/lib/mount_util.c b/lib/mount_util.c index dccecdf..55b5f4e 100644 --- a/lib/mount_util.c +++ b/lib/mount_util.c @@ -14,15 +14,29 @@ #include #include #include +#include #include #include +static int mtab_is_symlink(void) +{ + struct stat stbuf; + + if (lstat(_PATH_MOUNTED, &stbuf) != -1 && S_ISLNK(stbuf.st_mode)) + return 1; + else + return 0; +} + int fuse_mnt_add_mount(const char *progname, const char *fsname, const char *mnt, const char *type, const char *opts) { int res; int status; + if (mtab_is_symlink()) + return 0; + res = fork(); if (res == -1) { fprintf(stderr, "%s: fork: %s\n", progname, strerror(errno)); @@ -72,6 +86,9 @@ int fuse_mnt_umount(const char *progname, const char *mnt, int lazy) int res; int status; + if (mtab_is_symlink()) + return 0; + res = fork(); if (res == -1) { fprintf(stderr, "%s: fork: %s\n", progname, strerror(errno)); -- cgit v1.2.3