Skip to contentSkip to conversation

statmount/listmount testing suites

PATCH Superseded Andrea Cervesato 3 participants 25 messages May 16, 2024 – Jul 10, 2024

Subsystems (2)

v3 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v3 cover statmount/listmount testing suites

This patch-set is adding new testing suites for statmount() and listmount() syscalls, which have been recently added in kernel v6.8.
To find out more information, please read the following documentation since there's no man pages yet:

https://lwn.net/Articles/950569/
https://lore.kernel.org/lkml/[email protected]/T/

Along with kernel source code:

https://github.com/torvalds/linux/blob/1b294a1f35616977caddaddf3e9d28e576a1adbc/include/uapi/linux/mount.h#L155
https://github.com/torvalds/linux/blob/1b294a1f35616977caddaddf3e9d28e576a1adbc/tools/testing/selftests/filesystems/statmount/statmount_test.c

v2:
- split syscalls definitions from fallback declarations
- remove usless tst_test parameters declarations
- fixed documentation tags (kdoc -> asciidoc)

---
Andrea Cervesato (11):
Add SAFE_STATX macro
Add listmount/statmount syscalls
Add listmount/statmount fallback declarations Add listmount01 test
Add listmount02 test
Add stamount01 test
Add statmount02 test
Add statmount03 test
Add statmount04 test
Add statmount05 test
Add statmount06 test

 configure.ac                                      |   5 +
 include/lapi/mount.h                              |  70 +++++++++++
 include/lapi/stat.h                               |  10 +-
 include/lapi/syscalls/aarch64.in                  |   2 +
 include/lapi/syscalls/arc.in                      |   2 +
 include/lapi/syscalls/arm.in                      |   2 +
 include/lapi/syscalls/hppa.in                     |   2 +
 include/lapi/syscalls/i386.in                     |   2 +
 include/lapi/syscalls/ia64.in                     |   2 +
 include/lapi/syscalls/loongarch.in                |   2 +
 include/lapi/syscalls/mips_n32.in                 |   2 +
 include/lapi/syscalls/mips_n64.in                 |   2 +
 include/lapi/syscalls/mips_o32.in                 |   2 +
 include/lapi/syscalls/powerpc.in                  |   2 +
 include/lapi/syscalls/powerpc64.in                |   2 +
 include/lapi/syscalls/s390.in                     |   2 +
 include/lapi/syscalls/s390x.in                    |   2 +
 include/lapi/syscalls/sh.in                       |   2 +
 include/lapi/syscalls/sparc.in                    |   2 +
 include/lapi/syscalls/sparc64.in                  |   2 +
 include/lapi/syscalls/x86_64.in                   |   2 +
 include/tst_safe_macros.h                         |   7 ++
 lib/tst_safe_macros.c                             |  22 ++++
 runtest/syscalls                                  |  10 ++
 testcases/kernel/syscalls/listmount/.gitignore    |   2 +
 testcases/kernel/syscalls/listmount/Makefile      |   7 ++
 testcases/kernel/syscalls/listmount/listmount.h   |  26 +++++
 testcases/kernel/syscalls/listmount/listmount01.c |  66 +++++++++++
 testcases/kernel/syscalls/listmount/listmount02.c | 106 +++++++++++++++++
 testcases/kernel/syscalls/statmount/.gitignore    |   6 +
 testcases/kernel/syscalls/statmount/Makefile      |   7 ++
 testcases/kernel/syscalls/statmount/statmount.h   |  26 +++++
 testcases/kernel/syscalls/statmount/statmount01.c |  69 +++++++++++
 testcases/kernel/syscalls/statmount/statmount02.c |  76 ++++++++++++
 testcases/kernel/syscalls/statmount/statmount03.c |  97 +++++++++++++++
 testcases/kernel/syscalls/statmount/statmount04.c | 131 +++++++++++++++++++++
 testcases/kernel/syscalls/statmount/statmount05.c | 136 ++++++++++++++++++++++
 testcases/kernel/syscalls/statmount/statmount06.c |  72 ++++++++++++
 38 files changed, 986 insertions(+), 1 deletion(-)

---
base-commit: e644691d30c3948a9788b735c51e09ca849ea47f
change-id: 20240516-listmount_statmount-080965e2f80e

Best regards,

Signature · 5 lines
Andrea Cervesato <[email protected]>


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

PATCH v3 1/11 Add SAFE_STATX macro

From: Andrea Cervesato <[email protected]>

---
 include/tst_safe_macros.h |  7 +++++++
 lib/tst_safe_macros.c     | 22 ++++++++++++++++++++++
 2 files changed, 29 insertions(+)
