代码拉取完成,页面将自动刷新
From 46eed8e1649cb8446d4c051ad1f1821cf3adca1a Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 14 May 2024 11:58:20 +0200
Subject: [PATCH] libmount: Fix atime remount for new API
All atime settings are mutually exclusive, and the attr_set mask for
the mount_setattr() syscall cannot contain multiple MOUNT_ATTR_ atime
related options.
Unfortunately, during a remount, the list of options is composed of
both old and new options. In this case, libmount sets more atime
options to the mask. The correct behavior is to use the last atime
related option from the list.
Fixes: https://github.com/util-linux/util-linux/issues/3032
Signed-off-by: Karel Zak <kzak@redhat.com>
---
libmount/src/optlist.c | 33 +++++++++++++++++++++------------
1 file changed, 21 insertions(+), 12 deletions(-)
diff --git a/libmount/src/optlist.c b/libmount/src/optlist.c
index 476acfd65..e32489627 100644
--- a/libmount/src/optlist.c
+++ b/libmount/src/optlist.c
@@ -837,6 +837,7 @@ int mnt_optlist_get_attrs(struct libmnt_optlist *ls, uint64_t *set, uint64_t *cl
struct libmnt_iter itr;
struct libmnt_opt *opt;
uint64_t remount_reset = 0;
+ uint64_t atime_set = 0;
if (!ls || !ls->linux_map || !set || !clr)
return -EINVAL;
@@ -879,29 +880,37 @@ int mnt_optlist_get_attrs(struct libmnt_optlist *ls, uint64_t *set, uint64_t *cl
remount_reset &= ~x;
if (opt->ent->mask & MNT_INVERT) {
- DBG(OPTLIST, ul_debugobj(ls, " clr: %s", opt->ent->name));
- /*
- * All atime settings are mutually exclusive so *clr must
- * have MOUNT_ATTR__ATIME set.
- *
- * See the function fs/namespace.c:build_mount_kattr()
- * in the linux kernel source.
- */
+ DBG(OPTLIST, ul_debugobj(ls, " clr: %s 0x%08" PRIx64,
+ opt->ent->name, x));
+
if (x == MOUNT_ATTR_RELATIME || x == MOUNT_ATTR_NOATIME ||
x == MOUNT_ATTR_STRICTATIME)
*clr |= MOUNT_ATTR__ATIME;
else
*clr |= x;
} else {
- DBG(OPTLIST, ul_debugobj(ls, " set: %s", opt->ent->name));
- *set |= x;
-
if (x == MOUNT_ATTR_RELATIME || x == MOUNT_ATTR_NOATIME ||
- x == MOUNT_ATTR_STRICTATIME)
+ x == MOUNT_ATTR_STRICTATIME) {
+ /* All atime settings are mutually exclusive,
+ * the last option wins and MOUNT_ATTR__ATIME
+ * is required in clr mask.
+ */
+ DBG(OPTLIST, ul_debugobj(ls, " atime: %s 0x%08" PRIx64,
+ opt->ent->name, x));
*clr |= MOUNT_ATTR__ATIME;
+ atime_set = x;
+ } else {
+ DBG(OPTLIST, ul_debugobj(ls, " set: %s 0x%08" PRIx64,
+ opt->ent->name, x));
+ *set |= x;
+ }
}
}
+ if (atime_set) {
+ DBG(OPTLIST, ul_debugobj(ls, " set atime 0x%08" PRIx64, atime_set));
+ *set |= atime_set;
+ }
if (remount_reset)
*clr |= remount_reset;
--
2.33.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。