]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: (context) use default options maps
authorKarel Zak <kzak@redhat.com>
Mon, 15 Aug 2022 15:32:40 +0000 (17:32 +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/context.c

index b73b329d41c163a5d8c066560eee45c23350cbe8..8115ffc18fc69e238813cbbefaeaededce557e56 100644 (file)
@@ -1101,8 +1101,22 @@ struct libmnt_optlist *mnt_context_get_optlist(struct libmnt_context *cxt)
 {
        if (!cxt)
                return NULL;
-
-       return cxt->optlist ? : (cxt->optlist = mnt_new_optlist());
+       if (!cxt->optlist) {
+               cxt->optlist = mnt_new_optlist();
+               if (!cxt->optlist)
+                       return NULL;
+               if (mnt_optlist_register_map(cxt->optlist,
+                               mnt_get_builtin_optmap(MNT_LINUX_MAP)))
+                       goto fail;
+               if (mnt_optlist_register_map(cxt->optlist,
+                               mnt_get_builtin_optmap(MNT_USERSPACE_MAP)))
+                       goto fail;
+       }
+
+       return cxt->optlist;
+fail:
+       mnt_unref_optlist(cxt->optlist);
+       return NULL;
 }
 
 /**