Skip to content

Commit

Permalink
libmount: use mount(2) for remount on Linux < 5.14
Browse files Browse the repository at this point in the history
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: util-linux#2283
Signed-off-by: Karel Zak <kzak@redhat.com>
  • Loading branch information
karelzak committed Jun 5, 2023
1 parent 90b1259 commit 71b01d2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions libmount/src/hook_mount.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include "mountP.h"
#include "fileutils.h" /* statx() fallback */
#include "mount-api-utils.h"
#include "linux_version.h"

#include <inttypes.h>

Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 71b01d2

Please sign in to comment.