From 7ffb8cf3de665d0a6abc69ea3d26323b985dce65 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Mon, 5 Jan 2004 15:07:12 +0000 Subject: [PATCH] added -d option to fusermount --- ChangeLog | 4 ++++ util/fusermount.c | 36 +++++++++++++++++++++++++----------- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 455e599..8dfab5d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2004-01-05 Miklos Szeredi + + * Added -d option to fusermount + 2003-12-15 Miklos Szeredi * Added major+minor version to library API, and minor version to diff --git a/util/fusermount.c b/util/fusermount.c index 4b489bc..1a6db91 100644 --- a/util/fusermount.c +++ b/util/fusermount.c @@ -86,7 +86,7 @@ static void unlock_mtab(int mtablock) } } -static int add_mount(const char *dev, const char *mnt, const char *type) +static int add_mount(const char *fsname, const char *mnt, const char *type) { int res; const char *mtab = _PATH_MOUNTED; @@ -116,7 +116,7 @@ static int add_mount(const char *dev, const char *mnt, const char *type) if(opts == NULL) return -1; - ent.mnt_fsname = (char *) dev; + ent.mnt_fsname = (char *) fsname; ent.mnt_dir = (char *) mnt; ent.mnt_type = (char *) type; ent.mnt_opts = opts; @@ -363,7 +363,7 @@ static int check_perm(const char *mnt, struct stat *stbuf) return 0; } -static int mount_fuse(const char *mnt, int flags) +static int mount_fuse(const char *mnt, int flags, const char *fsname) { int res; int fd; @@ -396,12 +396,15 @@ static int mount_fuse(const char *mnt, int flags) return -1; } - res = do_mount(dev, mnt, type, stbuf.st_mode & S_IFMT, fd, flags); + if(fsname == NULL) + fsname = dev; + + res = do_mount(fsname, mnt, type, stbuf.st_mode & S_IFMT, fd, flags); if(res == -1) return -1; mtablock = lock_mtab(); - res = add_mount(dev, mnt, type); + res = add_mount(fsname, mnt, type); unlock_mtab(mtablock); if(res == -1) { umount(mnt); @@ -479,11 +482,12 @@ static void usage() fprintf(stderr, "%s: [options] mountpoint [program [args ...]]\n" "Options:\n" - " -h print help\n" - " -u unmount\n" - " -p check default permissions on files\n" - " -c cache in kernel space if possible\n" - " -x allow other users to access the files (only for root)\n", + " -h print help\n" + " -u unmount\n" + " -p check default permissions on files\n" + " -c cache in kernel space if possible\n" + " -x allow other users to access the files (only for root)\n" + " -d name add 'name' as the filesystem name to mtab\n", progname); exit(1); } @@ -501,6 +505,7 @@ int main(int argc, char *argv[]) char mypath[PATH_MAX]; char *unmount_cmd; char *commfd; + const char *fsname = NULL; char verstr[128]; int flags = 0; @@ -535,6 +540,15 @@ int main(int argc, char *argv[]) } flags |= FUSE_ALLOW_OTHER; break; + + case 'd': + a++; + if(a == argc) { + fprintf(stderr, "%s: Missing argument to -d\n", progname); + exit(1); + } + fsname = argv[a]; + break; default: fprintf(stderr, "%s: Unknown option %s\n", progname, argv[a]); @@ -579,7 +593,7 @@ int main(int argc, char *argv[]) userprog = argv + a; numargs = argc - a; - fd = mount_fuse(mnt, flags); + fd = mount_fuse(mnt, flags, fsname); if(fd == -1) exit(1); -- 2.30.2