]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: fix support of comma-separated fs types lists
authorGleb Fotengauer-Malinovskiy <glebfm@altlinux.org>
Thu, 27 Sep 2012 16:48:34 +0000 (20:48 +0400)
committerKarel Zak <kzak@redhat.com>
Fri, 16 Nov 2012 09:31:49 +0000 (10:31 +0100)
# grep cdrom /etc/fstab
/dev/sr0 /media/cdrom udf,iso9660 ro,noauto,user,utf8 0 0
# mount /media/cdrom
mount: unknown filesystem type 'udf,iso9660'

# mount -t udf,iso9660 /dev/sr0 /media/cdrom
mount: /dev/sr0 is write-protected, mounting read-only

[kzak@redhat.com: - add some comments
                  - don't try to found external helpers for the types]

Signed-off-by: Gleb Fotengauer-Malinovskiy <glebfm@altlinux.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/context.c
libmount/src/context_mount.c

index ad97dc8e7e61c6a64c7bd735bdc043bce6638a17..721c497ef67e90731ea219000ce958aa4fb3be1d 100644 (file)
@@ -714,15 +714,14 @@ const char *mnt_context_get_target(struct libmnt_context *cxt)
  * @cxt: mount context
  * @fstype: filesystem type
  *
- * Note that the @fstype has to be the real FS type. For comma-separated list of
- * filesystems or for "nofs" notation use mnt_context_set_fstype_pattern().
+ * Note that the @fstype has to be the real FS type. For patterns with
+ * comma-separated list of filesystems or for "nofs" notation use
+ * mnt_context_set_fstype_pattern().
  *
  * Returns: 0 on success, negative number in case of error.
  */
 int mnt_context_set_fstype(struct libmnt_context *cxt, const char *fstype)
 {
-       if (fstype && strchr(fstype, ','))
-               return -EINVAL;
        return mnt_fs_set_fstype(mnt_context_get_fs(cxt), fstype);
 }
 
@@ -1482,6 +1481,9 @@ int mnt_context_prepare_helper(struct libmnt_context *cxt, const char *name,
        if (!type)
                type = mnt_fs_get_fstype(cxt->fs);
 
+       if (type && strchr(type, ','))
+               return 0;                       /* type is fstype pattern */
+
        if (mnt_context_is_nohelpers(cxt)
            || !type
            || !strcmp(type, "none")
index 6dc8e6486cb778f40359c3348a4ab06f3b379389..1e21db7c670303be2e1cb7fe88d956a7adcf847a 100644 (file)
@@ -690,9 +690,13 @@ int mnt_context_do_mount(struct libmnt_context *cxt)
                cxt->mountdata = (char *) mnt_fs_get_fs_options(cxt->fs);
 
        type = mnt_fs_get_fstype(cxt->fs);
-       if (type)
-               res = do_mount(cxt, NULL);
-       else
+       if (type) {
+               if (strchr(type, ','))
+                       /* this only happen if fstab countains list of filesystems */
+                       res = do_mount_by_pattern(cxt, type);
+               else
+                       res = do_mount(cxt, NULL);
+       } else
                res = do_mount_by_pattern(cxt, cxt->fstype_pattern);
 
        if (mnt_context_get_status(cxt)