diff options
author | Miklos Szeredi <miklos@szeredi.hu> | 2007-07-25 09:36:52 +0000 |
---|---|---|
committer | Miklos Szeredi <miklos@szeredi.hu> | 2007-07-25 09:36:52 +0000 |
commit | 7f571e320e39a5dd0bb7ab2c1b2a40b174879b18 (patch) | |
tree | 60add554a3444a0f1be63d4ec2b0d2e1dcfe15b9 /lib/mount_util.c | |
parent | 5e1769c04dabef220cc5bf56825ce848ae4da226 (diff) |
Don't call /bin/[u]mount if /etc/mtab is a symlink
Diffstat (limited to 'lib/mount_util.c')
-rw-r--r-- | lib/mount_util.c | 17 |
1 files changed, 17 insertions, 0 deletions
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 <dirent.h> #include <errno.h> #include <limits.h> +#include <mntent.h> #include <sys/stat.h> #include <sys/wait.h> +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)); |