]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: (owner) use optlist for X-mount options
authorKarel Zak <kzak@redhat.com>
Tue, 23 Aug 2022 12:24:47 +0000 (14:24 +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/hook_owner.c

index f23ef536c65f95c838d08e2ca7d69dd982eb51cd..02fdcbefd9e838e8c1902630154f88c2de7df686 100644 (file)
@@ -92,54 +92,56 @@ static int hook_prepare_options(
                        void *data __attribute__((__unused__)))
 {
        struct hook_data *hd = NULL;
-       const char *o;
+       struct libmnt_optlist *ol;
+       struct libmnt_opt *opt;
        int rc = 0;
-       char *value;
-       size_t valsz;
 
-       o = mnt_fs_get_user_options(cxt->fs);
-       if (!o)
-               return 0;
+       assert(cxt);
+       assert(cxt->map_userspace);
+
+       ol = mnt_context_get_optlist(cxt);
+       if (!ol)
+               return -ENOMEM;
 
-       if ((rc = mnt_optstr_get_option(o, "X-mount.owner", &value, &valsz)) < 0)
-               goto fail;
-       if (rc == 0) {
-               if (!valsz)
+       opt = mnt_optlist_get_named(ol, "X-mount.owner", cxt->map_userspace);
+       if (opt) {
+               const char *value = mnt_opt_get_value(opt);
+               if (!value)
                        goto fail;
                if (!hd) {
                        hd = new_hook_data();
                        if (!hd)
                                goto fail;
                }
-               if (mnt_parse_uid(value, valsz, &hd->owner))
+               if (mnt_parse_uid(value, strlen(value), &hd->owner))
                        goto fail;
        }
 
-       if ((rc = mnt_optstr_get_option(o, "X-mount.group", &value, &valsz)) < 0)
-               goto fail;
-       if (rc == 0) {
-               if (!valsz)
+       opt = mnt_optlist_get_named(ol, "X-mount.group", cxt->map_userspace);
+       if (opt) {
+               const char *value = mnt_opt_get_value(opt);
+               if (!value)
                        goto fail;
                if (!hd) {
                        hd = new_hook_data();
                        if (!hd)
                                goto fail;
                }
-               if (mnt_parse_gid(value, valsz, &hd->group))
+               if (mnt_parse_gid(value, strlen(value), &hd->group))
                        goto fail;
        }
 
-       if ((rc = mnt_optstr_get_option(o, "X-mount.mode", &value, &valsz)) < 0)
-               goto fail;
-       if (rc == 0) {
-               if (!valsz)
+       opt = mnt_optlist_get_named(ol, "X-mount.mode", cxt->map_userspace);
+       if (opt) {
+               const char *value = mnt_opt_get_value(opt);
+               if (!value)
                        goto fail;
                if (!hd) {
                        hd = new_hook_data();
                        if (!hd)
                                goto fail;
                }
-               if (mnt_parse_mode(value, valsz, &hd->mode))
+               if (mnt_parse_mode(value, strlen(value), &hd->mode))
                        goto fail;
        }