From d85f45d5ddb020b9858356b4c2c91d962ac7e6d7 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 12 Aug 2021 13:39:39 +0200 Subject: [PATCH] libmount: allow X-* options more than once Signed-off-by: Karel Zak --- libmount/src/optstr.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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) { -- 2.47.3