]> err.no Git - util-linux/commitdiff
mount: handle filesystems with subtype
authorMiklos Szeredi <miklos@szeredi.hu>
Fri, 27 Aug 2010 14:58:44 +0000 (16:58 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 27 Aug 2010 18:23:19 +0000 (20:23 +0200)
Linux can handle filesystem types with "MAINTYPE.SUBTYPE" format,
where the main type determines the actual filesystem driver while the
subtype can be interpreted by the filesystem itself.

When searching for mount helpers mount(8) and umount(8) should also
interpret such types, falling back to (u)mount.MAINTYPE if
(u)mount.MAINTYPE.SUBTYPE doesn't exist.

This patch implements this, passing the type with "-t TYPE"
to the mount program in this case.

Reported-by: Josef Bacik <josef@redhat.com>
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=625064
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
mount/mount.c
mount/umount.c

index f2b6ee23e2db94b246d7030a22e47c23625d0008..84986e36b48639ef2e78deecc4de91ff197b2a40 100644 (file)
@@ -664,13 +664,22 @@ check_special_mountprog(const char *spec, const char *node, const char *type, in
 
        path = strtok(search_path, ":");
        while (path) {
+               int type_opt = 0;
+
                res = snprintf(mountprog, sizeof(mountprog), "%s/mount.%s",
                               path, type);
                path = strtok(NULL, ":");
                if (res >= sizeof(mountprog) || res < 0)
                        continue;
 
-               if (stat(mountprog, &statbuf))
+               res = stat(mountprog, &statbuf);
+               if (res == -1 && errno == ENOENT && strchr(type, '.')) {
+                       /* If type ends with ".subtype" try without it */
+                       *strrchr(mountprog, '.') = '\0';
+                       type_opt = 1;
+                       res = stat(mountprog, &statbuf);
+               }
+               if (res)
                        continue;
 
                if (verbose)
@@ -678,7 +687,7 @@ check_special_mountprog(const char *spec, const char *node, const char *type, in
 
                switch (fork()) {
                case 0: { /* child */
-                       char *oo, *mountargs[10];
+                       char *oo, *mountargs[12];
                        int i = 0;
 
                        if (setgid(getgid()) < 0)
@@ -703,7 +712,11 @@ check_special_mountprog(const char *spec, const char *node, const char *type, in
                                mountargs[i++] = "-o";                  /* 8 */
                                mountargs[i++] = oo;                    /* 9 */
                        }
-                       mountargs[i] = NULL;                            /* 10 */
+                       if (type_opt) {
+                               mountargs[i++] = "-t";                  /* 10 */
+                               mountargs[i++] = (char *) type;         /* 11 */
+                       }
+                       mountargs[i] = NULL;                            /* 12 */
 
                        if (verbose > 2) {
                                i = 0;
index 5bd536047583cb6b2079f1cccc91a5ca0c865e9e..0ad7c5f98233b18787a178fd4023c41705e12051 100644 (file)
@@ -103,11 +103,20 @@ check_special_umountprog(const char *spec, const char *node,
                return 0;
 
        if (strlen(type) < 100) {
+               int type_opt = 0;
+
                sprintf(umountprog, "/sbin/umount.%s", type);
-               if (stat(umountprog, &statbuf) == 0) {
+               res = stat(umountprog, &statbuf);
+               if (res == -1 && errno == ENOENT && strchr(type, '.')) {
+                       /* If type ends with ".subtype" try without it */
+                       *strrchr(umountprog, '.') = '\0';
+                       type_opt = 1;
+                       res = stat(umountprog, &statbuf);
+               }
+               if (res == 0) {
                        res = fork();
                        if (res == 0) {
-                               char *umountargs[8];
+                               char *umountargs[10];
                                int i = 0;
 
                                if(setgid(getgid()) < 0)
@@ -128,6 +137,10 @@ check_special_umountprog(const char *spec, const char *node,
                                        umountargs[i++] = "-v";
                                if (remount)
                                        umountargs[i++] = "-r";
+                               if (type_opt) {
+                                       umountargs[i++] = "-t";
+                                       umountargs[i++] = (char *) type;
+                               }
                                umountargs[i] = NULL;
                                execv(umountprog, umountargs);
                                exit(1);        /* exec failed */