Add fs subtype support to mount.fuse
authorMiklos Szeredi <miklos@szeredi.hu>
Thu, 21 Jun 2007 13:48:07 +0000 (13:48 +0000)
committerMiklos Szeredi <miklos@szeredi.hu>
Thu, 21 Jun 2007 13:48:07 +0000 (13:48 +0000)
ChangeLog
util/mount.fuse.c

index 9b397dbd6e519853d0b81c3cabd281bea0aa2f79..e50aac32d7e8214958ce6e22e36112c5a7bd90d2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2007-06-21  Miklos Szeredi <miklos@szeredi.hu>
+
+       * Add fs subtype support to mount.fuse
+
 2007-06-20  Miklos Szeredi <miklos@szeredi.hu>
 
        * Add fs subtype support to libfuse and fusermount
index d15600965073ca8b69c2a4f5b09836a816fd6815..4cc03940cba91d40eb3829b8ab1f17689b6893c4 100644 (file)
@@ -6,7 +6,6 @@
 
 static char *progname;
 
-
 static char *xstrdup(const char *s)
 {
     char *t = strdup(s);
@@ -54,37 +53,66 @@ static void add_arg(char **cmdp, const char *opt)
 
 int main(int argc, char *argv[])
 {
-    char *type;
+    char *type = NULL;
     char *source;
     const char *mountpoint;
+    char *basename;
     char *options = NULL;
     char *command = NULL;
     char *setuid = NULL;
     int i;
 
     progname = argv[0];
+    basename = strrchr(argv[0], '/');
+    if (basename)
+        basename++;
+    else
+        basename = argv[0];
+
+    if (strncmp(basename, "mount.fuse.", 11) == 0)
+        type = basename + 11;
+    if (strncmp(basename, "mount.fuseblk.", 14) == 0)
+        type = basename + 14;
+
+    if (type && !type[0])
+        type = NULL;
+
     if (argc < 3) {
-        fprintf(stderr,
-                "usage: %s type#[source] mountpoint [-o opt[,opts...]]\n",
-                progname);
+        fprintf(stderr, "usage: %s %s destination [-t type] [-o opt[,opts...]]\n",
+                progname, type ? "source" : "type#[source]");
         exit(1);
     }
 
-    type = xstrdup(argv[1]);
-    source = strchr(type, '#');
-    if (source)
-        *source++ = '\0';
+    source = argv[1];
+    if (!source[0])
+        source = NULL;
 
-    if (!type[0]) {
-        fprintf(stderr, "%s: empty filesystem type\n", progname);
-        exit(1);
-    }
     mountpoint = argv[2];
 
     for (i = 3; i < argc; i++) {
-        if (strcmp(argv[i], "-v") == 0)
+        if (strcmp(argv[i], "-v") == 0) {
             continue;
-        if (strcmp(argv[i], "-o") == 0) {
+        } else if (strcmp(argv[i], "-t") == 0) {
+            i++;
+
+            if (i == argc) {
+                fprintf(stderr,
+                        "%s: missing argument to option '-t'\n", progname);
+                exit(1);
+            }
+            type = argv[i];
+            if (strncmp(type, "fuse.", 5) == 0)
+                type += 5;
+            else if (strncmp(type, "fuseblk.", 8) == 0)
+                type += 8;
+
+            if (!type[0]) {
+                fprintf(stderr,
+                        "%s: empty type given as argument to option '-t'\n",
+                        progname);
+                exit(1);
+            }
+        } else  if (strcmp(argv[i], "-o") == 0) {
             char *opts;
             char *opt;
             i++;
@@ -122,6 +150,18 @@ int main(int argc, char *argv[])
         }
     }
 
+    if (!type) {
+        type = xstrdup(source);
+        source = strchr(type, '#');
+        if (source)
+            *source++ = '\0';
+
+        if (!type[0]) {
+            fprintf(stderr, "%s: empty filesystem type\n", progname);
+            exit(1);
+        }
+    }
+
     add_arg(&command, type);
     if (source)
         add_arg(&command, source);