public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH v3 0/2] open_tree_attr syscall coverage
@ 2025-09-17 14:25 Andrea Cervesato
  2025-09-17 14:25 ` [LTP] [PATCH v3 1/2] Add open_tree_attr fallback Andrea Cervesato
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Andrea Cervesato @ 2025-09-17 14:25 UTC (permalink / raw)
  To: ltp

open_tree_attr has been added in kernel 6.15 in the following commit:
https://lore.kernel.org/all/20250128-work-mnt_idmap-update-v2-v1-3-c25feb0d2eb3@kernel.org/

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
Changes in v3:
- define variants only when syscalls are supported
- Link to v2: https://lore.kernel.org/r/20250902-open_tree_attr-v2-0-b23d2585986d@suse.com

Changes in v2:
- close FD after opening it with open_tree()
- revert style edit in setup()
- use TST_EXP_FD_SILENT()
- Link to v1: https://lore.kernel.org/r/20250828-open_tree_attr-v1-0-f339a0e51e22@suse.com

---
Andrea Cervesato (2):
      Add open_tree_attr fallback
      mount_setattr01: add open_tree_attr variant

 configure.ac                                       |  1 +
 include/lapi/fsmount.h                             |  8 +++
 .../syscalls/mount_setattr/mount_setattr01.c       | 83 +++++++++++++++++-----
 3 files changed, 74 insertions(+), 18 deletions(-)
---
base-commit: 2f208c00cfc4a1d7d5d957ac2b866e1248623aa6
change-id: 20250828-open_tree_attr-4b2ece576c1c

Best regards,
-- 
Andrea Cervesato <andrea.cervesato@suse.com>


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [LTP] [PATCH v3 1/2] Add open_tree_attr fallback
  2025-09-17 14:25 [LTP] [PATCH v3 0/2] open_tree_attr syscall coverage Andrea Cervesato
@ 2025-09-17 14:25 ` Andrea Cervesato
  2025-09-17 14:25 ` [LTP] [PATCH v3 2/2] mount_setattr01: add open_tree_attr variant Andrea Cervesato
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Andrea Cervesato @ 2025-09-17 14:25 UTC (permalink / raw)
  To: ltp

From: Andrea Cervesato <andrea.cervesato@suse.com>

open_tree_attr syscall has been introduced in kernel 6.15 and it's
now defined in lapi/fsmount.h.

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
 configure.ac           | 1 +
 include/lapi/fsmount.h | 8 ++++++++
 2 files changed, 9 insertions(+)

diff --git a/configure.ac b/configure.ac
index 62ae27d494474fe342b1cceeac7f4c21c0b1028c..2d4d527bcaa675dae5d712a96d266d17184b8a0d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -137,6 +137,7 @@ AC_CHECK_FUNCS_ONCE([ \
     move_mount \
     name_to_handle_at \
     open_tree \
+    open_tree_attr \
     openat \
     openat2 \
     pidfd_getfd \
diff --git a/include/lapi/fsmount.h b/include/lapi/fsmount.h
index 1783272a00a1a049031cacbb417239123450a0e4..451987ae637d040e08970b7ffcf015bae07a6f11 100644
--- a/include/lapi/fsmount.h
+++ b/include/lapi/fsmount.h
@@ -105,6 +105,14 @@ static inline int open_tree(int dirfd, const char *pathname, unsigned int flags)
 }
 #endif /* HAVE_OPEN_TREE */
 
+#ifndef HAVE_OPEN_TREE_ATTR
+static inline int open_tree_attr(int dirfd, const char *pathname, unsigned int flags,
+				 struct mount_attr *attr, size_t size)
+{
+	return tst_syscall(__NR_open_tree_attr, dirfd, pathname, flags, attr, size);
+}
+#endif /* HAVE_OPEN_TREE_ATTR */
+
 #ifndef HAVE_MOUNT_SETATTR
 static inline int mount_setattr(int dirfd, const char *from_pathname, unsigned int flags,
 				struct mount_attr *attr, size_t size)

-- 
2.51.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [LTP] [PATCH v3 2/2] mount_setattr01: add open_tree_attr variant
  2025-09-17 14:25 [LTP] [PATCH v3 0/2] open_tree_attr syscall coverage Andrea Cervesato
  2025-09-17 14:25 ` [LTP] [PATCH v3 1/2] Add open_tree_attr fallback Andrea Cervesato
