From: Karel Zak Date: Mon, 5 Jun 2023 10:59:41 +0000 (+0200) Subject: libmount: use mount(2) for remount on Linux < 5.14 X-Git-Tag: v2.40-rc1~401^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=71b01d2a3760f36a1e81d422237f661fd07a72ad;p=thirdparty%2Futil-linux.git libmount: use mount(2) for remount on Linux < 5.14 It seems mount_setattr() is supported on Linux < 5.14, but it's without MOUNT_ATTR_NOSYMFOLLOW. That's problem for remount where we reset all VFS flags. The most simple (but not elegant) is to check for kernel version and fallback to mount(2) on remount. Addresses: https://github.com/util-linux/util-linux/issues/2283 Signed-off-by: Karel Zak --- diff --git a/libmount/src/hook_mount.c b/libmount/src/hook_mount.c index 91483afa68..5a7e30fea0 100644 --- a/libmount/src/hook_mount.c +++ b/libmount/src/hook_mount.c @@ -46,6 +46,7 @@ #include "mountP.h" #include "fileutils.h" /* statx() fallback */ #include "mount-api-utils.h" +#include "linux_version.h" #include @@ -693,6 +694,13 @@ static int hook_prepare(struct libmnt_context *cxt, if (!rc && cxt->helper == NULL && (set != 0 || clr != 0 || (flags & MS_REMOUNT))) { + /* + * mount_setattr() supported, but not usable for remount + * https://github.com/torvalds/linux/commit/dd8b477f9a3d8edb136207acb3652e1a34a661b7 + */ + if (get_linux_version() < KERNEL_VERSION(5, 14, 0)) + goto enosys; + if (!mount_setattr_is_supported()) goto enosys;