Skip to contentSkip to conversation

statmount/listmount testing suites

PATCH In review Andrea Cervesato 3 participants 21 messages Oct 9, 2024 Arm STM32

lore
Share & tools
lore
#0 lore raw

v8 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

---
Changes in v8:
- simplify statx fallback
- fix fchmodat2_01 which is not compiling due to statx fallback changes
- listmount04: remove zero attributes in the tcase struct
- Link to v7: https://lore.kernel.org/r/[email protected]

Changes in v7:
- fix statmount01
- add more EOVERFLOW tests in statmount07
- add more invalid tests in listmount04
- Link to v6: https://lore.kernel.org/r/[email protected]

Changes in v6:
- fix statmount01
- add more EOVERFLOW tests in statmount06
- Link to v5: https://lore.kernel.org/r/[email protected]

Changes in v5:
- usage of sx.data.stx_mask
- use TST_EXP_EQ_STR
- use tst_tmpdir_genpath()
- use !TST_PASS instead of TST_RET == -1
- listmount03
- listmount04
- statmount08
- Link to v4: https://lore.kernel.org/r/[email protected]

Changes in v4:
- listmount01: remove all filesystems run
- listmount02: better descriptions and proper unmount()
- statmount01: check all fields are zeroed
- statmount02: check also readonly flag
- statmount03: now it checks for all mount flags
- statmount04: moved read_peer_group inside statmount.h
- statmount07: add test for invalid values
- generic style fixes
- fix statx import
- Link to v3: https://lore.kernel.org/r/[email protected]

---
Andrea Cervesato (16):
Add SAFE_STATX macro
Add TST_EXP_EQ_STR macro
Add listmount/statmount syscalls
Add listmount/statmount fallback declarations Add listmount01 test
Add listmount02 test
Add statmount01 test
Add statmount02 test
Add statmount03 test
Add statmount04 test
Add statmount05 test
Add statmount06 test
Add statmount07 test
Add statmount08 test
Add listmount03 test
Add listmount04 test

 configure.ac                                       |   2 +
 include/lapi/mount.h                               |  70 ++++++++++
 include/lapi/stat.h                                | 107 ++++++++++-----
 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_test_macros.h                          |  14 ++
 runtest/syscalls                                   |  14 ++
 testcases/kernel/syscalls/fchmodat2/fchmodat2_01.c |   2 +
 testcases/kernel/syscalls/listmount/.gitignore     |   4 +
 testcases/kernel/syscalls/listmount/Makefile       |   7 +
 testcases/kernel/syscalls/listmount/listmount.h    |  27 ++++
 testcases/kernel/syscalls/listmount/listmount01.c  |  63 +++++++++
 testcases/kernel/syscalls/listmount/listmount02.c  | 105 +++++++++++++++
 testcases/kernel/syscalls/listmount/listmount03.c  |  62 +++++++++
 testcases/kernel/syscalls/listmount/listmount04.c  | 143 ++++++++++++++++++++
 testcases/kernel/syscalls/statmount/.gitignore     |   8 ++
 testcases/kernel/syscalls/statmount/Makefile       |   7 +
 testcases/kernel/syscalls/statmount/statmount.h    |  51 ++++++++
 testcases/kernel/syscalls/statmount/statmount01.c  |  77 +++++++++++
 testcases/kernel/syscalls/statmount/statmount02.c  |  84 ++++++++++++
 testcases/kernel/syscalls/statmount/statmount03.c  | 138 ++++++++++++++++++++
 testcases/kernel/syscalls/statmount/statmount04.c  | 105 +++++++++++++++
 testcases/kernel/syscalls/statmount/statmount05.c  | 123 ++++++++++++++++++
 testcases/kernel/syscalls/statmount/statmount06.c  |  68 ++++++++++
 testcases/kernel/syscalls/statmount/statmount07.c  | 144 +++++++++++++++++++++
 testcases/kernel/syscalls/statmount/statmount08.c  |  65 ++++++++++
 42 files changed, 1494 insertions(+), 32 deletions(-)

