From edf2663cdff947d9615cee50833e3e215bc62a6f Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Tue, 27 Jan 2004 14:54:47 +0000 Subject: [PATCH] cleanup --- ChangeLog | 8 ++++++++ lib/mount.c | 2 +- util/fusermount.c | 19 +++++++++++++------ 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5f2c89d..969342b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-01-27 Miklos Szeredi + + * Added -q option for fusermount + + * fuse_unmount() now uses -q option of fusermount, so no error is + printed if the cause of the program exit is that the filesystem + has already been unmounted + 2004-01-26 Miklos Szeredi * Released 1.1-pre2 diff --git a/lib/mount.c b/lib/mount.c index 1224afa..7b67203 100644 --- a/lib/mount.c +++ b/lib/mount.c @@ -71,7 +71,7 @@ void fuse_unmount(const char *mountpoint) const char *mountprog = FUSERMOUNT_PROG; char umount_cmd[1024]; - snprintf(umount_cmd, sizeof(umount_cmd) - 1, "%s -u %s", mountprog, + snprintf(umount_cmd, sizeof(umount_cmd) - 1, "%s -u -q %s", mountprog, mountpoint); umount_cmd[sizeof(umount_cmd) - 1] = '\0'; diff --git a/util/fusermount.c b/util/fusermount.c index 1d8afd2..d4fcebb 100644 --- a/util/fusermount.c +++ b/util/fusermount.c @@ -133,11 +133,11 @@ static int add_mount(const char *fsname, const char *mnt, const char *type) return 0; } -static int remove_mount(const char *mnt) +static int remove_mount(const char *mnt, int quiet) { int res; const char *mtab = _PATH_MOUNTED; - const char *mtab_new = _PATH_MOUNTED "~"; + const char *mtab_new = _PATH_MOUNTED "~fuse~"; struct mntent *entp; FILE *fp; FILE *newfp; @@ -210,7 +210,7 @@ static int remove_mount(const char *mnt) } } else { - if(!found) + if(!found && !quiet) fprintf(stderr, "%s: entry for %s not found in %s\n", progname, mnt, mtab); unlink(mtab_new); @@ -488,7 +488,8 @@ static void usage() " -c cache in kernel space if possible\n" " -x allow other users to access the files (only for root)\n" " -n name add 'name' as the filesystem name to mtab\n" - " -l issue large reads\n", + " -l issue large reads\n" + " -q quiet: don't complain if unmount fails\n", progname); exit(1); } @@ -509,6 +510,7 @@ int main(int argc, char *argv[]) const char *fsname = NULL; char verstr[128]; int flags = 0; + int quiet = 0; progname = argv[0]; @@ -554,9 +556,14 @@ int main(int argc, char *argv[]) case 'l': flags |= FUSE_LARGE_READ; break; + + case 'q': + quiet = 1; + break; default: fprintf(stderr, "%s: Unknown option %s\n", progname, argv[a]); + fprintf(stderr, "Try `%s -h' for more information\n", progname); exit(1); } } @@ -580,7 +587,7 @@ int main(int argc, char *argv[]) if(unmount) { int mtablock = lock_mtab(); - res = remove_mount(mnt); + res = remove_mount(mnt, quiet); unlock_mtab(mtablock); if(res == -1) exit(1); @@ -632,7 +639,7 @@ int main(int argc, char *argv[]) setgid(getgid()); unmount_cmd = (char *) malloc(strlen(mypath) + strlen(mnt) + 64); - sprintf(unmount_cmd, "%s -u %s", mypath, mnt); + sprintf(unmount_cmd, "%s -u -q %s", mypath, mnt); setenv(FUSE_UMOUNT_CMD_ENV, unmount_cmd, 1); sprintf(verstr, "%i", FUSE_KERNEL_VERSION); setenv(FUSE_KERNEL_VERSION_ENV, verstr, 1); -- 2.30.2