added -d option to fusermount
authorMiklos Szeredi <miklos@szeredi.hu>
Mon, 5 Jan 2004 15:07:12 +0000 (15:07 +0000)
committerMiklos Szeredi <miklos@szeredi.hu>
Mon, 5 Jan 2004 15:07:12 +0000 (15:07 +0000)
ChangeLog
util/fusermount.c

index 455e59906c1e8cd473c122dec1b954cd4558b423..8dfab5d054e982206d42cda2cd65a6527fdd727b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2004-01-05  Miklos Szeredi <mszeredi@inf.bme.hu>
+
+       * Added -d option to fusermount 
+
 2003-12-15  Miklos Szeredi <mszeredi@inf.bme.hu>
 
        * Added major+minor version to library API, and minor version to
index 4b489bc294971b232f1c5ae29b9524a95f15fd57..1a6db91a5621799c0b596d4af7f08c276165cd85 100644 (file)
@@ -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);