]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: fix fs pattern usage in mount --all
authorKarel Zak <kzak@redhat.com>
Tue, 6 Mar 2018 13:44:23 +0000 (14:44 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 6 Mar 2018 13:44:23 +0000 (14:44 +0100)
The command "mount -a -t <pattern>" uses the -t as pattern to filter
fstab entries. And "mount -t <type>" is used to specify FS type.

Unfortunately libmount does not care about this difference when it
calls standard mount functionality. The original pattern is still in
the library control struct and mnt_do_mount() tries to use it as FS
type.

This patch is just bugfix. Maybe the long term solution would be to
differentiate between the pattern and type in the library API. Now the
library follows mount(8) command line and it's little bit messy.

Reported-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/context_mount.c

index 139fb5a287fb257f83c5160984fa0e222ce7d649..fc07ca1844a5d7825e2c12118c9d805f9575e0f2 100644 (file)
@@ -1175,6 +1175,7 @@ int mnt_context_next_mount(struct libmnt_context *cxt,
 {
        struct libmnt_table *fstab, *mtab;
        const char *o, *tgt;
+       char *pattern;
        int rc, mounted = 0;
 
        if (ignored)
@@ -1254,7 +1255,18 @@ int mnt_context_next_mount(struct libmnt_context *cxt,
 
        rc = mnt_context_set_fs(cxt, *fs);
        if (!rc) {
+               /*
+                * "-t <pattern>" is used to filter out fstab entries, but for ordinary
+                * mount operation -t means "-t <type>". We have to zeroize the pattern
+                * to avoid misinterpretation.
+                */
+               pattern = cxt->fstype_pattern;
+               cxt->fstype_pattern = NULL;
+
                rc = mnt_context_mount(cxt);
+
+               cxt->fstype_pattern = pattern;
+
                if (mntrc)
                        *mntrc = rc;
        }