From: Karel Zak Date: Thu, 18 Aug 2022 10:38:44 +0000 (+0200) Subject: libmount: (optlist) filter by optmap masks X-Git-Tag: v2.39-rc1~310 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0dea3c01b6bc388a096c139e2526f1cb21c39cfd;p=thirdparty%2Futil-linux.git libmount: (optlist) filter by optmap masks Signed-off-by: Karel Zak --- diff --git a/libmount/src/mountP.h b/libmount/src/mountP.h index 9a0727d1be..6977b0c195 100644 --- a/libmount/src/mountP.h +++ b/libmount/src/mountP.h @@ -514,9 +514,13 @@ enum { /* Default -- if @map specified then returns all options for the map, otherwise * returns all options including uknonwn options, exclude external options */ MNT_OL_FLTR_DFLT = 0, + /* Options as expected by mount. helpers */ + MNT_OL_FLTR_HELPERS, + /* Options as expected in mtab */ + MNT_OL_FLTR_MTAB, /* All options -- include mapped, unknown and external options */ MNT_OL_FLTR_ALL, - /* All unknown options -- exclude external */ + /* All unknown options -- exclude external (usually FS specific options) */ MNT_OL_FLTR_UNKNOWN, __MNT_OL_FLTR_COUNT /* keep it last */ diff --git a/libmount/src/optlist.c b/libmount/src/optlist.c index d480eb9950..158982cb7a 100644 --- a/libmount/src/optlist.c +++ b/libmount/src/optlist.c @@ -665,6 +665,14 @@ int mnt_optlist_strdup_optstr(struct libmnt_optlist *ls, char **optstr, if (opt->map || opt->external) continue; break; + case MNT_OL_FLTR_HELPERS: + if (opt->ent && opt->ent->mask & MNT_NOHLPS) + continue; + break; + case MNT_OL_FLTR_MTAB: + if (opt->ent && opt->ent->mask & MNT_NOMTAB) + continue; + break; } rc = mnt_buffer_append_option(&buf, @@ -707,10 +715,10 @@ int mnt_optlist_get_optstr(struct libmnt_optlist *ls, const char **optstr, cache = &ls->cache_all[MNT_OL_FLTR_DFLT]; break; case MNT_OL_FLTR_ALL: - cache = &ls->cache_all[MNT_OL_FLTR_ALL]; - break; case MNT_OL_FLTR_UNKNOWN: - cache = &ls->cache_all[MNT_OL_FLTR_UNKNOWN]; + case MNT_OL_FLTR_HELPERS: + case MNT_OL_FLTR_MTAB: + cache = &ls->cache_all[what]; break; default: return -EINVAL;