From e828630a16c7c31bfbce228d6993c1cff7088152 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Mon, 24 Apr 2023 17:29:05 +0200 Subject: [PATCH] libmount: recover from ENOSYS for the new API Addresses: https://github.com/util-linux/util-linux/pull/2188 Signed-off-by: Karel Zak --- libmount/src/hook_mount.c | 11 ++++++++++- libmount/src/mountP.h | 6 ++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/libmount/src/hook_mount.c b/libmount/src/hook_mount.c index 7fcf3f3f84..2dbe5217cc 100644 --- a/libmount/src/hook_mount.c +++ b/libmount/src/hook_mount.c @@ -571,6 +571,8 @@ fake: * * Note that this function interprets classic MS_* flags by new Linux mount FD * based API. + * + * Returns: 0 on success, <0 on error, >0 on recover-able error */ static int hook_prepare(struct libmnt_context *cxt, const struct libmnt_hookset *hs, @@ -614,8 +616,15 @@ static int hook_prepare(struct libmnt_context *cxt, rc = mnt_optlist_get_attrs(ol, &set, &clr, 0); /* open_tree() or fsopen() */ - if (!rc) + if (!rc) { rc = init_sysapi(cxt, hs, flags); + if (rc && cxt->syscall_status == -ENOSYS) { + /* we need to recover from this error, so hook_mount_legacy.c + * can try to continue */ + reset_syscall_status(cxt); + return 1; + } + } /* check mutually exclusive operations */ if (!rc && (flags & MS_BIND) && (flags & MS_MOVE)) diff --git a/libmount/src/mountP.h b/libmount/src/mountP.h index d7ae6b7d2d..a2ab4a8145 100644 --- a/libmount/src/mountP.h +++ b/libmount/src/mountP.h @@ -490,6 +490,12 @@ struct libmnt_context } \ }) +#define reset_syscall_status(_cxt) __extension__ ({ \ + DBG(CXT, ul_debug("reset sycall status")); \ + (_cxt)->syscall_status = 0; \ + (_cxt)->syscall_name = NULL; \ + }) + /* optmap.c */ extern const struct libmnt_optmap *mnt_optmap_get_entry( struct libmnt_optmap const **maps, -- 2.47.2