[LTP] [PATCH v1] mount_setattr01.c: Add clearing the attributes check
Wei Gao
wegao@suse.com
Fri Feb 14 07:20:34 CET 2025
Signed-off-by: Wei Gao <wegao@suse.com>
---
.../syscalls/mount_setattr/mount_setattr01.c | 39 +++++++++++++++++--
1 file changed, 35 insertions(+), 4 deletions(-)
diff --git a/testcases/kernel/syscalls/mount_setattr/mount_setattr01.c b/testcases/kernel/syscalls/mount_setattr/mount_setattr01.c
index e500df28e..aac487aa6 100644
--- a/testcases/kernel/syscalls/mount_setattr/mount_setattr01.c
+++ b/testcases/kernel/syscalls/mount_setattr/mount_setattr01.c
@@ -98,16 +98,47 @@ static void run(unsigned int n)
if (!TST_PASS)
goto out1;
mount_flag = 1;
+
+ TST_EXP_PASS_SILENT(statvfs(OT_MNTPOINT, &buf), "statvfs sucess");
+ if (!TST_PASS)
+ goto out2;
+
+ TST_EXP_EXPR(buf.f_flag & tc->expect_attrs, "%s set check pass", tc->name);
+
SAFE_CLOSE(otfd);
+ SAFE_UMOUNT(OT_MNTPOINT);
+ mount_flag = 0;
+
+ TST_EXP_FD_SILENT(open_tree(AT_FDCWD, MNTPOINT, AT_EMPTY_PATH |
+ AT_SYMLINK_NOFOLLOW | OPEN_TREE_CLOEXEC | OPEN_TREE_CLONE));
+ if (!TST_PASS)
+ return;
+
+ otfd = (int)TST_RET;
+
+ TST_EXP_PASS_SILENT(mount_setattr(otfd, "", AT_EMPTY_PATH, &attr, sizeof(attr)),
+ "%s set", tc->name);
+ if (!TST_PASS)
+ goto out1;
+
+ attr.attr_set &= ~tc->mount_attrs;
+ attr.attr_clr |= tc->mount_attrs;
+ TST_EXP_PASS_SILENT(mount_setattr(otfd, "", AT_EMPTY_PATH, &attr, sizeof(attr)),
+ "%s set", tc->name);
+ if (!TST_PASS)
+ goto out1;
+
+ TST_EXP_PASS_SILENT(move_mount(otfd, "", AT_FDCWD, OT_MNTPOINT, MOVE_MOUNT_F_EMPTY_PATH));
+ if (!TST_PASS)
+ goto out1;
+ mount_flag = 1;
TST_EXP_PASS_SILENT(statvfs(OT_MNTPOINT, &buf), "statvfs sucess");
if (!TST_PASS)
goto out2;
- if (buf.f_flag & tc->expect_attrs)
- tst_res(TPASS, "%s is actually set as expected", tc->name);
- else
- tst_res(TFAIL, "%s is not actually set as expected", tc->name);
+ TST_EXP_EXPR(!(buf.f_flag & tc->expect_attrs), "%s clear check pass", tc->name);
+ SAFE_CLOSE(otfd);
goto out2;
--
2.35.3
More information about the ltp
mailing list