@ 2025-09-17 14:25 ` Andrea Cervesato
  2025-09-25  9:49 ` [LTP] [PATCH v3 0/2] open_tree_attr syscall coverage Andrea Cervesato via ltp
  2026-03-11 15:29 ` Andrea Cervesato via ltp
  3 siblings, 0 replies; 7+ messages in thread
From: Andrea Cervesato @ 2025-09-17 14:25 UTC (permalink / raw)
  To: ltp

From: Andrea Cervesato <andrea.cervesato@suse.com>

This patch simply introduces a new variant to the mount_setattr01
test, in order to verify that open_tree_attr() works correctly.
The open_tree_attr() syscall has been introduced in the kernel v6.15 by
commit "c4a16820d901 - fs: add open_tree_attr()".

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
 .../syscalls/mount_setattr/mount_setattr01.c       | 83 +++++++++++++++++-----
 1 file changed, 65 insertions(+), 18 deletions(-)

diff --git a/testcases/kernel/syscalls/mount_setattr/mount_setattr01.c b/testcases/kernel/syscalls/mount_setattr/mount_setattr01.c
index eb32cd91a7fcb4cb303e184dd40d5e10a280874c..14927e1038e1333120bdd0bad33c3891301e71ec 100644
--- a/testcases/kernel/syscalls/mount_setattr/mount_setattr01.c
+++ b/testcases/kernel/syscalls/mount_setattr/mount_setattr01.c
@@ -3,10 +3,11 @@
  * Copyright (c) 2022 FUJITSU LIMITED. All rights reserved.
  * Author: Dai Shili <daisl.fnst@fujitsu.com>
  * Author: Chen Hanxiao <chenhx.fnst@fujitsu.com>
+ * Copyright (C) 2025 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
  */
 
 /*\
- * Basic mount_setattr() test.
+ * Basic mount_setattr()/open_tree_attr() test.
  * Test whether the basic mount attributes are set correctly.
  *
  * Verify some MOUNT_SETATTR(2) attributes:
@@ -22,7 +23,8 @@
  * - MOUNT_ATTR_NODIRATIME - prevents updating access time for
  *   directories on this mount
  *
- * The functionality was added in v5.12.
+ * The mount_setattr functionality was added in v5.12, while the open_tree_attr
+ * functionality was added in v6.15.
  */
 
 #define _GNU_SOURCE
@@ -30,6 +32,7 @@
 #include <sys/statvfs.h>
 #include "tst_test.h"
 #include "lapi/fsmount.h"
+#include "lapi/syscalls.h"
 
 #define MNTPOINT        "mntpoint"
 #define OT_MNTPOINT     "ot_mntpoint"
@@ -40,7 +43,23 @@
 		.expect_attrs = exp_attrs       \
 	}
 
+static int open_tree_variant1(struct mount_attr *attr);
+static int open_tree_variant2(struct mount_attr *attr);
+
 static int mount_flag, otfd = -1;
+struct mount_attr *attr;
+
+static struct tsetattr_variant {
+	int (*child_variant)(struct mount_attr *attr);
+	char *desc;
+} tvariants[] = {
+#if (__NR_mount_setattr != __LTP__NR_INVALID_SYSCALL)
+	{ .child_variant = &open_tree_variant1, "mount_setattr()" },
+#endif
+#if (__NR_open_tree_attr != __LTP__NR_INVALID_SYSCALL)
+	{ .child_variant = &open_tree_variant2, "open_tree_attr()"},
+#endif
+};
 
 static struct tcase {
 	char *name;
@@ -66,39 +85,62 @@ static void cleanup(void)
 static void setup(void)
 {
 	fsopen_supported_by_kernel();
-	struct stat st = {0};
 
-	if (stat(OT_MNTPOINT, &st) == -1)
+	if (access(OT_MNTPOINT, F_OK) != 0)
 		SAFE_MKDIR(OT_MNTPOINT, 0777);
 }
 
+static int open_tree_variant1(struct mount_attr *attr)
+{
+	tst_res(TINFO, "Using variant open_tree() + mount_setattr()");
+
+	otfd = TST_EXP_FD_SILENT(open_tree(AT_FDCWD, MNTPOINT,
+			AT_EMPTY_PATH | OPEN_TREE_CLONE));
+	if (otfd == -1)
+		return -1;
+
+	TST_EXP_PASS(mount_setattr(otfd, "", AT_EMPTY_PATH,
+			attr, sizeof(*attr)));
+	if (TST_RET == -1) {
+		SAFE_CLOSE(otfd);
+		return -1;
+	}
+
+	return otfd;
+}
+
+static int open_tree_variant2(struct mount_attr *attr)
+{
+	otfd = TST_EXP_FD(open_tree_attr(AT_FDCWD, MNTPOINT,
+			AT_EMPTY_PATH | OPEN_TREE_CLONE,
+			attr, sizeof(*attr)));
+
+	return otfd;
+}
+
 static void run(unsigned int n)
 {
 	struct tcase *tc = &tcases[n];
-	struct mount_attr attr = {
-		.attr_set = tc->mount_attrs,
-	};
+	struct tsetattr_variant *tv = &tvariants[tst_variant];
 	struct statvfs buf;
 
-	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;
+	tst_res(TINFO, "Using variant %s", tv->desc);
 
-	otfd = (int)TST_RET;
+	memset(attr, 0, sizeof(*attr));
+	attr->attr_set = 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;
+	otfd = tv->child_variant(attr);
+	if (otfd == -1)
+		goto out2;
 
 	TST_EXP_PASS_SILENT(move_mount(otfd, "", AT_FDCWD, OT_MNTPOINT, MOVE_MOUNT_F_EMPTY_PATH));
 	if (!TST_PASS)
 		goto out1;
+
 	mount_flag = 1;
 	SAFE_CLOSE(otfd);
 
-	TST_EXP_PASS_SILENT(statvfs(OT_MNTPOINT, &buf), "statvfs sucess");
+	TST_EXP_PASS_SILENT(statvfs(OT_MNTPOINT, &buf), "statvfs success");
 	if (!TST_PASS)
 		goto out2;
 
@@ -123,9 +165,14 @@ static struct tst_test test = {
 	.test = run,
 	.setup = setup,
 	.cleanup = cleanup,
+	.test_variants = ARRAY_SIZE(tvariants),
 	.needs_root = 1,
 	.mount_device = 1,
 	.mntpoint = MNTPOINT,
 	.all_filesystems = 1,
-	.skip_filesystems = (const char *const []){"fuse", NULL},
+	.skip_filesystems = (const char *const []) {"fuse", NULL},
+	.bufs = (struct tst_buffers []) {
+		{&attr, .size = sizeof(struct mount_attr)},
+		{}
+	}
 };

-- 
2.51.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [LTP] [PATCH v3 0/2] open_tree_attr syscall coverage
  2025-09-17 14:25 [LTP] [PATCH v3 0/2] open_tree_attr syscall coverage Andrea Cervesato
  2025-09-17 14:25 ` [LTP] [PATCH v3 1/2] Add open_tree_attr fallback Andrea Cervesato
  2025-09-17 14:25 ` [LTP] [PATCH v3 2/2] mount_setattr01: add open_tree_attr variant Andrea Cervesato
@ 2025-09-25  9:49 ` Andrea Cervesato via ltp
  2025-09-25 14:00   ` Cyril Hrubis
  2026-03-11 15:29 ` Andrea Cervesato via ltp
  3 siblings, 1 reply; 7+ messages in thread
