From: Karel Zak Date: Thu, 12 Aug 2021 11:39:39 +0000 (+0200) Subject: libmount: allow X-* options more than once X-Git-Tag: v2.38-rc1~303 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d85f45d5ddb020b9858356b4c2c91d962ac7e6d7;p=thirdparty%2Futil-linux.git libmount: allow X-* options more than once Signed-off-by: Karel Zak --- diff --git a/libmount/src/optstr.c b/libmount/src/optstr.c index 21707d1ed3..e2a0734daf 100644 --- a/libmount/src/optstr.c +++ b/libmount/src/optstr.c @@ -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) {