]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: allow X-* options more than once
authorKarel Zak <kzak@redhat.com>
Thu, 12 Aug 2021 11:39:39 +0000 (13:39 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 12 Aug 2021 11:39:39 +0000 (13:39 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/optstr.c

index 21707d1ed30ef00f4a8dc637fe2a7db4ba4fd105..e2a0734daf3d99541b148192978f7670bdf692b2 100644 (file)
@@ -724,7 +724,7 @@ int mnt_optstr_apply_flags(char **optstr, unsigned long flags,
 {
        struct libmnt_optmap const *maps[1];
        char *name, *next, *val;
-       size_t namesz = 0, valsz = 0;
+       size_t namesz = 0, valsz = 0, multi = 0;
        unsigned long fl;
        int rc = 0;
 
@@ -794,7 +794,11 @@ int mnt_optstr_apply_flags(char **optstr, unsigned long flags,
                                                goto err;
                                }
                                if (!(ent->mask & MNT_INVERT)) {
-                                       fl &= ~ent->id;
+                                       /* allow options with prefix (X-mount.foo,X-mount.bar) more than once */
+                                       if (ent->mask & MNT_PREFIX)
+                                               multi |= ent->id;
+                                       else
+                                               fl &= ~ent->id;
                                        if (ent->id & MS_REC)
                                                fl |= MS_REC;
                                }
@@ -802,6 +806,9 @@ int mnt_optstr_apply_flags(char **optstr, unsigned long flags,
                }
        }
 
+       /* remove from flags options which are alowed more than once */
+       fl &= ~multi;
+
        /* add missing options (but ignore fl if contains MS_REC only) */
        if (fl && fl != MS_REC) {