---
base-commit: 701212f08d6e850457cc2b10238f28662ef48471
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 v8 1/16 Add SAFE_STATX macro

From: Andrea Cervesato <[email protected]>

---
 include/lapi/stat.h                                | 107 +++++++++++++++------
 testcases/kernel/syscalls/fchmodat2/fchmodat2_01.c |   2 +
 2 files changed, 77 insertions(+), 32 deletions(-)
include/lapi/stat.h +75 -32
index 030646a9e..17b62ea98 100644
@@ -30,6 +30,7 @@ struct statx_timestamp {
 	int32_t __reserved;
 };
 #endif
+
 /*
  * Structures for the extended file attribute retrieval system call
  * (statx()).
@@ -67,39 +68,53 @@ struct statx_timestamp {
  * will have values installed for compatibility purposes so that stat() and
  * co. can be emulated in userspace.
  */
-#ifndef HAVE_STRUCT_STATX
-struct statx {
-	/* 0x00 */
-	uint32_t	stx_mask;
-	uint32_t	stx_blksize;
-	uint64_t	stx_attributes;
-	/* 0x10 */
-	uint32_t	stx_nlink;
-	uint32_t	stx_uid;
-	uint32_t	stx_gid;
-	uint16_t	stx_mode;
-	uint16_t	__spare0[1];
-	/* 0x20 */
-	uint64_t	stx_ino;
-	uint64_t	stx_size;
-	uint64_t	stx_blocks;
-	uint64_t	stx_attributes_mask;
-	/* 0x40 */
-	const struct statx_timestamp	stx_atime;
-	const struct statx_timestamp	stx_btime;
-	const struct statx_timestamp	stx_ctime;
-	const struct statx_timestamp	stx_mtime;
-	/* 0x80 */
-	uint32_t	stx_rdev_major;
-	uint32_t	stx_rdev_minor;
-	uint32_t	stx_dev_major;
-	uint32_t	stx_dev_minor;
-	/* 0x90 */
-	uint64_t	__spare2[14];
-	/* 0x100 */
+ #define LTP_DEFINE_STATX_STRUCT(x) \
+ 	struct x { \
+	uint32_t	stx_mask; \
+	uint32_t	stx_blksize; \
+	uint64_t	stx_attributes; \
+	uint32_t	stx_nlink; \
+	uint32_t	stx_uid; \
+	uint32_t	stx_gid; \
+	uint16_t	stx_mode; \
+	uint16_t	__spare0[1]; \
+	uint64_t	stx_ino; \
+	uint64_t	stx_size; \
+	uint64_t	stx_blocks; \
+	uint64_t	stx_attributes_mask; \
+	const struct statx_timestamp	stx_atime; \
+	const struct statx_timestamp	stx_btime; \
+	const struct statx_timestamp	stx_ctime; \
+	const struct statx_timestamp	stx_mtime; \
+	uint32_t	stx_rdev_major; \
+	uint32_t	stx_rdev_minor; \
+	uint32_t	stx_dev_major; \
+	uint32_t	stx_dev_minor; \
+	uint64_t	stx_mnt_id; \
+	uint32_t	stx_dio_mem_align; \
+	uint32_t	stx_dio_offset_align; \
+	uint64_t	__spare3[12]; \
 };
+
+LTP_DEFINE_STATX_STRUCT(statx_fallback);
+
+#ifndef HAVE_STRUCT_STATX
+LTP_DEFINE_STATX_STRUCT(statx);
 #endif
 
+/*
+ * This is the fallback statx that we pass to the safe_statx() syscall.
+ * The reason why we need it, is that statx struct is constantly changing
+ * inside the kernel and we need to extend its definition when structure
+ * changes in order to compile the tests.
+ */
+struct ltp_statx {
+	union {
+		struct statx buff;
+		struct statx_fallback data;
+	};
+};
+
 #ifndef HAVE_STATX
 
 /*
@@ -108,9 +123,9 @@ struct statx {
  * Returns: It returns status of statx syscall
  */
 static inline int statx(int dirfd, const char *pathname, unsigned int flags,
-			unsigned int mask, struct statx *statxbuf)
+			unsigned int mask, struct statx *st)
 {
-	return tst_syscall(__NR_statx, dirfd, pathname, flags, mask, statxbuf);
+	return tst_syscall(__NR_statx, dirfd, pathname, flags, mask, st);
 }
 #endif
 