From: Andrea Cervesato via ltp @ 2025-09-25  9:49 UTC (permalink / raw)
  To: Andrea Cervesato, ltp

Hi!

On 9/17/25 4:25 PM, Andrea Cervesato wrote:
> open_tree_attr has been added in kernel 6.15 in the following commit:
> https://lore.kernel.org/all/20250128-work-mnt_idmap-update-v2-v1-3-c25feb0d2eb3@kernel.org/
>
> Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
> ---
> Changes in v3:
> - define variants only when syscalls are supported
> - Link to v2: https://lore.kernel.org/r/20250902-open_tree_attr-v2-0-b23d2585986d@suse.com
>
> Changes in v2:
> - close FD after opening it with open_tree()
> - revert style edit in setup()
> - use TST_EXP_FD_SILENT()
> - Link to v1: https://lore.kernel.org/r/20250828-open_tree_attr-v1-0-f339a0e51e22@suse.com
>
> ---
> Andrea Cervesato (2):
>        Add open_tree_attr fallback
>        mount_setattr01: add open_tree_attr variant
>
>   configure.ac                                       |  1 +
>   include/lapi/fsmount.h                             |  8 +++
>   .../syscalls/mount_setattr/mount_setattr01.c       | 83 +++++++++++++++++-----
>   3 files changed, 74 insertions(+), 18 deletions(-)
> ---
> base-commit: 2f208c00cfc4a1d7d5d957ac2b866e1248623aa6
> change-id: 20250828-open_tree_attr-4b2ece576c1c
>
> Best regards,