include/tst_safe_macros.h +7 -0
index 8de8ef106..43ff50a33 100644
@@ -503,4 +503,11 @@ int safe_sscanf(const char *file, const int lineno, const char *restrict buffer,
 #define SAFE_SSCANF(buffer, format, ...) \
 	safe_sscanf(__FILE__, __LINE__, (buffer), (format),	##__VA_ARGS__)
 
+struct statx;
+int safe_statx(const char *file, const int lineno,
+	int dirfd, const char *pathname, int flags, unsigned int mask,
+	struct statx *buf);
+#define SAFE_STATX(dirfd, pathname, flags, mask, buf) \
+	safe_statx(__FILE__, __LINE__, (dirfd), (pathname), (flags), (mask), (buf))
+
 #endif /* TST_SAFE_MACROS_H__ */
lib/tst_safe_macros.c +22 -0
index 39b8cc924..f50a7bcc2 100644
@@ -20,6 +20,7 @@
 #include "tst_safe_macros.h"
 #include "lapi/personality.h"
 #include "lapi/pidfd.h"
+#include "lapi/stat.h"
 
 int safe_access(const char *file, const int lineno,
 	    const char *pathname, int mode)
@@ -710,3 +711,24 @@ int safe_mprotect(const char *file, const int lineno,
 
 	return rval;
 }
+
+int safe_statx(const char *file, const int lineno,
+	int dirfd, const char *pathname, int flags, unsigned int mask,
+	struct statx *buf)
+{
+	int rval;
+
+	rval = statx(dirfd, pathname, flags, mask, buf);
+
+	if (rval == -1) {
+		tst_brk_(file, lineno, TBROK | TERRNO,
+			"statx(%d,%s,%d,%u,%p) failed", dirfd, pathname, flags, mask, buf);
+	} else if (rval) {
+		tst_brk_(file, lineno, TBROK | TERRNO,
+			"Invalid statx(%d,%s,%d,%u,%p) return value %d",
+			dirfd, pathname, flags, mask, buf,
+			rval);
+	}
+
+	return rval;
+}
Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v3 1/11
#2 lore raw

Re: [LTP] [PATCH v3 01/11] Add SAFE_STATX macro

Hi,

Quoted 52 lines · On Thursday, May 16, 2024 2:29:09 PM GMT+2 Andrea Cervesato wrote:

From: Andrea Cervesato <[email protected]>

---
 include/tst_safe_macros.h |  7 +++++++
 lib/tst_safe_macros.c     | 22 ++++++++++++++++++++++
 2 files changed, 29 insertions(+)
include/tst_safe_macros.h +7 -0
index 8de8ef106..43ff50a33 100644
@@ -503,4 +503,11 @@ int safe_sscanf(const char *file, const int lineno, const char *restrict buffer,
 #define SAFE_SSCANF(buffer, format, ...) \
 	safe_sscanf(__FILE__, __LINE__, (buffer), (format),	##__VA_ARGS__)
 
+struct statx;
+int safe_statx(const char *file, const int lineno,
+	int dirfd, const char *pathname, int flags, unsigned int mask,
+	struct statx *buf);
+#define SAFE_STATX(dirfd, pathname, flags, mask, buf) \
+	safe_statx(__FILE__, __LINE__, (dirfd), (pathname), (flags), (mask), (buf))
+
 #endif /* TST_SAFE_MACROS_H__ */
lib/tst_safe_macros.c +12 -0
index 39b8cc924..f50a7bcc2 100644
@@ -20,6 +20,7 @@
 #include "tst_safe_macros.h"
 #include "lapi/personality.h"
 #include "lapi/pidfd.h"
+#include "lapi/stat.h"
 
 int safe_access(const char *file, const int lineno,
 	    const char *pathname, int mode)
@@ -710,3 +711,24 @@ int safe_mprotect(const char *file, const int lineno,
 
 	return rval;
 }
+
+int safe_statx(const char *file, const int lineno,
+	int dirfd, const char *pathname, int flags, unsigned int mask,
+	struct statx *buf)
+{
+	int rval;
+
+	rval = statx(dirfd, pathname, flags, mask, buf);
+
+	if (rval == -1) {
+		tst_brk_(file, lineno, TBROK | TERRNO,

lib/tst_safe_macros.c int safe_mprotect(const char *file, const int lineno, · line 734

Quoted 10 lines
lib/tst_safe_macros.c +10 -0
+			"statx(%d,%s,%d,%u,%p) failed", dirfd, pathname, flags, mask, buf);
+	} else if (rval) {
+		tst_brk_(file, lineno, TBROK | TERRNO,
+			"Invalid statx(%d,%s,%d,%u,%p) return value %d",
+			dirfd, pathname, flags, mask, buf,
+			rval);
+	}
+
+	return rval;
+}

Regards,
Avinesh

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw

PATCH v3 2/11 Add listmount/statmount syscalls

In reply to Andrea Cervesato

From: Andrea Cervesato <[email protected]>

---
 include/lapi/syscalls/aarch64.in   | 2 ++
 include/lapi/syscalls/arc.in       | 2 ++
 include/lapi/syscalls/arm.in       | 2 ++
 include/lapi/syscalls/hppa.in      | 2 ++
 include/lapi/syscalls/i386.in      | 2 ++
 include/lapi/syscalls/ia64.in      | 2 ++
 include/lapi/syscalls/loongarch.in | 2 ++
 include/lapi/syscalls/mips_n32.in  | 2 ++
 include/lapi/syscalls/mips_n64.in  | 2 ++
 include/lapi/syscalls/mips_o32.in  | 2 ++
 include/lapi/syscalls/powerpc.in   | 2 ++
 include/lapi/syscalls/powerpc64.in | 2 ++
 include/lapi/syscalls/s390.in      | 2 ++
 include/lapi/syscalls/s390x.in     | 2 ++
 include/lapi/syscalls/sh.in        | 2 ++
 include/lapi/syscalls/sparc.in     | 2 ++
 include/lapi/syscalls/sparc64.in   | 2 ++
 include/lapi/syscalls/x86_64.in    | 2 ++
 18 files changed, 36 insertions(+)
include/lapi/syscalls/aarch64.in +2 -0
index 2cb6c2d87..3b32a3b2a 100644
@@ -297,4 +297,6 @@ faccessat2 439
 epoll_pwait2 441
 quotactl_fd 443
 futex_waitv 449
+statmount 457
+listmount 458
 _sysctl 1078
include/lapi/syscalls/arc.in +2 -0
index 3e2ee9061..1a3a908e4 100644
@@ -317,3 +317,5 @@ faccessat2 439
 epoll_pwait2 441
 quotactl_fd 443
 futex_waitv 449
+statmount 457
+listmount 458
include/lapi/syscalls/arm.in +2 -0
index 7bdbca533..78d84549f 100644
@@ -395,3 +395,5 @@ faccessat2 (__NR_SYSCALL_BASE+439)
 epoll_pwait2 (__NR_SYSCALL_BASE+441)
 quotactl_fd (__NR_SYSCALL_BASE+443)
 futex_waitv (__NR_SYSCALL_BASE+449)
+statmount (__NR_SYSCALL_BASE+457)
+listmount (__NR_SYSCALL_BASE+458)
include/lapi/syscalls/hppa.in +2 -0
index 8ebdafafb..1f01a4a0c 100644
@@ -44,3 +44,5 @@ faccessat2 439
 epoll_pwait2 441
 quotactl_fd 443
 futex_waitv 449
+statmount 457
+listmount 458
include/lapi/syscalls/i386.in +2 -0
index 1472631c4..f4e6589ab 100644
@@ -431,3 +431,5 @@ faccessat2 439
 epoll_pwait2 441
 quotactl_fd 443
 futex_waitv 449
+statmount 457
+listmount 458
include/lapi/syscalls/ia64.in +2 -0
index 0ea6e9722..dd8b8c79f 100644
@@ -344,3 +344,5 @@ faccessat2 1463
 epoll_pwait2 1465
 quotactl_fd 1467
 futex_waitv 1473
+statmount 1481
+listmount 1482
include/lapi/syscalls/loongarch.in +2 -0
index 301f611f6..f48c0658c 100644
@@ -305,3 +305,5 @@ memfd_secret 447
 process_mrelease 448
 futex_waitv 449
 set_mempolicy_home_node 450
+statmount 457
+listmount 458
include/lapi/syscalls/mips_n32.in +2 -0
index e818c9d92..af5928c0e 100644
@@ -371,3 +371,5 @@ epoll_pwait2 6441
 mount_setattr 6442
 quotactl_fd 6443
 futex_waitv 6449
+statmount 6457
+listmount 6458
include/lapi/syscalls/mips_n64.in +2 -0
index 6e15f43b3..a6d83e2e0 100644
@@ -347,3 +347,5 @@ epoll_pwait2 5441
 mount_setattr 5442
 quotactl_fd 5443
 futex_waitv 5449
+statmount 5457
+listmount 5458
include/lapi/syscalls/mips_o32.in +2 -0
index 921d5d331..eda7388a3 100644
@@ -417,3 +417,5 @@ epoll_pwait2 4441
 mount_setattr 4442
 quotactl_fd 4443
 futex_waitv 4449
+statmount 4457
+listmount 4458
include/lapi/syscalls/powerpc.in +2 -0
index 545d9d3d6..1b40ea53d 100644
@@ -424,3 +424,5 @@ faccessat2 439
 epoll_pwait2 441
 quotactl_fd 443
 futex_waitv 449
+statmount 457
+listmount 458
include/lapi/syscalls/powerpc64.in +2 -0
index 545d9d3d6..1b40ea53d 100644
@@ -424,3 +424,5 @@ faccessat2 439
 epoll_pwait2 441
 quotactl_fd 443
 futex_waitv 449
+statmount 457
+listmount 458
include/lapi/syscalls/s390.in +2 -0
index 7213ac5f8..6593a4ff7 100644
@@ -411,3 +411,5 @@ faccessat2 439
 epoll_pwait2 441
 quotactl_fd 443
 futex_waitv 449
+statmount 457
+listmount 458
include/lapi/syscalls/s390x.in +2 -0
index 879012e2b..b98e727d6 100644
@@ -359,3 +359,5 @@ faccessat2 439
 epoll_pwait2 441
 quotactl_fd 443
 futex_waitv 449
+statmount 457
+listmount 458
include/lapi/syscalls/sh.in +2 -0
index 7d5192a27..59178113e 100644
@@ -405,3 +405,5 @@ faccessat2 439
 epoll_pwait2 441
 quotactl_fd 443
 futex_waitv 449
+statmount 457
+listmount 458
include/lapi/syscalls/sparc.in +2 -0
index 91d2fb1c2..56a244ceb 100644
@@ -410,3 +410,5 @@ faccessat2 439
 epoll_pwait2 441
 quotactl_fd 443
 futex_waitv 449
+statmount 457
+listmount 458
include/lapi/syscalls/sparc64.in +2 -0
index 1f2fc59b7..84051a600 100644
@@ -375,3 +375,5 @@ faccessat2 439
 epoll_pwait2 441
 quotactl_fd 443
 futex_waitv 449
+statmount 457
+listmount 458
include/lapi/syscalls/x86_64.in +2 -0
index dc61aa56e..935c5d7bc 100644
@@ -352,6 +352,8 @@ faccessat2 439
 epoll_pwait2 441
 quotactl_fd 443
 futex_waitv 449
+statmount 457
+listmount 458
 rt_sigaction 512
 rt_sigreturn 513
 ioctl 514
Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v3 2/11
#4 lore raw

Re: [LTP] [PATCH v3 02/11] Add listmount/statmount syscalls

Hi,

Quoted 201 lines · On Thursday, May 16, 2024 2:29:10 PM GMT+2 Andrea Cervesato wrote:

From: Andrea Cervesato <[email protected]>

---
 include/lapi/syscalls/aarch64.in   | 2 ++
 include/lapi/syscalls/arc.in       | 2 ++
 include/lapi/syscalls/arm.in       | 2 ++
 include/lapi/syscalls/hppa.in      | 2 ++
 include/lapi/syscalls/i386.in      | 2 ++
 include/lapi/syscalls/ia64.in      | 2 ++
 include/lapi/syscalls/loongarch.in | 2 ++
 include/lapi/syscalls/mips_n32.in  | 2 ++
 include/lapi/syscalls/mips_n64.in  | 2 ++
 include/lapi/syscalls/mips_o32.in  | 2 ++
 include/lapi/syscalls/powerpc.in   | 2 ++
 include/lapi/syscalls/powerpc64.in | 2 ++
 include/lapi/syscalls/s390.in      | 2 ++
 include/lapi/syscalls/s390x.in     | 2 ++
 include/lapi/syscalls/sh.in        | 2 ++
 include/lapi/syscalls/sparc.in     | 2 ++
 include/lapi/syscalls/sparc64.in   | 2 ++
 include/lapi/syscalls/x86_64.in    | 2 ++
 18 files changed, 36 insertions(+)
include/lapi/syscalls/aarch64.in +2 -0
index 2cb6c2d87..3b32a3b2a 100644
@@ -297,4 +297,6 @@ faccessat2 439
 epoll_pwait2 441
 quotactl_fd 443
 futex_waitv 449
+statmount 457
+listmount 458
 _sysctl 1078
include/lapi/syscalls/arc.in +2 -0
index 3e2ee9061..1a3a908e4 100644
@@ -317,3 +317,5 @@ faccessat2 439
 epoll_pwait2 441
 quotactl_fd 443
 futex_waitv 449
+statmount 457
+listmount 458
include/lapi/syscalls/arm.in +2 -0
index 7bdbca533..78d84549f 100644
@@ -395,3 +395,5 @@ faccessat2 (__NR_SYSCALL_BASE+439)
 epoll_pwait2 (__NR_SYSCALL_BASE+441)
 quotactl_fd (__NR_SYSCALL_BASE+443)
 futex_waitv (__NR_SYSCALL_BASE+449)
+statmount (__NR_SYSCALL_BASE+457)
+listmount (__NR_SYSCALL_BASE+458)
include/lapi/syscalls/hppa.in +2 -0
index 8ebdafafb..1f01a4a0c 100644
@@ -44,3 +44,5 @@ faccessat2 439
 epoll_pwait2 441
 quotactl_fd 443
 futex_waitv 449
+statmount 457
+listmount 458
include/lapi/syscalls/i386.in +2 -0
index 1472631c4..f4e6589ab 100644
@@ -431,3 +431,5 @@ faccessat2 439
 epoll_pwait2 441
 quotactl_fd 443
 futex_waitv 449
+statmount 457
+listmount 458
include/lapi/syscalls/ia64.in +2 -0
index 0ea6e9722..dd8b8c79f 100644
@@ -344,3 +344,5 @@ faccessat2 1463
 epoll_pwait2 1465
 quotactl_fd 1467
 futex_waitv 1473
+statmount 1481
+listmount 1482
include/lapi/syscalls/loongarch.in +2 -0
index 301f611f6..f48c0658c 100644
@@ -305,3 +305,5 @@ memfd_secret 447
 process_mrelease 448
 futex_waitv 449
 set_mempolicy_home_node 450
+statmount 457
+listmount 458
include/lapi/syscalls/mips_n32.in +2 -0
index e818c9d92..af5928c0e 100644
@@ -371,3 +371,5 @@ epoll_pwait2 6441
 mount_setattr 6442
 quotactl_fd 6443
 futex_waitv 6449
+statmount 6457
+listmount 6458
include/lapi/syscalls/mips_n64.in +2 -0
index 6e15f43b3..a6d83e2e0 100644
@@ -347,3 +347,5 @@ epoll_pwait2 5441
 mount_setattr 5442
 quotactl_fd 5443
 futex_waitv 5449
+statmount 5457
+listmount 5458
include/lapi/syscalls/mips_o32.in +2 -0
index 921d5d331..eda7388a3 100644
@@ -417,3 +417,5 @@ epoll_pwait2 4441
 mount_setattr 4442
 quotactl_fd 4443
 futex_waitv 4449
+statmount 4457
+listmount 4458
include/lapi/syscalls/powerpc.in +2 -0
index 545d9d3d6..1b40ea53d 100644
@@ -424,3 +424,5 @@ faccessat2 439
 epoll_pwait2 441
 quotactl_fd 443
 futex_waitv 449
+statmount 457
+listmount 458
include/lapi/syscalls/powerpc64.in +2 -0
index 545d9d3d6..1b40ea53d 100644
@@ -424,3 +424,5 @@ faccessat2 439
 epoll_pwait2 441
 quotactl_fd 443
 futex_waitv 449
+statmount 457
+listmount 458
include/lapi/syscalls/s390.in +2 -0
index 7213ac5f8..6593a4ff7 100644
@@ -411,3 +411,5 @@ faccessat2 439
 epoll_pwait2 441
 quotactl_fd 443
 futex_waitv 449
+statmount 457
+listmount 458
include/lapi/syscalls/s390x.in +2 -0
index 879012e2b..b98e727d6 100644
@@ -359,3 +359,5 @@ faccessat2 439
 epoll_pwait2 441
 quotactl_fd 443
 futex_waitv 449
+statmount 457
+listmount 458
include/lapi/syscalls/sh.in +2 -0
index 7d5192a27..59178113e 100644
@@ -405,3 +405,5 @@ faccessat2 439
 epoll_pwait2 441
 quotactl_fd 443
 futex_waitv 449
+statmount 457
+listmount 458
include/lapi/syscalls/sparc.in +2 -0
index 91d2fb1c2..56a244ceb 100644
@@ -410,3 +410,5 @@ faccessat2 439
 epoll_pwait2 441
 quotactl_fd 443
 futex_waitv 449
+statmount 457
+listmount 458
include/lapi/syscalls/sparc64.in +2 -0
index 1f2fc59b7..84051a600 100644
@@ -375,3 +375,5 @@ faccessat2 439
 epoll_pwait2 441
 quotactl_fd 443
 futex_waitv 449
+statmount 457
+listmount 458
include/lapi/syscalls/x86_64.in +0 -0
index dc61aa56e..935c5d7bc 100644

include/lapi/syscalls/x86_64.in faccessat2 439 · line 359

Quoted 8 lines
include/lapi/syscalls/x86_64.in +2 -0
@@ -352,6 +352,8 @@ faccessat2 439
 epoll_pwait2 441
 quotactl_fd 443
 futex_waitv 449
+statmount 457
+listmount 458
 rt_sigaction 512
 rt_sigreturn 513
 ioctl 514

Regards,
Avinesh

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#5 lore raw

PATCH v3 3/11 Add listmount/statmount fallback declarations

In reply to Andrea Cervesato

From: Andrea Cervesato <[email protected]>

---
 configure.ac         |  5 ++++
 include/lapi/mount.h | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/lapi/stat.h  | 10 +++++++-
 3 files changed, 84 insertions(+), 1 deletion(-)
configure.ac +5 -0
index 85c5739c4..80462d2f8 100644
@@ -113,6 +113,7 @@ AC_CHECK_FUNCS_ONCE([ \
     io_uring_register \
     io_uring_enter \
     kcmp \
+    listmount \
     mallinfo \
     mallinfo2 \
     mallopt \
@@ -142,6 +143,7 @@ AC_CHECK_FUNCS_ONCE([ \
     setns \
     sigpending \
     splice \
+    statmount \
     statx \
     stime \
     sync_file_range \
@@ -233,6 +235,9 @@ AC_CHECK_TYPES([struct mount_attr],,,[
 #endif
 ])
 
+AC_CHECK_TYPES([struct mnt_id_req],,,[#include <linux/mount.h>])
+AC_CHECK_TYPES([struct statmount],,,[#include <linux/mount.h>])
+
 # Tools knobs
 
 # Bash
include/lapi/mount.h +70 -0

86 lines not on this page · raw message

include/lapi/stat.h +9 -1
index 3606c9eb0..84dc76faf 100644
@@ -95,7 +95,11 @@ struct statx {
 	uint32_t	stx_dev_major;
 	uint32_t	stx_dev_minor;
 	/* 0x90 */
-	uint64_t	__spare2[14];
+	__u64	stx_mnt_id;
+	__u32	stx_dio_mem_align;
+	__u32	stx_dio_offset_align;
+	/* 0xa0 */
+	__u64	__spare3[12];
 	/* 0x100 */
 };
 #endif
@@ -229,4 +233,8 @@ static inline int statx(int dirfd, const char *pathname, unsigned int flags,
 # define STATX_ATTR_VERITY	0x00100000
 #endif
 
+#ifndef STATX_MNT_ID_UNIQUE
+# define STATX_MNT_ID_UNIQUE  0x00004000U
+#endif
+
 #endif /* LAPI_STAT_H__ */
Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#6 lore raw

Re: [LTP] [PATCH v3 03/11] Add listmount/statmount fallback declarations

Hi!

include/lapi/stat.h struct statx { · line 102

Quoted 10 lines
include/lapi/stat.h +5 -1
@@ -95,7 +95,11 @@ struct statx {
 	uint32_t	stx_dev_major;
 	uint32_t	stx_dev_minor;
 	/* 0x90 */
-	uint64_t	__spare2[14];
+	__u64	stx_mnt_id;
+	__u32	stx_dio_mem_align;
+	__u32	stx_dio_offset_align;
+	/* 0xa0 */
+	__u64	__spare3[12];

These should be the userspace variants, i.e. uint32_t and uint64_t.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#7 lore raw

PATCH v3 4/11 Add listmount01 test

In reply to Andrea Cervesato

From: Andrea Cervesato <[email protected]>

This test verifies that listmount() is properly recognizing a mounted root directory using LSMT_ROOT flag.

---
 runtest/syscalls                                  |  2 +
 testcases/kernel/syscalls/listmount/.gitignore    |  1 +
 testcases/kernel/syscalls/listmount/Makefile      |  7 +++
 testcases/kernel/syscalls/listmount/listmount.h   | 26 +++++++++
 testcases/kernel/syscalls/listmount/listmount01.c | 66 +++++++++++++++++++++++
 5 files changed, 102 insertions(+)
runtest/syscalls +2 -0
index cf06ee563..bce04c0cf 100644
@@ -706,6 +706,8 @@ linkat02 linkat02
 
 listen01 listen01
 
+listmount01 listmount01
+
 listxattr01 listxattr01
 listxattr02 listxattr02
 listxattr03 listxattr03
testcases/kernel/syscalls/listmount/.gitignore new file +1 -0
new file mode 100644
index 000000000..5257b298c
@@ -0,0 +1 @@
+listmount01
testcases/kernel/syscalls/listmount/Makefile new file +7 -0
new file mode 100644
index 000000000..8cf1b9024
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (C) 2024 SUSE LLC Andrea Cervesato <[email protected]>
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/listmount/listmount.h new file +26 -0
new file mode 100644
index 000000000..93766cd33
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2024 SUSE LLC Andrea Cervesato <[email protected]>
+ */
+
+#ifndef LISTMOUNT_H
+
+#define _GNU_SOURCE
+
+#include "tst_test.h"
+#include "lapi/mount.h"
+#include "lapi/syscalls.h"
+
+static inline ssize_t listmount(uint64_t mnt_id, uint64_t last_mnt_id,
+			 uint64_t list[], size_t num, unsigned int flags)
+{
+	struct mnt_id_req req = {
+		.size = MNT_ID_REQ_SIZE_VER0,
+		.mnt_id = mnt_id,
+		.param = last_mnt_id,
+	};
+
+	return tst_syscall(__NR_listmount, &req, list, num, flags);
+}
+
+#endif
testcases/kernel/syscalls/listmount/listmount01.c new file +66 -0

66 lines not on this page · raw message

Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#8 lore raw

Re: [LTP] [PATCH v3 04/11] Add listmount01 test

Hi!

Quoted 10 lines
testcases/kernel/syscalls/listmount/listmount01.c new file +7 -0
@@ -0,0 +1,66 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2024 SUSE LLC Andrea Cervesato <[email protected]>
+ */
+
+/*\
+ * [Description]

testcases/kernel/syscalls/listmount/listmount01.c line 17

Quoted 10 lines
testcases/kernel/syscalls/listmount/listmount01.c new file +10 -0
+ *
+ * This test verifies that listmount() is properly recognizing a mounted
+ * root directory using LSMT_ROOT flag.
+ *
+ * [Algorithm]
+ *
+ * * move into a new unshared namespace
+ * * mount() a root inside temporary folder and get its mount ID
+ * * get list of mounted IDs using listmount(LSMT_ROOT, ..)
+ * * verify that the root mount ID is the only mount ID present inside the list

Can we please use dashes here instead of asterisks? It's kind of hard to read asterisk based list inside of C comments...

Quoted 34 lines
testcases/kernel/syscalls/listmount/listmount01.c new file +34 -0
+ */
+
+#include "listmount.h"
+#include "lapi/stat.h"
+#include "lapi/sched.h"
+
+#define MNTPOINT "mntpoint"
+#define LISTSIZE 32
+
+static uint64_t root_id;
+
+static void run(void)
+{
+	uint64_t list[LISTSIZE];
+
+	TST_EXP_POSITIVE(listmount(LSMT_ROOT, 0, list, LISTSIZE, 0));
+	if (TST_RET == -1)
+		return;
+
+	TST_EXP_EQ_LI(TST_RET, 1);
+	TST_EXP_EQ_LI(list[0], root_id);
+}
+
+static void setup(void)
+{
+	struct statx sx;
+
+	SAFE_UNSHARE(CLONE_NEWNS);
+
+	SAFE_CHROOT(MNTPOINT);
+	SAFE_MOUNT("", "/", NULL, MS_REC | MS_PRIVATE, NULL);
+	SAFE_STATX(AT_FDCWD, "/", 0, STATX_MNT_ID_UNIQUE, &sx);
+
+	root_id = sx.stx_mnt_id;

testcases/kernel/syscalls/listmount/listmount01.c line 61

Quoted 10 lines
testcases/kernel/syscalls/listmount/listmount01.c new file +10 -0
+}
+
+static struct tst_test test = {
+	.test_all = run,
+	.setup = setup,
+	.forks_child = 1,
+	.min_kver = "6.8",
+	.mount_device = 1,
+	.mntpoint = MNTPOINT,
+	.all_filesystems = 1,

I do not think that this makes sense to be run for all filesystems, the listmount() syscall does not interact with any of the filesytem code at all. It just loops over a list of mount points in the namespace.

Quoted 12 lines
testcases/kernel/syscalls/listmount/listmount01.c new file +5 -0
+	.skip_filesystems = (const char *const []) {
+		"fuse",
+		NULL
+	},
+};
Signature · 6 lines
-- 
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#9 lore raw

PATCH v3 5/11 Add listmount02 test

In reply to Andrea Cervesato

From: Andrea Cervesato <[email protected]>

This test verifies that listmount() is properly reading groups of mount IDs.

---
 runtest/syscalls                                  |   1 +
 testcases/kernel/syscalls/listmount/.gitignore    |   1 +
 testcases/kernel/syscalls/listmount/listmount02.c | 106 ++++++++++++++++++++++
 3 files changed, 108 insertions(+)
runtest/syscalls +1 -0
index bce04c0cf..8831c0aec 100644
@@ -707,6 +707,7 @@ linkat02 linkat02
 listen01 listen01
 
 listmount01 listmount01
+listmount02 listmount02
 
 listxattr01 listxattr01
 listxattr02 listxattr02
testcases/kernel/syscalls/listmount/.gitignore +1 -0
index 5257b298c..30bbf9f02 100644
@@ -1 +1,2 @@
 listmount01
+listmount02
testcases/kernel/syscalls/listmount/listmount02.c new file +106 -0

106 lines not on this page · raw message

Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#10 lore raw

Re: [LTP] [PATCH v3 05/11] Add listmount02 test

Hi!

Quoted 33 lines

This test verifies that listmount() is properly reading groups of mount IDs.

---
 runtest/syscalls                                  |   1 +
 testcases/kernel/syscalls/listmount/.gitignore    |   1 +
 testcases/kernel/syscalls/listmount/listmount02.c | 106 ++++++++++++++++++++++
 3 files changed, 108 insertions(+)
runtest/syscalls +1 -0
index bce04c0cf..8831c0aec 100644
@@ -707,6 +707,7 @@ linkat02 linkat02
 listen01 listen01
 
 listmount01 listmount01
+listmount02 listmount02
 
 listxattr01 listxattr01
 listxattr02 listxattr02
testcases/kernel/syscalls/listmount/.gitignore +1 -0
index 5257b298c..30bbf9f02 100644
@@ -1 +1,2 @@
 listmount01
+listmount02
testcases/kernel/syscalls/listmount/listmount02.c new file +0 -0
new file mode 100644
index 000000000..cd742bd64

testcases/kernel/syscalls/listmount/listmount02.c line 9

Quoted 9 lines
testcases/kernel/syscalls/listmount/listmount02.c new file +9 -0
@@ -0,0 +1,106 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2024 SUSE LLC Andrea Cervesato <[email protected]>
+ */
+
+/*\
+ * [Description]
+ *
+ * This test verifies that listmount() is properly reading groups of mount IDs.

This description could be way better. The code below tests that both the oneshoot and the iterator API for listmount() return the same array. I.e. by passing non-zero as the second argument of the listmount() you ask only for the ids that are listed only after that id.

testcases/kernel/syscalls/listmount/listmount02.c line 18

Quoted 8 lines
testcases/kernel/syscalls/listmount/listmount02.c new file +8 -0
+ * [Algorithm]
+ *
+ * * move into a new unshared namespace
+ * * mount() our new root inside temporary folder
+ * * generate a full mounts tree inside root folder
+ * * read the full list of mounted IDs using listmount(LSMT_ROOT, ..)
+ * * read the list of mounted IDs using groups of fixed size
+ * * compare the first mount list with the second mount list

Here as well, dashes please.

testcases/kernel/syscalls/listmount/listmount02.c line 27

Quoted 9 lines
testcases/kernel/syscalls/listmount/listmount02.c new file +9 -0
+ */
+
+#include "listmount.h"
+#include "lapi/sched.h"
+
+#define MNTPOINT "mntpoint"
+#define BIND_MOUNTS 7
+#define GROUPS_SIZE 3
+#define LISTSIZE (1 << BIND_MOUNTS)

So each bind mount doubles the number of mounted filesystems? I suppose that we copy the whole hierarchy below the current mount point. I guess that this should be explained in the Algorithm section.

Quoted 45 lines
testcases/kernel/syscalls/listmount/listmount02.c new file +45 -0
+static void run(void)
+{
+	ssize_t ret;
+	size_t id, tot_ids, count = 0;
+	uint64_t mount_ids[LISTSIZE];
+	uint64_t list[LISTSIZE];
+
+	for (int i = 0; i < BIND_MOUNTS; i++)
+		SAFE_MOUNT("/", "/", NULL, MS_BIND, NULL);
+
+	tst_res(TINFO, "Reading all %d mount IDs in once", LISTSIZE);
+
+	TST_EXP_POSITIVE(listmount(LSMT_ROOT, 0, mount_ids, LISTSIZE, 0));
+	if (TST_RET == -1)
+		goto end;
+
+	tot_ids = (size_t)TST_RET;
+
+	if (tot_ids != LISTSIZE) {
+		tst_res(TFAIL, "listmount() returned %lu but %d was expected",
+			tot_ids, LISTSIZE);
+		goto end;
+	}
+
+	tst_res(TINFO, "Reading groups of %d mount IDs", GROUPS_SIZE);
+
+	while (count < LISTSIZE) {
+		id = count ? list[count - 1] : 0;
+		ret = listmount(LSMT_ROOT, id, list + count, GROUPS_SIZE, 0);
+
+		tst_res(TDEBUG, "listmount(LSMT_ROOT, %lu, list + %lu, %d, 0)",
+			id, count, GROUPS_SIZE);
+
+		if (ret == -1) {
+			tst_res(TFAIL, "listmount() failed with %s", tst_strerrno(errno));
+			goto end;
+		}
+
+		count += ret;
+
+		if (TST_RET < GROUPS_SIZE)
+			break;
+	}
+
+	for (size_t i = 0; i < LISTSIZE; i++) {

testcases/kernel/syscalls/listmount/listmount02.c line 83

Quoted 10 lines
testcases/kernel/syscalls/listmount/listmount02.c new file +10 -0
+		if (mount_ids[i] != list[i]) {
+			tst_res(TFAIL, "Mount ID differs at %ld index", i);
+			goto end;
+		}
+	}
+
+	tst_res(TPASS, "All mount IDs have been correctly read");
+
+end:
+	SAFE_UMOUNT("/");

Hmm, shouldn't we umount BIND_MOUNT times here?

I suppose that if we fail to umount everything that we did mount previously, the test will fail quite soon with just a few (-i) iterations, since the amount of mounts doubles with each bind mount.

Quoted 8 lines
testcases/kernel/syscalls/listmount/listmount02.c new file +8 -0
+}
+
+static void setup(void)
+{
+	SAFE_UNSHARE(CLONE_NEWNS);
+	SAFE_CHROOT(MNTPOINT);
+
+	SAFE_MOUNT("", "/", NULL, MS_REC | MS_SHARED, NULL);

testcases/kernel/syscalls/listmount/listmount02.c line 101

Quoted 10 lines
testcases/kernel/syscalls/listmount/listmount02.c new file +10 -0
+}
+
+static struct tst_test test = {
+	.test_all = run,
+	.setup = setup,
+	.forks_child = 1,
+	.min_kver = "6.8",
+	.mount_device = 1,
+	.mntpoint = MNTPOINT,
+	.all_filesystems = 1,

Again I do not think that it makes much sense to run this for all filesystems here.

Quoted 12 lines
testcases/kernel/syscalls/listmount/listmount02.c new file +5 -0
+	.skip_filesystems = (const char *const []) {
+		"fuse",
+		NULL
+	},
+};
Signature · 6 lines
-- 
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#11 lore raw

PATCH v3 6/11 Add stamount01 test

In reply to Andrea Cervesato

From: Andrea Cervesato <[email protected]>

This test verifies that statmount() is working with no mask flags.

---
 runtest/syscalls                                  |  2 +
 testcases/kernel/syscalls/statmount/.gitignore    |  1 +
 testcases/kernel/syscalls/statmount/Makefile      |  7 +++
 testcases/kernel/syscalls/statmount/statmount.h   | 26 +++++++++
 testcases/kernel/syscalls/statmount/statmount01.c | 69 +++++++++++++++++++++++
 5 files changed, 105 insertions(+)
runtest/syscalls +2 -0
index 8831c0aec..d36aebfd5 100644
@@ -1538,6 +1538,8 @@ stat03_64 stat03_64
 stat04 symlink01 -T stat04
 stat04_64 symlink01 -T stat04_64
 
+statmount01 statmount01
+
 statfs01 statfs01
 statfs01_64 statfs01_64
 statfs02 statfs02
testcases/kernel/syscalls/statmount/.gitignore new file +1 -0
new file mode 100644
index 000000000..f1529eb29
@@ -0,0 +1 @@
+statmount01
testcases/kernel/syscalls/statmount/Makefile new file +7 -0
new file mode 100644
index 000000000..8cf1b9024
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (C) 2024 SUSE LLC Andrea Cervesato <[email protected]>
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/statmount/statmount.h new file +26 -0
new file mode 100644
index 000000000..e807c8288
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2024 SUSE LLC Andrea Cervesato <[email protected]>
+ */
+
+#ifndef STATMOUNT_H
+
+#define _GNU_SOURCE
+
+#include "tst_test.h"
+#include "lapi/mount.h"
+#include "lapi/syscalls.h"
+
+static inline int statmount(uint64_t mnt_id, uint64_t mask, struct statmount *buf,
+		     size_t bufsize, unsigned int flags)
+{
+	struct mnt_id_req req = {
+		.size = MNT_ID_REQ_SIZE_VER0,
+		.mnt_id = mnt_id,
+		.param = mask,
+	};
+
+	return tst_syscall(__NR_statmount, &req, buf, bufsize, flags);
+}
+
+#endif
testcases/kernel/syscalls/statmount/statmount01.c new file +69 -0

69 lines not on this page · raw message

Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#12 lore raw

Re: [LTP] [PATCH v3 06/11] Add stamount01 test

Hi!

testcases/kernel/syscalls/statmount/statmount01.c line 36

Quoted 10 lines
testcases/kernel/syscalls/statmount/statmount01.c new file +10 -0
+static void run(void)
+{
+	memset(st_mount, 0, sizeof(struct statmount));
+
+	TST_EXP_PASS(statmount(
+		root_id,
+		0,
+		st_mount,
+		sizeof(struct statmount),
+		0));

This is a stranely formatted, but the rest of the code looks okay.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#13 lore raw

Re: [LTP] [PATCH v3 06/11] Add stamount01 test

In reply to Andrea Cervesato

Hi!

testcases/kernel/syscalls/statmount/statmount01.c line 41

Quoted 1 line
testcases/kernel/syscalls/statmount/statmount01.c new file +1 -0
+	TST_EXP_EQ_LI(st_mount->mask, 0);

And I suppose that it would make sense to check that the rest of the fields is cleared (set to zeroes as well) because if kernel does not memset() the structure to 0 it's potential information leak.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#14 lore raw

PATCH v3 7/11 Add statmount02 test

In reply to Andrea Cervesato

From: Andrea Cervesato <[email protected]>

This test verifies that statmount() is correctly reading basic filesystem info using STATMOUNT_SB_BASIC.

---
 runtest/syscalls                                  |  1 +
 testcases/kernel/syscalls/statmount/.gitignore    |  1 +
 testcases/kernel/syscalls/statmount/statmount02.c | 76 +++++++++++++++++++++++
 3 files changed, 78 insertions(+)
runtest/syscalls +1 -0
index d36aebfd5..ac6ebb51d 100644
@@ -1539,6 +1539,7 @@ stat04 symlink01 -T stat04
 stat04_64 symlink01 -T stat04_64
 
 statmount01 statmount01
+statmount02 statmount02
 
 statfs01 statfs01
 statfs01_64 statfs01_64
testcases/kernel/syscalls/statmount/.gitignore +1 -0
index f1529eb29..a30b9565f 100644
@@ -1 +1,2 @@
 statmount01
+statmount02
testcases/kernel/syscalls/statmount/statmount02.c new file +76 -0

76 lines not on this page · raw message

Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#15 lore raw

Re: [LTP] [PATCH v3 07/11] Add statmount02 test

Hi!

testcases/kernel/syscalls/statmount/statmount02.c line 49

Quoted 5 lines
testcases/kernel/syscalls/statmount/statmount02.c new file +5 -0
+	TST_EXP_EQ_LI(st_mount->mask, STATMOUNT_SB_BASIC);
+	TST_EXP_EQ_LI(st_mount->size, sizeof(struct statmount));
+	TST_EXP_EQ_LI(st_mount->sb_dev_major, sx_mount->stx_dev_major);
+	TST_EXP_EQ_LI(st_mount->sb_dev_minor, sx_mount->stx_dev_minor);
+	TST_EXP_EQ_LI(st_mount->sb_magic, sf_mount->f_type);

The basic operation also sets sb_flags, I suppose that we can pass "readonly" flag for the mount in the tst_test structure then we should see it in the sb_flags here.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#16 lore raw

PATCH v3 8/11 Add statmount03 test

In reply to Andrea Cervesato

From: Andrea Cervesato <[email protected]>

This test verifies that statmount() is correctly reading mount information (mount id, parent mount id, mount attributes etc.) using STATMOUNT_MNT_BASIC.

---
 runtest/syscalls                                  |  1 +
 testcases/kernel/syscalls/statmount/.gitignore    |  1 +
 testcases/kernel/syscalls/statmount/statmount03.c | 97 +++++++++++++++++++++++
 3 files changed, 99 insertions(+)
runtest/syscalls +1 -0
index ac6ebb51d..6eba317de 100644
@@ -1540,6 +1540,7 @@ stat04_64 symlink01 -T stat04_64
 
 statmount01 statmount01
 statmount02 statmount02
+statmount03 statmount03
 
 statfs01 statfs01
 statfs01_64 statfs01_64
testcases/kernel/syscalls/statmount/.gitignore +1 -0
index a30b9565f..2a02bf721 100644
@@ -1,2 +1,3 @@
 statmount01
 statmount02
+statmount03
testcases/kernel/syscalls/statmount/statmount03.c new file +97 -0

97 lines not on this page · raw message

Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#17 lore raw

Re: [LTP] [PATCH v3 08/11] Add statmount03 test

Hi!

Quoted 11 lines
testcases/kernel/syscalls/statmount/statmount03.c new file +11 -0
+static void run(void)
+{
+	memset(st_mount, 0, sizeof(struct statmount));
+
+	TST_EXP_PASS(statmount(
+		root_id,
+		STATMOUNT_MNT_BASIC,
+		st_mount,
+		sizeof(struct statmount),
+		0));
+

testcases/kernel/syscalls/statmount/statmount03.c line 54

Quoted 10 lines
testcases/kernel/syscalls/statmount/statmount03.c new file +10 -0
+	if (TST_RET == -1)
+		return;
+
+	TST_EXP_EQ_LI(st_mount->mask, STATMOUNT_MNT_BASIC);
+	TST_EXP_EQ_LI(st_mount->size, sizeof(struct statmount));
+	TST_EXP_EQ_LI(st_mount->mnt_id, root_id);
+	TST_EXP_EQ_LI(st_mount->mnt_id_old, root_id_old);
+	TST_EXP_EQ_LI(st_mount->mnt_parent_id, parent_id);
+	TST_EXP_EQ_LI(st_mount->mnt_parent_id_old, parent_id_old);
+	TST_EXP_EQ_LI(st_mount->mnt_propagation, MS_PRIVATE);

You are missing the mnt_master and mnt_peer_group these are I suppose set to 0 in this case. I guess that we would have bind mount the mount and make it slave to get the mnt_master set. And I'm not sure how to set the mnt group id.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#18 lore raw

PATCH v3 9/11 Add statmount04 test

In reply to Andrea Cervesato

From: Andrea Cervesato <[email protected]>

This test verifies that statmount() is correctly reading propagation from what mount in current namespace using STATMOUNT_PROPAGATE_FROM.

---
 runtest/syscalls                                  |   1 +
 testcases/kernel/syscalls/statmount/.gitignore    |   1 +
 testcases/kernel/syscalls/statmount/statmount04.c | 131 ++++++++++++++++++++++
 3 files changed, 133 insertions(+)
runtest/syscalls +1 -0
index 6eba317de..81c2f9740 100644
@@ -1541,6 +1541,7 @@ stat04_64 symlink01 -T stat04_64
 statmount01 statmount01
 statmount02 statmount02
 statmount03 statmount03
+statmount04 statmount04
 
 statfs01 statfs01
 statfs01_64 statfs01_64
testcases/kernel/syscalls/statmount/.gitignore +1 -0
index 2a02bf721..e720050b5 100644
@@ -1,3 +1,4 @@
 statmount01
 statmount02
 statmount03
+statmount04
testcases/kernel/syscalls/statmount/statmount04.c new file +131 -0

131 lines not on this page · raw message

Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#19 lore raw

Re: [LTP] [PATCH v3 09/11] Add statmount04 test

Hi!

Quoted 43 lines

This test verifies that statmount() is correctly reading propagation from what mount in current namespace using STATMOUNT_PROPAGATE_FROM.

---
 runtest/syscalls                                  |   1 +
 testcases/kernel/syscalls/statmount/.gitignore    |   1 +
 testcases/kernel/syscalls/statmount/statmount04.c | 131 ++++++++++++++++++++++
 3 files changed, 133 insertions(+)
runtest/syscalls +1 -0
index 6eba317de..81c2f9740 100644
@@ -1541,6 +1541,7 @@ stat04_64 symlink01 -T stat04_64
 statmount01 statmount01
 statmount02 statmount02
 statmount03 statmount03
+statmount04 statmount04
 
 statfs01 statfs01
 statfs01_64 statfs01_64
testcases/kernel/syscalls/statmount/.gitignore +1 -0
index 2a02bf721..e720050b5 100644
@@ -1,3 +1,4 @@
 statmount01
 statmount02
 statmount03
+statmount04
testcases/kernel/syscalls/statmount/statmount04.c new file +8 -0
new file mode 100644
index 000000000..6ca7ab4d0
@@ -0,0 +1,131 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2024 SUSE LLC Andrea Cervesato <[email protected]>
+ */
+
+/*\
+ * [Description]
+ *

testcases/kernel/syscalls/statmount/statmount04.c line 18

Quoted 10 lines
testcases/kernel/syscalls/statmount/statmount04.c new file +10 -0
+ * This test verifies that statmount() is correctly reading propagation from
+ * what mount in current namespace using STATMOUNT_PROPAGATE_FROM.
+ *
+ * [Algorithm]
+ *
+ * * create a mount point
+ * * propagate a mounted folder inside the mount point
+ * * run statmount() on the mount point using STATMOUNT_PROPAGATE_FROM
+ * * read results and check propagated_from parameter contains the propagated
+ *   folder ID

Again dashes please.

Quoted 27 lines
testcases/kernel/syscalls/statmount/statmount04.c new file +27 -0
+ */
+
+#include "statmount.h"
+#include "lapi/stat.h"
+#include "lapi/sched.h"
+#include "tst_safe_stdio.h"
+
+#define MNTPOINT "mntpoint"
+#define DIR_A MNTPOINT "/LTP_DIR_A"
+#define DIR_C_SUBFOLDER "/LTP_DIR_A/propagated"
+#define DIR_C (MNTPOINT DIR_C_SUBFOLDER)
+#define DIR_B MNTPOINT "/LTP_DIR_B"
+#define DIR_D MNTPOINT "/LTP_DIR_B/propagated"
+
+static uint64_t peer_group_id;
+static uint64_t dird_id;
+static struct statmount *st_mount;
+
+static int read_peer_group(void)
+{
+	FILE *file;
+	char line[PATH_MAX];
+	char mroot[PATH_MAX];
+	int group = -1;
+
+	file = SAFE_FOPEN("/proc/self/mountinfo", "r");
+

testcases/kernel/syscalls/statmount/statmount04.c line 55

Quoted 10 lines
testcases/kernel/syscalls/statmount/statmount04.c new file +10 -0
+	while (fgets(line, sizeof(line), file)) {
+		if (sscanf(line, "%*d %*d %*d:%*d %s %*s %*s shared:%d", mroot, &group) != 2)
+			continue;
+
+		if (strcmp(mroot, DIR_C_SUBFOLDER) == 0)
+			break;
+	}
+
+	if (group == -1)
+		tst_brk(TBROK, "Can't reed peer group ID for %s", DIR_C_SUBFOLDER);
                                        ^
					read

Also I'm wondering if we simply cannot call statmount() to get basic info for DIR_C_SUBFOLDER and get the group id from there instead of parsing proc.

testcases/kernel/syscalls/statmount/statmount04.c line 69

Quoted 13 lines
testcases/kernel/syscalls/statmount/statmount04.c new file +13 -0
+	return group;
+}
+
+static void run(void)
+{
+	memset(st_mount, 0, sizeof(struct statmount));
+
+	TST_EXP_PASS(statmount(
+		dird_id,
+		STATMOUNT_PROPAGATE_FROM,
+		st_mount,
+		sizeof(struct statmount),
+		0));

Here as well, strange formatting.

Quoted 32 lines
testcases/kernel/syscalls/statmount/statmount04.c new file +32 -0
+	if (TST_RET == -1)
+		return;
+
+	TST_EXP_EQ_LI(st_mount->mask, STATMOUNT_PROPAGATE_FROM);
+	TST_EXP_EQ_LI(st_mount->size, sizeof(struct statmount));
+	TST_EXP_EQ_LI(st_mount->propagate_from, peer_group_id);
+}
+
+static void setup(void)
+{
+	struct statx sx;
+
+	/* create DIR_A / DIR_C structure with DIR_C mounted */
+	SAFE_MKDIR(DIR_A, 0700);
+	SAFE_MOUNT(DIR_A, DIR_A, "none", MS_BIND, NULL);
+	SAFE_MOUNT("none", DIR_A, "none", MS_SHARED, NULL);
+
+	SAFE_MKDIR(DIR_C, 0700);
+	SAFE_MOUNT(DIR_C, DIR_C, "none", MS_BIND, NULL);
+	SAFE_MOUNT("none", DIR_C, "none", MS_SHARED, NULL);
+
+	/* DIR_A mounts into DIR_B. DIR_D is propagated */
+	SAFE_MKDIR(DIR_B, 0700);
+	SAFE_MOUNT(DIR_A, DIR_B, "none", MS_BIND, NULL);
+	SAFE_MOUNT("none", DIR_B, "none", MS_SLAVE, NULL);
+
+	SAFE_STATX(AT_FDCWD, DIR_D, 0, STATX_MNT_ID_UNIQUE, &sx);
+	dird_id = sx.stx_mnt_id;
+
+	peer_group_id = read_peer_group();
+}
+

testcases/kernel/syscalls/statmount/statmount04.c line 112

Quoted 10 lines
testcases/kernel/syscalls/statmount/statmount04.c new file +10 -0
+static void cleanup(void)
+{
+	if (tst_is_mounted(DIR_C))
+		SAFE_UMOUNT(DIR_C);
+
+	if (tst_is_mounted(DIR_B))
+		SAFE_UMOUNT(DIR_B);
+
+	if (tst_is_mounted(DIR_A))
+		SAFE_UMOUNT(DIR_A);

Again I wouldn't bet that umounting once is enough here. If my mental image is right we have stacked several mounts on each directory.

I wonder how many cycled would this code do?

	while (tst_is_mounted(DIR_A))
		SAFE_UMOUNT(DIR_A);
Quoted 26 lines
testcases/kernel/syscalls/statmount/statmount04.c new file +19 -0
+}
+
+static struct tst_test test = {
+	.test_all = run,
+	.setup = setup,
+	.cleanup = cleanup,
+	.min_kver = "6.8",
+	.mount_device = 1,
+	.mntpoint = MNTPOINT,
+	.all_filesystems = 1,
+	.skip_filesystems = (const char *const []) {
+		"fuse",
+		NULL
+	},
+	.bufs = (struct tst_buffers []) {
+		{&st_mount, .size = sizeof(struct statmount)},
+		{}
+	}
+};
Signature · 6 lines
-- 
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#20 lore raw

Re: [LTP] [PATCH v3 09/11] Add statmount04 test

Hi!

Quoted 14 lines

testcases/kernel/syscalls/statmount/statmount04.c line 112

Quoted 10 lines
testcases/kernel/syscalls/statmount/statmount04.c new file +10 -0
+static void cleanup(void)
+{
+	if (tst_is_mounted(DIR_C))
+		SAFE_UMOUNT(DIR_C);
+
+	if (tst_is_mounted(DIR_B))
+		SAFE_UMOUNT(DIR_B);
+
+	if (tst_is_mounted(DIR_A))
+		SAFE_UMOUNT(DIR_A);

Again I wouldn't bet that umounting once is enough here. If my mental image is right we have stacked several mounts on each directory.

Quoted 4 lines

I wonder how many cycled would this code do?

	while (tst_is_mounted(DIR_A))
		SAFE_UMOUNT(DIR_A);

Scratch that, we are bind mounting only once, so it should be correct.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#21 lore raw

PATCH v3 10/11 Add statmount05 test

In reply to Andrea Cervesato

From: Andrea Cervesato <[email protected]>

This test verifies STATMOUNT_MNT_ROOT and STATMOUNT_MNT_POINT functionalities of statmount().

---
 runtest/syscalls                                  |   1 +
 testcases/kernel/syscalls/statmount/.gitignore    |   1 +
 testcases/kernel/syscalls/statmount/statmount05.c | 136 ++++++++++++++++++++++
 3 files changed, 138 insertions(+)
runtest/syscalls +1 -0
index 81c2f9740..b04aabc6f 100644
@@ -1542,6 +1542,7 @@ statmount01 statmount01
 statmount02 statmount02
 statmount03 statmount03
 statmount04 statmount04
+statmount05 statmount05
 
 statfs01 statfs01
 statfs01_64 statfs01_64
testcases/kernel/syscalls/statmount/.gitignore +1 -0
index e720050b5..f64763242 100644
@@ -2,3 +2,4 @@ statmount01
 statmount02
 statmount03
 statmount04
+statmount05
testcases/kernel/syscalls/statmount/statmount05.c new file +136 -0

136 lines not on this page · raw message

Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#22 lore raw

Re: [LTP] [PATCH v3 10/11] Add statmount05 test

Hi!
This one looks fine, minus the minor stuff as everywhere else.

Also the statmount() is again missing the invalid testcases, e.g. non-zero flags, invalid (too small) size, invalid flags, invalid buf pointer...

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#23 lore raw

PATCH v3 11/11 Add statmount06 test

In reply to Andrea Cervesato

From: Andrea Cervesato <[email protected]>

This test verifies that statmount() is correctly reading name of the filesystem type using STATMOUNT_FS_TYPE.

---
 runtest/syscalls                                  |  1 +
 testcases/kernel/syscalls/statmount/.gitignore    |  1 +
 testcases/kernel/syscalls/statmount/statmount06.c | 72 +++++++++++++++++++++++
 3 files changed, 74 insertions(+)
runtest/syscalls +1 -0
index b04aabc6f..a3546b155 100644
@@ -1543,6 +1543,7 @@ statmount02 statmount02
 statmount03 statmount03
 statmount04 statmount04
 statmount05 statmount05
+statmount06 statmount06
 
 statfs01 statfs01
 statfs01_64 statfs01_64
testcases/kernel/syscalls/statmount/.gitignore +1 -0
index f64763242..03a75bd40 100644
@@ -3,3 +3,4 @@ statmount02
 statmount03
 statmount04
 statmount05
+statmount06
testcases/kernel/syscalls/statmount/statmount06.c new file +72 -0

72 lines not on this page · raw message

Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#24 lore raw

Re: [LTP] [PATCH v3 11/11] Add statmount06 test

Hi!

Quoted 36 lines
testcases/kernel/syscalls/statmount/statmount06.c new file +36 -0
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2024 SUSE LLC Andrea Cervesato <[email protected]>
+ */
+
+/*\
+ * [Description]
+ *
+ * This test verifies that statmount() is correctly reading name of the
+ * filesystem type using STATMOUNT_FS_TYPE.
+ *
+ * [Algorithm]
+ *
+ * * create a mount point
+ * * run statmount() on the mount point using STATMOUNT_FS_TYPE
+ * * read results and check if contain the name of the filesystem
+ */
+
+#include "statmount.h"
+#include "lapi/stat.h"
+#include "lapi/sched.h"
+
+#define MNTPOINT "mntpoint"
+#define SM_SIZE (1 << 10)
+
+static uint64_t root_id;
+static struct statmount *st_mount;
+
+static void run(void)
+{
+	memset(st_mount, 0, SM_SIZE);
+
+	TST_EXP_PASS(statmount(
+		root_id,
+		STATMOUNT_FS_TYPE,
+		st_mount,

testcases/kernel/syscalls/statmount/statmount06.c line 46

Quoted 10 lines
testcases/kernel/syscalls/statmount/statmount06.c new file +10 -0
+		SM_SIZE,
+		0));
+
+	if (TST_RET == -1)
+		return;
+
+	TST_EXP_EQ_LI(st_mount->mask, STATMOUNT_FS_TYPE);
+	TST_EXP_EXPR(strcmp(st_mount->str + st_mount->fs_type, tst_device->fs_type) == 0,
+		"statmount() read '%s', expected '%s'",
+		st_mount->str + st_mount->fs_type, tst_device->fs_type);

This starts to be a common pattern, I guess that we need TST_EXP_STR_EQ()...

Quoted 33 lines
testcases/kernel/syscalls/statmount/statmount06.c new file +26 -0
+}
+
+static void setup(void)
+{
+	struct statx sx;
+
+	SAFE_STATX(AT_FDCWD, MNTPOINT, 0, STATX_MNT_ID_UNIQUE, &sx);
+	root_id = sx.stx_mnt_id;
+}
+
+static struct tst_test test = {
+	.test_all = run,
+	.setup = setup,
+	.min_kver = "6.8",
+	.mount_device = 1,
+	.mntpoint = MNTPOINT,
+	.all_filesystems = 1,
+	.skip_filesystems = (const char *const []) {
+		"fuse",
+		NULL
+	},
+	.bufs = (struct tst_buffers []) {
+		{&st_mount, .size = SM_SIZE},
+		{}
+	}
+};
Signature · 6 lines
-- 
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 5 lines
Cyril Hrubis
[email protected]

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