13 Star 2 Fork 54

src-openEuler/util-linux

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-libmount-Fix-atime-remount-for-new-API.patch 2.69 KB
一键复制 编辑 原始数据 按行查看 历史
zhangyao2022 提交于 2024-07-03 14:38 . sync community patches
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
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/util-linux.git
git@gitee.com:src-openeuler/util-linux.git
src-openeuler
util-linux
util-linux
master

搜索帮助