Should I merge this one? I got Reviewed tag already.

- Andrea


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [LTP] [PATCH v3 0/2] open_tree_attr syscall coverage
  2025-09-25  9:49 ` [LTP] [PATCH v3 0/2] open_tree_attr syscall coverage Andrea Cervesato via ltp
@ 2025-09-25 14:00   ` Cyril Hrubis
  2025-09-25 14:02     ` Andrea Cervesato via ltp
  0 siblings, 1 reply; 7+ messages in thread
From: Cyril Hrubis @ 2025-09-25 14:00 UTC (permalink / raw)
  To: Andrea Cervesato; +Cc: ltp

Hi!
> Should I merge this one? I got Reviewed tag already.

We are in a pre-release git freeze now, so only fixes should go in until
the release.

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [LTP] [PATCH v3 0/2] open_tree_attr syscall coverage
  2025-09-25 14:00   ` Cyril Hrubis
@ 2025-09-25 14:02     ` Andrea Cervesato via ltp
  0 siblings, 0 replies; 7+ messages in thread
From: Andrea Cervesato via ltp @ 2025-09-25 14:02 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: ltp

On 9/25/25 4:00 PM, Cyril Hrubis wrote:
> Hi!
>> Should I merge this one? I got Reviewed tag already.
> We are in a pre-release git freeze now, so only fixes should go in until
> the release.
>
Ok thanks, I will merge it once we have the release.

- Andrea


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [LTP] [PATCH v3 0/2] open_tree_attr syscall coverage
  2025-09-17 14:25 [LTP] [PATCH v3 0/2] open_tree_attr syscall coverage Andrea Cervesato
                   ` (2 preceding siblings ...)
  2025-09-25  9:49 ` [LTP] [PATCH v3 0/2] open_tree_attr syscall coverage Andrea Cervesato via ltp
@ 2026-03-11 15:29 ` Andrea Cervesato via ltp
  3 siblings, 0 replies; 7+ messages in thread
From: Andrea Cervesato via ltp @ 2026-03-11 15:29 UTC (permalink / raw)
  To: ltp

Merged, I forgot it after release.

--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-03-11 15:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-17 14:25 [LTP] [PATCH v3 0/2] open_tree_attr syscall coverage Andrea Cervesato
2025-09-17 14:25 ` [LTP] [PATCH v3 1/2] Add open_tree_attr fallback Andrea Cervesato
2025-09-17 14:25 ` [LTP] [PATCH v3 2/2] mount_setattr01: add open_tree_attr variant Andrea Cervesato
2025-09-25  9:49 ` [LTP] [PATCH v3 0/2] open_tree_attr syscall coverage Andrea Cervesato via ltp
2025-09-25 14:00   ` Cyril Hrubis
2025-09-25 14:02     ` Andrea Cervesato via ltp
2026-03-11 15:29 ` Andrea Cervesato via ltp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox