]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: (optlist) filter by optmap masks
authorKarel Zak <kzak@redhat.com>
Thu, 18 Aug 2022 10:38:44 +0000 (12:38 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 3 Jan 2023 11:58:42 +0000 (12:58 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/mountP.h
libmount/src/optlist.c

index 9a0727d1be589fcfebeb04f89defd878cd8da6bb..6977b0c1956ff41123fa9d2ee96c625d9a953127 100644 (file)
@@ -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.<type> 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 */
index d480eb99507a15c110b682e72ce5b21896ef52b9..158982cb7af7a38e07733f28e6d0be2a47bede0f 100644 (file)
@@ -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;