]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: use mount(2) for remount on Linux < 5.14
authorKarel Zak <kzak@redhat.com>
Mon, 5 Jun 2023 10:59:41 +0000 (12:59 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 5 Jun 2023 10:59:41 +0000 (12:59 +0200)
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 <kzak@redhat.com>
libmount/src/hook_mount.c

index 91483afa68f6caadb8b648e1db2139b4c7e325ff..5a7e30fea07519bcef839e6351855adb5d31fd12 100644 (file)
@@ -46,6 +46,7 @@
 #include "mountP.h"
 #include "fileutils.h" /* statx() fallback */
 #include "mount-api-utils.h"
+#include "linux_version.h"
 
 #include <inttypes.h>
 
@@ -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;