@@ -229,6 +244,10 @@ 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
+
 #define SAFE_FCHMODAT2(dfd, filename, mode, flags) \
 	safe_fchmodat2(__FILE__, __LINE__, (dfd), (filename), (mode), (flags))
 
@@ -251,4 +270,28 @@ static inline int safe_fchmodat2(const char *file, const int lineno,
 	return ret;
 }
 
+#define SAFE_STATX(dirfd, pathname, flags, mask, buf) \
+	safe_statx(__FILE__, __LINE__, (dirfd), (pathname), (flags), (mask), (buf))
+
+static inline int safe_statx(const char *file, const int lineno,
+	int dirfd, const char *pathname, int flags, unsigned int mask,
+	struct ltp_statx *buf)
+{
+	int rval;
+
+	rval = statx(dirfd, pathname, flags, mask, &buf->buff);
+
+	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;
+}
+
 #endif /* LAPI_STAT_H__ */
testcases/kernel/syscalls/fchmodat2/fchmodat2_01.c +2 -0
index a9932287c..f026b18df 100644
@@ -12,6 +12,8 @@
  * usage on symlinks will raise EOPNOTSUPP.
  */
 
+#define _GNU_SOURCE
+
 #include "tst_test.h"
 #include "tst_safe_file_at.h"
 #include "lapi/fcntl.h"
Signature · 5 lines
2.43.0


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

Re: [LTP] [PATCH v8 01/16] Add SAFE_STATX macro

Hi,

I'm going to push the patches since this is the last reviewed file. That's ok?

Andrea

Quoted 3 lines · Cyril Hrubis

Hi!

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

Re: [LTP] [PATCH v8 01/16] Add SAFE_STATX macro

Hi!

Quoted 2 lines

I'm going to push the patches since this is the last reviewed file. That's ok?

Yes please. Also thanks for the good work.

Signature · 5 lines
Cyril Hrubis
[email protected]

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

Re: [LTP] [PATCH v8 01/16] Add SAFE_STATX macro

Pushed, thanks for the patience. It was a long suite.

Andrea

Quoted 5 lines · Cyril Hrubis

Hi!

Quoted 2 lines

I'm going to push the patches since this is the last reviewed file. That's ok?

Yes please. Also thanks for the good work.

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

PATCH v8 2/16 Add TST_EXP_EQ_STR macro

In reply to Andrea Cervesato

From: Andrea Cervesato <[email protected]>

---
 include/tst_test_macros.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
