statmount/listmount testing suites
v5 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 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 | 111 ++++++++++++----- 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/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 | 97 +++++++++++++++ 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 | 82 +++++++++++++ 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 | 75 ++++++++++++ testcases/kernel/syscalls/statmount/statmount08.c | 65 ++++++++++ 41 files changed, 1386 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
PATCH v5 1/16 Add SAFE_STATX macro
From: Andrea Cervesato <[email protected]>
--- include/lapi/stat.h | 111 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 79 insertions(+), 32 deletions(-)
include/lapi/stat.h +79 -32
@@ -30,6 +30,7 @@ struct statx_timestamp { int32_t __reserved; };#endif +/* * Structures for the extended file attribute retrieval system call * (statx()).
@@ -67,39 +68,57 @@ 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); + +#ifdef HAVE_STRUCT_STATX +typedef struct statx ltp_statx_ ; +#else +LTP_DEFINE_STATX_STRUCT (statx); + +typedef struct statx_fallback ltp_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 { +ltp_statx_ buff; +struct statx_fallback data; + }; +}; +#ifndef HAVE_STATX /*
@@ -108,9 +127,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 +248,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 +274,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__ */
Signature · 5 lines
2.43.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v5 2/16 Add TST_EXP_EQ_STR macro
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
--- include/tst_test_macros.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
include/tst_test_macros.h +14 -0
@@ -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
PATCH v5 3/16 Add listmount/statmount syscalls
In reply to Andrea CervesatoFrom: 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
@@ -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
@@ -323,3 +323,5 @@ futex_waitv 449 cachestat 451 fchmodat2 452 mseal 462 +statmount 457 +listmount 458
include/lapi/syscalls/arm.in +2 -0
@@ -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
@@ -50,3 +50,5 @@ futex_waitv 449 cachestat 451 fchmodat2 452 mseal 462 +statmount 457 +listmount 458
include/lapi/syscalls/i386.in +2 -0
@@ -437,3 +437,5 @@ futex_waitv 449 cachestat 451 fchmodat2 452 mseal 462 +statmount 457 +listmount 458
include/lapi/syscalls/ia64.in +2 -0
@@ -350,3 +350,5 @@ futex_waitv 1473 cachestat 1475 fchmodat2 1476 mseal 1486 +statmount 1481 +listmount 1482
include/lapi/syscalls/loongarch.in +2 -0
@@ -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
@@ -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
@@ -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
@@ -423,3 +423,5 @@ futex_waitv 4449 cachestat 4451 fchmodat2 4452 mseal 4462 +statmount 4457 +listmount 4458
include/lapi/syscalls/powerpc.in +2 -0
@@ -430,3 +430,5 @@ futex_waitv 449 cachestat 451 fchmodat2 452 mseal 462 +statmount 457 +listmount 458
include/lapi/syscalls/powerpc64.in +2 -0
@@ -430,3 +430,5 @@ futex_waitv 449 cachestat 451 fchmodat2 452 mseal 462 +statmount 457 +listmount 458
include/lapi/syscalls/s390.in +2 -0
@@ -417,3 +417,5 @@ futex_waitv 449 cachestat 451 fchmodat2 452 mseal 462 +statmount 457 +listmount 458
include/lapi/syscalls/s390x.in +2 -0
@@ -365,3 +365,5 @@ futex_waitv 449 cachestat 451 fchmodat2 452 mseal 462 +statmount 457 +listmount 458
include/lapi/syscalls/sh.in +2 -0
@@ -411,3 +411,5 @@ futex_waitv 449 cachestat 451 fchmodat2 452 mseal 462 +statmount 457 +listmount 458
include/lapi/syscalls/sparc.in +2 -0
@@ -416,3 +416,5 @@ futex_waitv 449 cachestat 451 fchmodat2 452 mseal 462 +statmount 457 +listmount 458
include/lapi/syscalls/sparc64.in +2 -0
@@ -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
@@ -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
PATCH v5 4/16 Add listmount/statmount fallback declarations
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
--- configure.ac | 2 ++ include/lapi/mount.h | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+)
configure.ac +2 -0
@@ -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
PATCH v5 5/16 Add listmount01 test
In reply to Andrea CervesatoFrom: 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
@@ -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
@@ -0,0 +1 @@ +listmount01
testcases/kernel/syscalls/listmount/Makefile new file +7 -0
@@ -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
@@ -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
PATCH v5 6/16 Add listmount02 test
In reply to Andrea CervesatoFrom: 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
@@ -732,6 +732,7 @@ linkat02 linkat02 listen01 listen01 listmount01 listmount01 +listmount02 listmount02 listxattr01 listxattr01 listxattr02 listxattr02
testcases/kernel/syscalls/listmount/.gitignore +1 -0
@@ -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
PATCH v5 7/16 Add statmount01 test
In reply to Andrea CervesatoFrom: 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 | 82 +++++++++++++++++++++++ 5 files changed, 119 insertions(+)
runtest/syscalls +2 -0
@@ -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
@@ -0,0 +1 @@ +statmount01
testcases/kernel/syscalls/statmount/Makefile new file +7 -0
@@ -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
@@ -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 +82 -0
82 lines not on this page · raw message
Signature · 5 lines
2.43.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 07/16] Add statmount01 test
Hi!
testcases/kernel/syscalls/statmount/statmount01.c line 36
Quoted 8 lines
testcases/kernel/syscalls/statmount/statmount01.c new file +8
-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 )); + +if (TST_RET ==-1 ) +return ;
I asked for this to be changed to if (!TST_PASS)
Quoted 17 lines
testcases/kernel/syscalls/statmount/statmount01.c new file +17
-0+TST_EXP_EQ_LI (st_mount->size,sizeof (struct statmount )); +TST_EXP_EQ_LI (st_mount->mask,0 ); +TST_EXP_EQ_LI (st_mount->sb_dev_major,0 ); +TST_EXP_EQ_LI (st_mount->sb_dev_minor,0 ); +TST_EXP_EQ_LI (st_mount->sb_magic,0 ); +TST_EXP_EQ_LI (st_mount->sb_flags,0 ); +TST_EXP_EQ_LI (st_mount->fs_type,0 ); +TST_EXP_EQ_LI (st_mount->mnt_id,0 ); +TST_EXP_EQ_LI (st_mount->mnt_parent_id,0 ); +TST_EXP_EQ_LI (st_mount->mnt_id_old,0 ); +TST_EXP_EQ_LI (st_mount->mnt_parent_id_old,0 ); +TST_EXP_EQ_LI (st_mount->mnt_attr,0 ); +TST_EXP_EQ_LI (st_mount->mnt_propagation,0 ); +TST_EXP_EQ_LI (st_mount->mnt_peer_group,0 ); +TST_EXP_EQ_LI (st_mount->mnt_master,0 ); +TST_EXP_EQ_LI (st_mount->propagate_from,0 ); +TST_EXP_EQ_LI (st_mount->mnt_root,0 );
testcases/kernel/syscalls/statmount/statmount01.c line 64
Quoted 10 lines
testcases/kernel/syscalls/statmount/statmount01.c new file +10
-0+TST_EXP_EQ_LI (st_mount->mnt_point,0 ); +} + +static void setup (void ) +{ +struct ltp_statx sx; + +SAFE_STATX (AT_FDCWD ,MNTPOINT ,0 ,STATX_MNT_ID_UNIQUE , &sx); + + root_id = sx.data.stx_mnt_id;
And here to be changed to mntpoint_id
testcases/kernel/syscalls/statmount/statmount01.c line 77
Quoted 13 lines
testcases/kernel/syscalls/statmount/statmount01.c new file +13
-0+} + +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 + },
And here I suggested that there is no point in running this for all filesystems.
None of these has been addressed in v5.
Quoted 12 lines
testcases/kernel/syscalls/statmount/statmount01.c new file +5
-0+ .bufs = (struct tst_buffers []) { + {&st_mount, .size =sizeof (struct statmount )}, + {} + } +};Signature · 6 lines
-- 2.43.0 -- 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
PATCH v5 8/16 Add statmount02 test
In reply to Andrea CervesatoFrom: 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
@@ -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
@@ -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
PATCH v5 9/16 Add statmount03 test
In reply to Andrea CervesatoFrom: 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
@@ -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
@@ -1,2 +1,3 @@ statmount01 statmount02 +statmount03
testcases/kernel/syscalls/statmount/statmount.h +24 -0
@@ -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
PATCH v5 10/16 Add statmount04 test
In reply to Andrea CervesatoFrom: 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
@@ -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
@@ -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
PATCH v5 11/16 Add statmount05 test
In reply to Andrea CervesatoFrom: 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
@@ -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
@@ -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
Re: [LTP] [PATCH v5 11/16] Add statmount05 test
Hi!
Quoted 5 lines
testcases/kernel/syscalls/statmount/statmount05.c new file +5
-0+static void test_mount_root (void ) +{ +tst_res (TINFO ,"Testing STATMOUNT_MNT_ROOT" ); + +char *last_root;
testcases/kernel/syscalls/statmount/statmount05.c line 55
Quoted 10 lines
testcases/kernel/syscalls/statmount/statmount05.c new file +10
-0+ +memset (st_mount,0 ,SM_SIZE ); + +TST_EXP_PASS (statmount (root_id,STATMOUNT_MNT_ROOT , st_mount, +SM_SIZE ,0 )); + +if (!TST_PASS ) +return ; + + last_root =strrchr (mnt_root,'/' );
Wouldn't last_root = strrchr(DIRA, '/') produce the same result?
I'm just wondering why MNT_ROOT is relative and MNT_POINT is absolute here.
testcases/kernel/syscalls/statmount/statmount05.c line 59
Quoted 3 lines
testcases/kernel/syscalls/statmount/statmount05.c new file +3
-0+TST_EXP_EQ_LI (st_mount->mask,STATMOUNT_MNT_ROOT ); +TST_EXP_EQ_STR (st_mount->str + st_mount->mnt_root, last_root); +}
Otherwise:
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 11/16] Add statmount05 test
Hi,
Quoted 18 lines · Cyril Hrubis
Hi!
Quoted 5 lines
testcases/kernel/syscalls/statmount/statmount05.c new file +5
-0+static void test_mount_root (void ) +{ +tst_res (TINFO ,"Testing STATMOUNT_MNT_ROOT" ); + +char *last_root;testcases/kernel/syscalls/statmount/statmount05.c line 55
Quoted 10 lines
testcases/kernel/syscalls/statmount/statmount05.c new file +10
-0+ +memset (st_mount,0 ,SM_SIZE ); + +TST_EXP_PASS (statmount (root_id,STATMOUNT_MNT_ROOT , st_mount, +SM_SIZE ,0 )); + +if (!TST_PASS ) +return ; + + last_root =strrchr (mnt_root,'/' );Wouldn't
last_root=strrchr(DIRA, '/')produce the same result?
Quoted 2 lines
I'm just wondering why
MNT_ROOTis relative andMNT_POINTis absolute here.
Because STATMOUNT_MNT_ROOT returns the root folder and STATMOUNT_MNT_POINT returns the mount point folder, relative to the root folder.
Quoted 6 lines
testcases/kernel/syscalls/statmount/statmount05.c line 59
Quoted 3 lines
testcases/kernel/syscalls/statmount/statmount05.c new file +3
-0+TST_EXP_EQ_LI (st_mount->mask,STATMOUNT_MNT_ROOT ); +TST_EXP_EQ_STR (st_mount->str + st_mount->mnt_root, last_root); +}Otherwise:
Reviewed-by Cyril Hrubis <[email protected]>
Andrea
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 11/16] Add statmount05 test
Quoted 21 lines · Andrea Cervesato
Hi,
Quoted 18 lines · Cyril Hrubis
Hi!
Quoted 5 lines
testcases/kernel/syscalls/statmount/statmount05.c new file +5
-0+static void test_mount_root (void ) +{ + tst_res(TINFO, "Testing STATMOUNT_MNT_ROOT"); + + char *last_root;testcases/kernel/syscalls/statmount/statmount05.c line 55
Quoted 10 lines
testcases/kernel/syscalls/statmount/statmount05.c new file +10
-0+ + memset(st_mount, 0, SM_SIZE); + + TST_EXP_PASS(statmount(root_id, STATMOUNT_MNT_ROOT, st_mount, + SM_SIZE, 0)); + + if (!TST_PASS) + return; + + last_root = strrchr(mnt_root, '/');Wouldn't
last_root=strrchr(DIRA, '/')produce the same result?
Quoted 3 lines
Quoted 2 lines
I'm just wondering why
MNT_ROOTis relative andMNT_POINTis absolute here.Because
STATMOUNT_MNT_ROOTreturns the root folder andSTATMOUNT_MNT_POINTreturns the mount point folder, relative to the root folder.
That seems like the way statmount() is working by the way. Also in the kselftests root folder is given with a relative path, while mount point is containing the absolute path.
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
+
TST_EXP_EQ_LI(st_mount->mask, STATMOUNT_MNT_ROOT); +TST_EXP_EQ_STR(st_mount->str + st_mount->mnt_root, last_root); +}Otherwise:
Reviewed-by Cyril Hrubis <[email protected]>Andrea
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v5 12/16 Add statmount06 test
In reply to Andrea CervesatoFrom: 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
@@ -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
@@ -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
PATCH v5 13/16 Add statmount07 test
In reply to Andrea CervesatoFrom: 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 | 75 +++++++++++++++++++++++ 3 files changed, 77 insertions(+)
runtest/syscalls +1 -0
@@ -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
@@ -4,3 +4,4 @@ statmount03 statmount04 statmount05 statmount06 +statmount07
testcases/kernel/syscalls/statmount/statmount07.c new file +75 -0
75 lines not on this page · raw message
Signature · 5 lines
2.43.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 13/16] Add statmount07 test
Hi!
testcases/kernel/syscalls/statmount/statmount07.c line 37
Quoted 3 lines
testcases/kernel/syscalls/statmount/statmount07.c new file +3
-0+} tcases[] = { + {ENOENT, "mount id doesn't exist'", &mnt_id_dont_exist, 0, 0, &buff_size, &st_mount}, + {EOVERFLOW, "invalid mask", &mnt_id, -1, 0, &buff_size, &st_mount},
I guess that we stil miss the EOVERFLOW case here with one of the requests that yields string reply and small buffer.
Quoted 42 lines
testcases/kernel/syscalls/statmount/statmount07.c new file +38
-0+ {EINVAL, "flags must be zero", &mnt_id, 0, 1, &buff_size, &st_mount}, + {EFAULT, "invalid buffer size", &mnt_id, 0, 0, &buff_size_invalid, &st_mount}, + {EFAULT, "invalid buffer pointer", &mnt_id, 0, 0, &buff_size, &st_mount_null}, +}; + +static void run (unsigned int n) +{ +struct tcase *tc = &tcases[n]; + +memset (st_mount,0 ,sizeof (struct statmount )); + +TST_EXP_FAIL (statmount (*tc->mnt_id, tc->mask, + *tc->buff, *tc->buff_size, tc->flags), + tc->exp_errno,"%s" , tc->msg); +} + +static void setup (void ) +{ +struct ltp_statx sx; + +SAFE_STATX (AT_FDCWD ,MNTPOINT ,0 ,STATX_MNT_ID_UNIQUE , &sx); + + mnt_id = sx.data.stx_mnt_id; + buff_size =sizeof (struct statmount ); +} +static struct tst_test test = { + .test = run, + .tcnt =ARRAY_SIZE (tcases), + .setup = setup, + .min_kver ="6.8" , + .mount_device =1 , + .mntpoint =MNTPOINT , + .format_device =1 , + .bufs = (struct tst_buffers []) { + {&st_mount, .size =sizeof (struct statmount )}, + {} + } +};Signature · 2 lines
-- 2.43.0
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v5 14/16 Add statmount08 test
In reply to Andrea CervesatoFrom: 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
@@ -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
@@ -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
Re: [LTP] [PATCH v5 14/16] Add statmount08 test
Hi!
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v5 15/16 Add listmount03 test
In reply to Andrea CervesatoFrom: 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
@@ -733,6 +733,7 @@ listen01 listen01 listmount01 listmount01 listmount02 listmount02 +listmount03 listmount03 listxattr01 listxattr01 listxattr02 listxattr02
testcases/kernel/syscalls/listmount/.gitignore +1 -0
@@ -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
Re: [LTP] [PATCH v5 15/16] Add listmount03 test
Hi!
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v5 16/16 Add listmount04 test
In reply to Andrea CervesatoFrom: 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 req with insufficient size
--- runtest/syscalls | 1 + testcases/kernel/syscalls/listmount/.gitignore | 1 + testcases/kernel/syscalls/listmount/listmount04.c | 97 +++++++++++++++++++++++ 3 files changed, 99 insertions(+)
runtest/syscalls +1 -0
@@ -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
@@ -1,3 +1,4 @@ listmount01 listmount02 listmount03 +listmount04
testcases/kernel/syscalls/listmount/listmount04.c new file +97 -0
97 lines not on this page · raw message
Signature · 5 lines
2.43.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 16/16] Add listmount04 test
Hi!
testcases/kernel/syscalls/listmount/listmount04.c line 68
Quoted 8 lines
testcases/kernel/syscalls/listmount/listmount04.c new file +8
-0+ { + .req = &request_small, + .mnt_ids = mnt_ids, + .nr_mnt_ids = MNT_SIZE, + .flags = 0, + .exp_errno = EINVAL, + .msg = "request has insufficient size", + },
It took me a while to realize that this is a request with .size set to 0, which is obviously rejected as invalid. Maybe it should be called request_zero_size instead.
Also there is quite a bit more errors we can trigger, looking at statmount kernel syscall we can easily trigger at least:
- param > 0 && param <= MNT_UNIUQE_ID_OFFSET -> EINVAL
- spare != 0 -> EINVAL
- nonexisting mnt_ns_id -> ENOENT
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 16/16] Add listmount04 test
Hi,
Quoted 12 lines · Cyril Hrubis
Hi!
testcases/kernel/syscalls/listmount/listmount04.c line 68
Quoted 8 lines
testcases/kernel/syscalls/listmount/listmount04.c new file +8
-0+ { + .req = &request_small, + .mnt_ids = mnt_ids, + .nr_mnt_ids = MNT_SIZE, + .flags = 0, + .exp_errno = EINVAL, + .msg = "request has insufficient size", + },It took me a while to realize that this is a request with .size set to 0, which is obviously rejected as invalid. Maybe it should be called
request_zero_sizeinstead.
This is actually a request with a small memory size for mnt_id_req. I remove 4 bytes allocation from the struct, so it doesn't make sense request_zero_size.
Quoted 8 lines
Also there is quite a bit more errors we can trigger, looking at statmount kernel syscall we can easily trigger at least:
- param > 0 && param <=
MNT_UNIUQE_ID_OFFSET-> EINVAL
- spare != 0 -> EINVAL
- nonexistingmnt_ns_id-> ENOENT
Andrea
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 16/16] Add listmount04 test
Hi!
Quoted 11 lines
Quoted 11 lines
testcases/kernel/syscalls/listmount/listmount04.c line 68
Quoted 8 lines
testcases/kernel/syscalls/listmount/listmount04.c new file +8
-0+ { + .req = &request_small, + .mnt_ids = mnt_ids, + .nr_mnt_ids = MNT_SIZE, + .flags = 0, + .exp_errno = EINVAL, + .msg = "request has insufficient size", + },It took me a while to realize that this is a request with .size set to 0, which is obviously rejected as invalid. Maybe it should be called
request_zero_sizeinstead.
Quoted 3 lines
This is actually a request with a small memory size for
mnt_id_req. I remove 4 bytes allocation from the struct, so it doesn't make senserequest_zero_size.
But you pass the size as a zero, at least I do not see that you ever set request_small->size.
Quoted 8 lines
Quoted 7 lines
Also there is quite a bit more errors we can trigger, looking at statmount kernel syscall we can easily trigger at least:
- param > 0 && param <=
MNT_UNIUQE_ID_OFFSET-> EINVAL
- spare != 0 -> EINVAL
- nonexistingmnt_ns_id-> ENOENTAndrea
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp