From: Karel Zak Date: Fri, 19 Aug 2022 16:43:26 +0000 (+0200) Subject: libmount: (subdir) use optlist X-Git-Tag: v2.39-rc1~301 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=07cac903ebc9901ba7dd47a05dbee9ed9daeed8f;p=thirdparty%2Futil-linux.git libmount: (subdir) use optlist Signed-off-by: Karel Zak --- diff --git a/libmount/src/hook_subdir.c b/libmount/src/hook_subdir.c index 09025c5b5f..34b680b3fa 100644 --- a/libmount/src/hook_subdir.c +++ b/libmount/src/hook_subdir.c @@ -228,28 +228,33 @@ static int hook_mount_pre( static int is_subdir_required(struct libmnt_context *cxt, int *rc, char **subdir) { - char *dir = NULL; - size_t sz; + struct libmnt_optlist *ol; + struct libmnt_opt *opt; + const char *dir = NULL; assert(cxt); assert(rc); *rc = 0; - if (!cxt->fs - || !cxt->fs->user_optstr - || mnt_optstr_get_option(cxt->fs->user_optstr, - "X-mount.subdir", &dir, &sz) != 0) + ol = mnt_context_get_optlist(cxt); + if (!ol) + return -ENOMEM; + + opt = mnt_optlist_get_named(ol, "X-mount.subdir", cxt->map_userspace); + if (!opt) return 0; + dir = mnt_opt_get_value(opt); + if (dir && *dir == '"') - dir++, sz-=2; + dir++; - if (!dir || sz < 1) { + if (!dir || !*dir) { DBG(HOOK, ul_debug("failed to parse X-mount.subdir '%s'", dir)); *rc = -MNT_ERR_MOUNTOPT; } else { - *subdir = strndup(dir, sz); + *subdir = strdup(dir); if (!*subdir) *rc = -ENOMEM; } @@ -274,9 +279,7 @@ static int hook_prepare_target( if (!tgt) return 0; - /* X-mount.subdir= target */ if (cxt->action == MNT_ACT_MOUNT - && (cxt->user_mountflags & MNT_MS_XFSTABCOMM) && is_subdir_required(cxt, &rc, &subdir)) { /* create a global data */