include/tst_test_macros.h +14 -0
index c02ad38f9..b2ca32f77 100644
@@ -411,4 +411,18 @@ const char *tst_errno_names(char *buf, const int *exp_errs, int exp_errs_cnt);
 #define TST_EXP_EQ_SSZ_SILENT(VAL_A, VAL_B) \
 	TST_EXP_EQ_SILENT_(VAL_A, #VAL_A, VAL_B, #VAL_B, ssize_t, "%zi")
 
+#define TST_EXP_EQ_STR(STR_A, STR_B) do {                                      \
+	TST_PASS = strcmp(STR_A, STR_B) == 0;                                  \
+                                                                               \
+	if (TST_PASS) {                                                        \
+		tst_res_(__FILE__, __LINE__, TPASS,                            \
+			"%s == %s (%s)",                                       \
+			#STR_A, #STR_B, STR_B);                                \
+	} else {                                                               \
+		tst_res_(__FILE__, __LINE__, TFAIL,                            \
+			"%s (%s) != %s (%s)",                                  \
+			#STR_A, STR_A, #STR_B, STR_B);                         \
+	}                                                                      \
+} while (0)
+
 #endif	/* TST_TEST_MACROS_H__ */
Signature · 5 lines
2.43.0


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

PATCH v8 3/16 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 61d4450bf..c184f5710 100644
@@ -303,4 +303,6 @@ futex_waitv 449
 cachestat 451
 fchmodat2 452
 mseal 462
+statmount 457
+listmount 458
 _sysctl 1078
include/lapi/syscalls/arc.in +2 -0
index 752cc54fd..ff58f1be2 100644
@@ -323,3 +323,5 @@ futex_waitv 449
 cachestat 451
 fchmodat2 452
 mseal 462
+statmount 457
+listmount 458
include/lapi/syscalls/arm.in +2 -0
index 84203ca4d..ff1415f52 100644
@@ -402,3 +402,5 @@ futex_waitv (__NR_SYSCALL_BASE+449)
 cachestat (__NR_SYSCALL_BASE+451)
 fchmodat2 (__NR_SYSCALL_BASE+452)
 mseal (__NR_SYSCALL_BASE+462)
+statmount (__NR_SYSCALL_BASE+457)
+listmount (__NR_SYSCALL_BASE+458)
include/lapi/syscalls/hppa.in +2 -0
index 8240c69ce..ac6cd691d 100644
@@ -50,3 +50,5 @@ futex_waitv 449
 cachestat 451
 fchmodat2 452
 mseal 462
+statmount 457
+listmount 458
include/lapi/syscalls/i386.in +2 -0
index f6e8c7258..d2f8c295d 100644
@@ -437,3 +437,5 @@ futex_waitv 449
 cachestat 451
 fchmodat2 452
 mseal 462
+statmount 457
+listmount 458
include/lapi/syscalls/ia64.in +2 -0
index 8f55029a9..cd770bace 100644
@@ -350,3 +350,5 @@ futex_waitv 1473
 cachestat 1475
 fchmodat2 1476
 mseal 1486
+statmount 1481
+listmount 1482
include/lapi/syscalls/loongarch.in +2 -0
index 3df354fce..7e40e01bf 100644
@@ -308,3 +308,5 @@ set_mempolicy_home_node 450
 cachestat 451
 fchmodat2 452
 mseal 462
+statmount 457
+listmount 458
include/lapi/syscalls/mips_n32.in +2 -0
index d85c567c7..1c64e9ab4 100644
@@ -377,3 +377,5 @@ futex_waitv 6449
 cachestat 6451
 fchmodat2 6452
 mseal 6462
+statmount 6457
+listmount 6458
include/lapi/syscalls/mips_n64.in +2 -0
index c34a85bbe..e3895b1ea 100644
@@ -353,3 +353,5 @@ futex_waitv 5449
 cachestat 5451
 fchmodat2 5452
 mseal 5462
+statmount 5457
+listmount 5458
include/lapi/syscalls/mips_o32.in +2 -0
index 10d77787b..043747da7 100644
@@ -423,3 +423,5 @@ futex_waitv 4449
 cachestat 4451
 fchmodat2 4452
 mseal 4462
+statmount 4457
+listmount 4458
include/lapi/syscalls/powerpc.in +2 -0
index af3ae5c90..a3b8fdabf 100644
@@ -430,3 +430,5 @@ futex_waitv 449
 cachestat 451
 fchmodat2 452
 mseal 462
+statmount 457
+listmount 458
include/lapi/syscalls/powerpc64.in +2 -0
index af3ae5c90..a3b8fdabf 100644
@@ -430,3 +430,5 @@ futex_waitv 449
 cachestat 451
 fchmodat2 452
 mseal 462
+statmount 457
+listmount 458
include/lapi/syscalls/s390.in +2 -0
index e8e7fff0b..bf55073d6 100644
@@ -417,3 +417,5 @@ futex_waitv 449
 cachestat 451
 fchmodat2 452
 mseal 462
+statmount 457
+listmount 458
include/lapi/syscalls/s390x.in +2 -0
index 0ee3bd897..d11e22bd3 100644
@@ -365,3 +365,5 @@ futex_waitv 449
 cachestat 451
 fchmodat2 452
 mseal 462
+statmount 457
+listmount 458
include/lapi/syscalls/sh.in +2 -0
index 5701f2285..67cf85d50 100644
@@ -411,3 +411,5 @@ futex_waitv 449
 cachestat 451
 fchmodat2 452
 mseal 462
+statmount 457
+listmount 458
include/lapi/syscalls/sparc.in +2 -0
index 172969f60..56e275f74 100644
@@ -416,3 +416,5 @@ futex_waitv 449
 cachestat 451
 fchmodat2 452
 mseal 462
+statmount 457
+listmount 458
include/lapi/syscalls/sparc64.in +2 -0
index 5b667f10f..cfe221919 100644
@@ -381,3 +381,5 @@ futex_waitv 449
 cachestat 451
 fchmodat2 452
 mseal 462
+statmount 457
+listmount 458
include/lapi/syscalls/x86_64.in +2 -0
index 1993f343a..8919487c8 100644
@@ -358,6 +358,8 @@ futex_waitv 449
 cachestat 451
 fchmodat2 452
 mseal 462
+statmount 457
+listmount 458
 rt_sigaction 512
 rt_sigreturn 513
 ioctl 514
Signature · 5 lines
2.43.0


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

PATCH v8 4/16 Add listmount/statmount fallback declarations

In reply to Andrea Cervesato

From: Andrea Cervesato <[email protected]>

---
 configure.ac         |  2 ++
 include/lapi/mount.h | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 72 insertions(+)
configure.ac +2 -0
index ebbf49e28..b4ab81e26 100644
@@ -246,6 +246,8 @@ AC_CHECK_TYPES([struct mount_attr],,,[
 
 AC_CHECK_TYPES([struct cachestat_range],,,[#include <sys/mman.h>])
 AC_CHECK_TYPES([struct cachestat],,,[#include <sys/mman.h>])
+AC_CHECK_TYPES([struct mnt_id_req],,,[#include <linux/mount.h>])
+AC_CHECK_TYPES([struct statmount],,,[#include <linux/mount.h>])
 
 # Tools knobs
 
include/lapi/mount.h +70 -0

86 lines not on this page · raw message

Signature · 5 lines
2.43.0


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

PATCH v8 5/16 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   | 27 ++++++++++
 testcases/kernel/syscalls/listmount/listmount01.c | 63 +++++++++++++++++++++++
 5 files changed, 100 insertions(+)
runtest/syscalls +2 -0
index 02e721df9..09e3025a6 100644
@@ -731,6 +731,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 +27 -0
new file mode 100644
index 000000000..aad927f71
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2024 SUSE LLC Andrea Cervesato <[email protected]>
+ */
+
+#ifndef LISTMOUNT_H
+#define 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 +63 -0

63 lines not on this page · raw message

Signature · 5 lines
2.43.0


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

PATCH v8 6/16 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 | 105 ++++++++++++++++++++++
 3 files changed, 107 insertions(+)
runtest/syscalls +1 -0
index 09e3025a6..564066b2b 100644
@@ -732,6 +732,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 +105 -0

105 lines not on this page · raw message

Signature · 5 lines
2.43.0


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

PATCH v8 7/16 Add statmount01 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   | 27 ++++++++
 testcases/kernel/syscalls/statmount/statmount01.c | 77 +++++++++++++++++++++++
 5 files changed, 114 insertions(+)
runtest/syscalls +2 -0
index 564066b2b..677d797f8 100644
@@ -1574,6 +1574,8 @@ stat03_64 stat03_64
 stat04 stat04
 stat04_64 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 +27 -0
new file mode 100644
index 000000000..cb0fd1cca
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2024 SUSE LLC Andrea Cervesato <[email protected]>
+ */
+
+#ifndef STATMOUNT_H
+#define 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 +77 -0

77 lines not on this page · raw message

Signature · 5 lines
2.43.0


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

PATCH v8 8/16 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 | 84 +++++++++++++++++++++++
 3 files changed, 86 insertions(+)
runtest/syscalls +1 -0
index 677d797f8..c6c31c546 100644
@@ -1575,6 +1575,7 @@ stat04 stat04
 stat04_64 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 +84 -0

84 lines not on this page · raw message

Signature · 5 lines
2.43.0


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

PATCH v8 9/16 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/statmount.h   |  24 ++++
 testcases/kernel/syscalls/statmount/statmount03.c | 138 ++++++++++++++++++++++
 4 files changed, 164 insertions(+)
runtest/syscalls +1 -0
index c6c31c546..47ca26213 100644
@@ -1576,6 +1576,7 @@ stat04_64 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/statmount.h +24 -0
index cb0fd1cca..d21d7f8da 100644
@@ -11,6 +11,7 @@
 #include "tst_test.h"
 #include "lapi/mount.h"
 #include "lapi/syscalls.h"
+#include "tst_safe_stdio.h"
 
 static inline int statmount(uint64_t mnt_id, uint64_t mask, struct statmount *buf,
 		     size_t bufsize, unsigned int flags)
@@ -24,4 +25,27 @@ static inline int statmount(uint64_t mnt_id, uint64_t mask, struct statmount *bu
 	return tst_syscall(__NR_statmount, &req, buf, bufsize, flags);
 }
 
+static inline int read_peer_group(const char *path)
+{
+	FILE *file;
+	char line[PATH_MAX];
+	char mroot[PATH_MAX];
+	int group = -1;
+
+	file = SAFE_FOPEN("/proc/self/mountinfo", "r");
+
+	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, path) == 0)
+			break;
+	}
+
+	if (group == -1)
+		tst_brk(TBROK, "Can't reed peer group ID for %s", path);
+
+	return group;
+}
+
 #endif
testcases/kernel/syscalls/statmount/statmount03.c new file +138 -0

138 lines not on this page · raw message

Signature · 5 lines
2.43.0


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

PATCH v8 10/16 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 | 105 ++++++++++++++++++++++
 3 files changed, 107 insertions(+)
runtest/syscalls +1 -0
index 47ca26213..452ac1ac9 100644
@@ -1577,6 +1577,7 @@ stat04_64 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 +105 -0

105 lines not on this page · raw message

Signature · 5 lines
2.43.0


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

PATCH v8 11/16 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 | 123 ++++++++++++++++++++++
 3 files changed, 125 insertions(+)
runtest/syscalls +1 -0
index 452ac1ac9..97c7049a2 100644
@@ -1578,6 +1578,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 +123 -0

123 lines not on this page · raw message

Signature · 5 lines
2.43.0


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

PATCH v8 12/16 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 | 68 +++++++++++++++++++++++
 3 files changed, 70 insertions(+)
runtest/syscalls +1 -0
index 97c7049a2..a742e405b 100644
@@ -1579,6 +1579,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 +68 -0

68 lines not on this page · raw message

Signature · 5 lines
2.43.0


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

PATCH v8 13/16 Add statmount07 test

In reply to Andrea Cervesato

From: Andrea Cervesato <[email protected]>

This test is verifying that statmount syscall is raising the correct errors according with invalid input values.

---
 runtest/syscalls                                  |   1 +
 testcases/kernel/syscalls/statmount/.gitignore    |   1 +
 testcases/kernel/syscalls/statmount/statmount07.c | 144 ++++++++++++++++++++++
 3 files changed, 146 insertions(+)
runtest/syscalls +1 -0
index a742e405b..bf222e466 100644
@@ -1580,6 +1580,7 @@ statmount03 statmount03
 statmount04 statmount04
 statmount05 statmount05
 statmount06 statmount06
+statmount07 statmount07
 
 statfs01 statfs01
 statfs01_64 statfs01_64
testcases/kernel/syscalls/statmount/.gitignore +1 -0
index 03a75bd40..b2a55c077 100644
@@ -4,3 +4,4 @@ statmount03
 statmount04
 statmount05
 statmount06
+statmount07
testcases/kernel/syscalls/statmount/statmount07.c new file +144 -0

144 lines not on this page · raw message

Signature · 5 lines
2.43.0


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

PATCH v8 14/16 Add statmount08 test

In reply to Andrea Cervesato

From: Andrea Cervesato <[email protected]>

Verify that statmount() raises EPERM when mount point is not accessible.

---
 runtest/syscalls                                  |  1 +
 testcases/kernel/syscalls/statmount/.gitignore    |  1 +
 testcases/kernel/syscalls/statmount/statmount08.c | 65 +++++++++++++++++++++++
 3 files changed, 67 insertions(+)
runtest/syscalls +1 -0
index bf222e466..f8ae25344 100644
@@ -1581,6 +1581,7 @@ statmount04 statmount04
 statmount05 statmount05
 statmount06 statmount06
 statmount07 statmount07
+statmount08 statmount08
 
 statfs01 statfs01
 statfs01_64 statfs01_64
testcases/kernel/syscalls/statmount/.gitignore +1 -0
index b2a55c077..6106fcf07 100644
@@ -5,3 +5,4 @@ statmount04
 statmount05
 statmount06
 statmount07
+statmount08
testcases/kernel/syscalls/statmount/statmount08.c new file +65 -0

65 lines not on this page · raw message

Signature · 5 lines
2.43.0


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

PATCH v8 15/16 Add listmount03 test

In reply to Andrea Cervesato

From: Andrea Cervesato <[email protected]>

Verify that listmount() raises EPERM when mount point is not accessible.

---
 runtest/syscalls                                  |  1 +
 testcases/kernel/syscalls/listmount/.gitignore    |  1 +
 testcases/kernel/syscalls/listmount/listmount03.c | 62 +++++++++++++++++++++++
 3 files changed, 64 insertions(+)
runtest/syscalls +1 -0
index f8ae25344..7e6d7aacf 100644
@@ -733,6 +733,7 @@ listen01 listen01
 
 listmount01 listmount01
 listmount02 listmount02
+listmount03 listmount03
 
 listxattr01 listxattr01
 listxattr02 listxattr02
testcases/kernel/syscalls/listmount/.gitignore +1 -0
index 30bbf9f02..e4273f319 100644
@@ -1,2 +1,3 @@
 listmount01
 listmount02
+listmount03
testcases/kernel/syscalls/listmount/listmount03.c new file +62 -0

62 lines not on this page · raw message

Signature · 5 lines
2.43.0


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

PATCH v8 16/16 Add listmount04 test

In reply to Andrea Cervesato

From: Andrea Cervesato <[email protected]>

Verify that listmount() raises the correct errors according with invalid data:

- EFAULT: req or mnt_id are unaccessible memories
- EINVAL: invalid flags or mnt_id request
- ENOENT: non-existent mount point

---
 runtest/syscalls                                  |   1 +
 testcases/kernel/syscalls/listmount/.gitignore    |   1 +
 testcases/kernel/syscalls/listmount/listmount04.c | 143 ++++++++++++++++++++++
 3 files changed, 145 insertions(+)
runtest/syscalls +1 -0
index 7e6d7aacf..80c4888ee 100644
@@ -734,6 +734,7 @@ listen01 listen01
 listmount01 listmount01
 listmount02 listmount02
 listmount03 listmount03
+listmount04 listmount04
 
 listxattr01 listxattr01
 listxattr02 listxattr02
testcases/kernel/syscalls/listmount/.gitignore +1 -0
index e4273f319..4d709bae5 100644
@@ -1,3 +1,4 @@
 listmount01
 listmount02
 listmount03
+listmount04
testcases/kernel/syscalls/listmount/listmount04.c new file +143 -0

143 lines not on this page · raw message

Signature · 5 lines
2.43.0


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