From: Karel Zak Date: Tue, 9 Feb 2021 09:36:04 +0000 (+0100) Subject: libmount: fix /{etc,proc}/filesystems use X-Git-Tag: v2.37-rc1~134 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b6787fca021945d06bcb016c3bd245ec0bdaf92e;p=thirdparty%2Futil-linux.git libmount: fix /{etc,proc}/filesystems use * always update context->helper * consolidate helper and syscall status use Signed-off-by: Karel Zak --- diff --git a/libmount/src/context.c b/libmount/src/context.c index fa8a8c54b5..ccd050130e 100644 --- a/libmount/src/context.c +++ b/libmount/src/context.c @@ -2101,6 +2101,11 @@ int mnt_context_prepare_helper(struct libmnt_context *cxt, const char *name, assert(cxt->fs); assert((cxt->flags & MNT_FL_MOUNTFLAGS_MERGED)); + if (cxt->helper) { + free(cxt->helper); + cxt->helper = NULL; + } + if (!type) type = mnt_fs_get_fstype(cxt->fs); diff --git a/libmount/src/context_mount.c b/libmount/src/context_mount.c index dd17861764..28ffc88247 100644 --- a/libmount/src/context_mount.c +++ b/libmount/src/context_mount.c @@ -773,7 +773,7 @@ static int do_mount(struct libmnt_context *cxt, const char *try_type) assert(cxt->fs); assert((cxt->flags & MNT_FL_MOUNTFLAGS_MERGED)); - if (try_type && !cxt->helper) { + if (try_type) { rc = mnt_context_prepare_helper(cxt, "mount", try_type); if (rc) return rc; @@ -860,6 +860,17 @@ static int do_mount(struct libmnt_context *cxt, const char *try_type) return rc; } +static int is_success_status(struct libmnt_context *cxt) +{ + if (mnt_context_helper_executed(cxt)) + return mnt_context_get_helper_status(cxt) == 0; + + if (mnt_context_syscall_called(cxt)) + return mnt_context_get_status(cxt) == 1; + + return 0; +} + /* try mount(2) for all items in comma separated list of the filesystem @types */ static int do_mount_by_types(struct libmnt_context *cxt, const char *types) { @@ -900,7 +911,7 @@ static int do_mount_by_types(struct libmnt_context *cxt, const char *types) rc = do_mount(cxt, p); p = end ? end + 1 : NULL; free(autotype); - } while (!mnt_context_get_status(cxt) && p); + } while (!is_success_status(cxt) && p); free(p0); return rc; @@ -943,8 +954,9 @@ static int do_mount_by_pattern(struct libmnt_context *cxt, const char *pattern) return -MNT_ERR_NOFSTYPE; for (fp = filesystems; *fp; fp++) { + DBG(CXT, ul_debugobj(cxt, " ##### trying '%s'", *fp)); rc = do_mount(cxt, *fp); - if (mnt_context_get_status(cxt)) + if (is_success_status(cxt)) break; if (mnt_context_get_syscall_errno(cxt) != EINVAL && mnt_context_get_syscall_errno(cxt) != ENODEV)