From 7f571e320e39a5dd0bb7ab2c1b2a40b174879b18 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Wed, 25 Jul 2007 09:36:52 +0000 Subject: [PATCH] Don't call /bin/[u]mount if /etc/mtab is a symlink --- ChangeLog | 5 +++++ lib/fuse_opt.c | 12 +++++++----- lib/mount_util.c | 17 +++++++++++++++++ 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0d46ef9..2bf2251 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-07-25 Miklos Szeredi + + * Don't call /bin/[u]mount if /etc/mtab is a symlink. Reported by + Tomas M + 2007-07-12 Miklos Szeredi * Reset args->argc in fuse_opt_free_args(). Patch by Lucas diff --git a/lib/fuse_opt.c b/lib/fuse_opt.c index 31cffaf..9b464a1 100644 --- a/lib/fuse_opt.c +++ b/lib/fuse_opt.c @@ -27,11 +27,13 @@ struct fuse_opt_context { void fuse_opt_free_args(struct fuse_args *args) { - if (args && args->argv && args->allocated) { - int i; - for (i = 0; i < args->argc; i++) - free(args->argv[i]); - free(args->argv); + if (args) { + if (args->argv && args->allocated) { + int i; + for (i = 0; i < args->argc; i++) + free(args->argv[i]); + free(args->argv); + } args->argc = 0; args->argv = NULL; args->allocated = 0; 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)); -- 2.30.2