* [LTP] [PATCH v1 01/10] Add SAFE_STATX macro
2024-05-15 9:33 [LTP] [PATCH v1 00/10] statmount/listmount testing suites Andrea Cervesato
@ 2024-05-15 9:33 ` Andrea Cervesato
2024-05-16 1:30 ` Petr Vorel
2024-05-15 9:33 ` [LTP] [PATCH v1 02/10] Add listmount/statmount fallback declarations Andrea Cervesato
` (9 subsequent siblings)
10 siblings, 1 reply; 18+ messages in thread
From: Andrea Cervesato @ 2024-05-15 9:33 UTC (permalink / raw)
To: ltp
From: Andrea Cervesato <andrea.cervesato@suse.com>
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
include/tst_safe_macros.h | 7 +++++++
lib/tst_safe_macros.c | 21 +++++++++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
index 8de8ef106..43ff50a33 100644
--- a/include/tst_safe_macros.h
+++ b/include/tst_safe_macros.h
@@ -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__ */
diff --git a/lib/tst_safe_macros.c b/lib/tst_safe_macros.c
index 39b8cc924..bf2f3c0d8 100644
--- a/lib/tst_safe_macros.c
+++ b/lib/tst_safe_macros.c
@@ -710,3 +710,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;
+}
--
2.35.3
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 18+ messages in thread* Re: [LTP] [PATCH v1 01/10] Add SAFE_STATX macro
2024-05-15 9:33 ` [LTP] [PATCH v1 01/10] Add SAFE_STATX macro Andrea Cervesato
@ 2024-05-16 1:30 ` Petr Vorel
2024-05-16 11:50 ` Andrea Cervesato via ltp
0 siblings, 1 reply; 18+ messages in thread
From: Petr Vorel @ 2024-05-16 1:30 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
Hi Andrea,
could you please fix these?
testcases/kernel/syscalls/statmount/statmount03.c: useless tag: format_device
testcases/kernel/syscalls/statmount/statmount03.c: useless tag: needs_tmpdir
testcases/kernel/syscalls/statmount/statmount03.c: useless tag: needs_tmpdir
testcases/kernel/syscalls/statmount/statmount03.c: useless tag: needs_tmpdir
testcases/kernel/syscalls/statmount/statmount04.c: useless tag: format_device
testcases/kernel/syscalls/statmount/statmount04.c: useless tag: needs_tmpdir
testcases/kernel/syscalls/statmount/statmount04.c: useless tag: needs_tmpdir
testcases/kernel/syscalls/statmount/statmount04.c: useless tag: needs_tmpdir
testcases/kernel/syscalls/statmount/statmount05.c: useless tag: format_device
testcases/kernel/syscalls/statmount/statmount05.c: useless tag: needs_tmpdir
testcases/kernel/syscalls/statmount/statmount05.c: useless tag: needs_tmpdir
testcases/kernel/syscalls/statmount/statmount05.c: useless tag: needs_tmpdir
testcases/kernel/syscalls/statmount/statmount06.c: useless tag: format_device
> diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
> index 8de8ef106..43ff50a33 100644
> --- a/include/tst_safe_macros.h
> +++ b/include/tst_safe_macros.h
> @@ -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;
Could you please remove this? (unneeded)
With that, you might add for this patch in the next version:
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH v1 01/10] Add SAFE_STATX macro
2024-05-16 1:30 ` Petr Vorel
@ 2024-05-16 11:50 ` Andrea Cervesato via ltp
2024-05-16 14:49 ` Petr Vorel
0 siblings, 1 reply; 18+ messages in thread
From: Andrea Cervesato via ltp @ 2024-05-16 11:50 UTC (permalink / raw)
To: Petr Vorel, Andrea Cervesato; +Cc: ltp
Hi,
On 5/16/24 03:30, Petr Vorel wrote:
> Hi Andrea,
>
> could you please fix these?
Sure
>
> testcases/kernel/syscalls/statmount/statmount03.c: useless tag: format_device
> testcases/kernel/syscalls/statmount/statmount03.c: useless tag: needs_tmpdir
> testcases/kernel/syscalls/statmount/statmount03.c: useless tag: needs_tmpdir
> testcases/kernel/syscalls/statmount/statmount03.c: useless tag: needs_tmpdir
> testcases/kernel/syscalls/statmount/statmount04.c: useless tag: format_device
> testcases/kernel/syscalls/statmount/statmount04.c: useless tag: needs_tmpdir
> testcases/kernel/syscalls/statmount/statmount04.c: useless tag: needs_tmpdir
> testcases/kernel/syscalls/statmount/statmount04.c: useless tag: needs_tmpdir
> testcases/kernel/syscalls/statmount/statmount05.c: useless tag: format_device
> testcases/kernel/syscalls/statmount/statmount05.c: useless tag: needs_tmpdir
> testcases/kernel/syscalls/statmount/statmount05.c: useless tag: needs_tmpdir
> testcases/kernel/syscalls/statmount/statmount05.c: useless tag: needs_tmpdir
> testcases/kernel/syscalls/statmount/statmount06.c: useless tag: format_device
>
>> diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
>> index 8de8ef106..43ff50a33 100644
>> --- a/include/tst_safe_macros.h
>> +++ b/include/tst_safe_macros.h
>> @@ -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;
> Could you please remove this? (unneeded)
That's needed because in some distro statx is not defined before
reaching that line causing build failure.
>
> With that, you might add for this patch in the next version:
>
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
>
> Kind regards,
> Petr
Andrea
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH v1 01/10] Add SAFE_STATX macro
2024-05-16 11:50 ` Andrea Cervesato via ltp
@ 2024-05-16 14:49 ` Petr Vorel
2024-05-16 14:59 ` Andrea Cervesato via ltp
0 siblings, 1 reply; 18+ messages in thread
From: Petr Vorel @ 2024-05-16 14:49 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
> Hi,
> On 5/16/24 03:30, Petr Vorel wrote:
> > Hi Andrea,
> > could you please fix these?
> Sure
> > testcases/kernel/syscalls/statmount/statmount03.c: useless tag: format_device
> > testcases/kernel/syscalls/statmount/statmount03.c: useless tag: needs_tmpdir
> > testcases/kernel/syscalls/statmount/statmount03.c: useless tag: needs_tmpdir
> > testcases/kernel/syscalls/statmount/statmount03.c: useless tag: needs_tmpdir
> > testcases/kernel/syscalls/statmount/statmount04.c: useless tag: format_device
> > testcases/kernel/syscalls/statmount/statmount04.c: useless tag: needs_tmpdir
> > testcases/kernel/syscalls/statmount/statmount04.c: useless tag: needs_tmpdir
> > testcases/kernel/syscalls/statmount/statmount04.c: useless tag: needs_tmpdir
> > testcases/kernel/syscalls/statmount/statmount05.c: useless tag: format_device
> > testcases/kernel/syscalls/statmount/statmount05.c: useless tag: needs_tmpdir
> > testcases/kernel/syscalls/statmount/statmount05.c: useless tag: needs_tmpdir
> > testcases/kernel/syscalls/statmount/statmount05.c: useless tag: needs_tmpdir
> > testcases/kernel/syscalls/statmount/statmount06.c: useless tag: format_device
> > > diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
> > > index 8de8ef106..43ff50a33 100644
> > > --- a/include/tst_safe_macros.h
> > > +++ b/include/tst_safe_macros.h
> > > @@ -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;
> > Could you please remove this? (unneeded)
> That's needed because in some distro statx is not defined before reaching
> that line causing build failure.
<sys/stat.h> are included in lapi/stat.h. I wonder if <linux/stat.h> would fail.
If the definition later works it should be fixable by including the needed
header in lapi/stat.h, right?
Could you post link to CI job which failed?
Kind regards,
Petr
> > With that, you might add for this patch in the next version:
> > Reviewed-by: Petr Vorel <pvorel@suse.cz>
> > Kind regards,
> > Petr
> Andrea
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH v1 01/10] Add SAFE_STATX macro
2024-05-16 14:49 ` Petr Vorel
@ 2024-05-16 14:59 ` Andrea Cervesato via ltp
2024-05-16 16:27 ` Petr Vorel
0 siblings, 1 reply; 18+ messages in thread
From: Andrea Cervesato via ltp @ 2024-05-16 14:59 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
Hi,
On 5/16/24 16:49, Petr Vorel wrote:
>> Hi,
>> On 5/16/24 03:30, Petr Vorel wrote:
>>> Hi Andrea,
>>> could you please fix these?
>> Sure
>>> testcases/kernel/syscalls/statmount/statmount03.c: useless tag: format_device
>>> testcases/kernel/syscalls/statmount/statmount03.c: useless tag: needs_tmpdir
>>> testcases/kernel/syscalls/statmount/statmount03.c: useless tag: needs_tmpdir
>>> testcases/kernel/syscalls/statmount/statmount03.c: useless tag: needs_tmpdir
>>> testcases/kernel/syscalls/statmount/statmount04.c: useless tag: format_device
>>> testcases/kernel/syscalls/statmount/statmount04.c: useless tag: needs_tmpdir
>>> testcases/kernel/syscalls/statmount/statmount04.c: useless tag: needs_tmpdir
>>> testcases/kernel/syscalls/statmount/statmount04.c: useless tag: needs_tmpdir
>>> testcases/kernel/syscalls/statmount/statmount05.c: useless tag: format_device
>>> testcases/kernel/syscalls/statmount/statmount05.c: useless tag: needs_tmpdir
>>> testcases/kernel/syscalls/statmount/statmount05.c: useless tag: needs_tmpdir
>>> testcases/kernel/syscalls/statmount/statmount05.c: useless tag: needs_tmpdir
>>> testcases/kernel/syscalls/statmount/statmount06.c: useless tag: format_device
>>>> diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
>>>> index 8de8ef106..43ff50a33 100644
>>>> --- a/include/tst_safe_macros.h
>>>> +++ b/include/tst_safe_macros.h
>>>> @@ -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;
>>> Could you please remove this? (unneeded)
>> That's needed because in some distro statx is not defined before reaching
>> that line causing build failure.
> <sys/stat.h> are included in lapi/stat.h. I wonder if <linux/stat.h> would fail.
It's related with distros which need to use fallback. There's no
fallback of "struct statx" when defining the
statx() syscall wrapper, so it fails during build.
>
> If the definition later works it should be fixable by including the needed
> header in lapi/stat.h, right?
>
> Could you post link to CI job which failed?
>
> Kind regards,
> Petr
>
>>> With that, you might add for this patch in the next version:
>>> Reviewed-by: Petr Vorel <pvorel@suse.cz>
>>> Kind regards,
>>> Petr
>> Andrea
Andrea
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH v1 01/10] Add SAFE_STATX macro
2024-05-16 14:59 ` Andrea Cervesato via ltp
@ 2024-05-16 16:27 ` Petr Vorel
0 siblings, 0 replies; 18+ messages in thread
From: Petr Vorel @ 2024-05-16 16:27 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
Hi Andrea,
> Hi,
...
> > > > > +++ b/include/tst_safe_macros.h
> > > > > @@ -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;
> > > > Could you please remove this? (unneeded)
> > > That's needed because in some distro statx is not defined before reaching
> > > that line causing build failure.
> > <sys/stat.h> are included in lapi/stat.h. I wonder if <linux/stat.h> would fail.
> It's related with distros which need to use fallback. There's no fallback of
> "struct statx" when defining the
> statx() syscall wrapper, so it fails during build.
OK, struct statx is at least on musl guarded with _GNU_SOURCE, that's why
struct statx in the header helps. This is better than define _GNU_SOURCE also
for the header (it's in tst_safe_macros.c). But it would be good to document
this (either in the commit message or in the source) - I always wonder when
staring in various workarounds like this few years later and wondering if it can
be removed.
I was thinking it would be possible to switch to <linux/stat.h> and we would
save the detection. But given struct statx is used in tst_safe_macros.h,
we would need to replace all <sys/stat.h> with <linux/stat.h> also in the tests
which use tst_safe_macros.h:
$ git grep -l tst_safe_macros.h $(git grep -l -e include..lapi/stat.h -e include..sys/stat.h) | wc -l
8
But I don't think it's a good idea to switch to <linux/stat.h>.
Kind regards,
Petr
> > If the definition later works it should be fixable by including the needed
> > header in lapi/stat.h, right?
> > Could you post link to CI job which failed?
> > Kind regards,
> > Petr
> > > > With that, you might add for this patch in the next version:
> > > > Reviewed-by: Petr Vorel <pvorel@suse.cz>
> > > > Kind regards,
> > > > Petr
> > > Andrea
> Andrea
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* [LTP] [PATCH v1 02/10] Add listmount/statmount fallback declarations
2024-05-15 9:33 [LTP] [PATCH v1 00/10] statmount/listmount testing suites Andrea Cervesato
2024-05-15 9:33 ` [LTP] [PATCH v1 01/10] Add SAFE_STATX macro Andrea Cervesato
@ 2024-05-15 9:33 ` Andrea Cervesato
2024-05-16 1:22 ` Petr Vorel
2024-05-15 9:33 ` [LTP] [PATCH v1 03/10] Add listmount01 test Andrea Cervesato
` (8 subsequent siblings)
10 siblings, 1 reply; 18+ messages in thread
From: Andrea Cervesato @ 2024-05-15 9:33 UTC (permalink / raw)
To: ltp
From: Andrea Cervesato <andrea.cervesato@suse.com>
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
configure.ac | 5 +++
include/lapi/mount.h | 67 ++++++++++++++++++++++++++++++
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 +
21 files changed, 117 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 1f7aa70bd..95c91c6af 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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 \
@@ -232,6 +234,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
diff --git a/include/lapi/mount.h b/include/lapi/mount.h
index c1af944fe..57542832f 100644
--- a/include/lapi/mount.h
+++ b/include/lapi/mount.h
@@ -37,4 +37,71 @@
# define MS_NOSYMFOLLOW 256
#endif
+#ifndef HAVE_MNT_ID_REQ
+struct mnt_id_req {
+ __u32 size;
+ __u32 spare;
+ __u64 mnt_id;
+ __u64 param;
+};
+#endif
+
+#ifndef HAVE_STATMOUNT
+struct statmount {
+ __u32 size;
+ __u32 __spare1;
+ __u64 mask;
+ __u32 sb_dev_major;
+ __u32 sb_dev_minor;
+ __u64 sb_magic;
+ __u32 sb_flags;
+ __u32 fs_type;
+ __u64 mnt_id;
+ __u64 mnt_parent_id;
+ __u32 mnt_id_old;
+ __u32 mnt_parent_id_old;
+ __u64 mnt_attr;
+ __u64 mnt_propagation;
+ __u64 mnt_peer_group;
+ __u64 mnt_master;
+ __u64 propagate_from;
+ __u32 mnt_root;
+ __u32 mnt_point;
+ __u64 __spare2[50];
+ char str[];
+};
+#endif
+
+#ifndef MNT_ID_REQ_SIZE_VER0
+# define MNT_ID_REQ_SIZE_VER0 24
+#endif
+
+#ifndef STATMOUNT_SB_BASIC
+# define STATMOUNT_SB_BASIC 0x00000001U
+#endif
+
+#ifndef STATMOUNT_MNT_BASIC
+# define STATMOUNT_MNT_BASIC 0x00000002U
+#endif
+
+#ifndef STATMOUNT_PROPAGATE_FROM
+# define STATMOUNT_PROPAGATE_FROM 0x00000004U
+#endif
+
+#ifndef STATMOUNT_MNT_ROOT
+# define STATMOUNT_MNT_ROOT 0x00000008U
+#endif
+
+#ifndef STATMOUNT_MNT_POINT
+# define STATMOUNT_MNT_POINT 0x00000010U
+#endif
+
+#ifndef STATMOUNT_FS_TYPE
+# define STATMOUNT_FS_TYPE 0x00000020U
+#endif
+
+#ifndef LSMT_ROOT
+# define LSMT_ROOT 0xffffffffffffffff
+#endif
+
#endif /* LAPI_MOUNT_H__ */
diff --git a/include/lapi/stat.h b/include/lapi/stat.h
index 3606c9eb0..84dc76faf 100644
--- a/include/lapi/stat.h
+++ b/include/lapi/stat.h
@@ -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__ */
diff --git a/include/lapi/syscalls/aarch64.in b/include/lapi/syscalls/aarch64.in
index 2cb6c2d87..3b32a3b2a 100644
--- a/include/lapi/syscalls/aarch64.in
+++ b/include/lapi/syscalls/aarch64.in
@@ -297,4 +297,6 @@ faccessat2 439
epoll_pwait2 441
quotactl_fd 443
futex_waitv 449
+statmount 457
+listmount 458
_sysctl 1078
diff --git a/include/lapi/syscalls/arc.in b/include/lapi/syscalls/arc.in
index 3e2ee9061..1a3a908e4 100644
--- a/include/lapi/syscalls/arc.in
+++ b/include/lapi/syscalls/arc.in
@@ -317,3 +317,5 @@ faccessat2 439
epoll_pwait2 441
quotactl_fd 443
futex_waitv 449
+statmount 457
+listmount 458
diff --git a/include/lapi/syscalls/arm.in b/include/lapi/syscalls/arm.in
index 7bdbca533..78d84549f 100644
--- a/include/lapi/syscalls/arm.in
+++ b/include/lapi/syscalls/arm.in
@@ -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)
diff --git a/include/lapi/syscalls/hppa.in b/include/lapi/syscalls/hppa.in
index 8ebdafafb..1f01a4a0c 100644
--- a/include/lapi/syscalls/hppa.in
+++ b/include/lapi/syscalls/hppa.in
@@ -44,3 +44,5 @@ faccessat2 439
epoll_pwait2 441
quotactl_fd 443
futex_waitv 449
+statmount 457
+listmount 458
diff --git a/include/lapi/syscalls/i386.in b/include/lapi/syscalls/i386.in
index 1472631c4..f4e6589ab 100644
--- a/include/lapi/syscalls/i386.in
+++ b/include/lapi/syscalls/i386.in
@@ -431,3 +431,5 @@ faccessat2 439
epoll_pwait2 441
quotactl_fd 443
futex_waitv 449
+statmount 457
+listmount 458
diff --git a/include/lapi/syscalls/ia64.in b/include/lapi/syscalls/ia64.in
index 0ea6e9722..dd8b8c79f 100644
--- a/include/lapi/syscalls/ia64.in
+++ b/include/lapi/syscalls/ia64.in
@@ -344,3 +344,5 @@ faccessat2 1463
epoll_pwait2 1465
quotactl_fd 1467
futex_waitv 1473
+statmount 1481
+listmount 1482
diff --git a/include/lapi/syscalls/loongarch.in b/include/lapi/syscalls/loongarch.in
index 301f611f6..f48c0658c 100644
--- a/include/lapi/syscalls/loongarch.in
+++ b/include/lapi/syscalls/loongarch.in
@@ -305,3 +305,5 @@ memfd_secret 447
process_mrelease 448
futex_waitv 449
set_mempolicy_home_node 450
+statmount 457
+listmount 458
diff --git a/include/lapi/syscalls/mips_n32.in b/include/lapi/syscalls/mips_n32.in
index e818c9d92..af5928c0e 100644
--- a/include/lapi/syscalls/mips_n32.in
+++ b/include/lapi/syscalls/mips_n32.in
@@ -371,3 +371,5 @@ epoll_pwait2 6441
mount_setattr 6442
quotactl_fd 6443
futex_waitv 6449
+statmount 6457
+listmount 6458
diff --git a/include/lapi/syscalls/mips_n64.in b/include/lapi/syscalls/mips_n64.in
index 6e15f43b3..a6d83e2e0 100644
--- a/include/lapi/syscalls/mips_n64.in
+++ b/include/lapi/syscalls/mips_n64.in
@@ -347,3 +347,5 @@ epoll_pwait2 5441
mount_setattr 5442
quotactl_fd 5443
futex_waitv 5449
+statmount 5457
+listmount 5458
diff --git a/include/lapi/syscalls/mips_o32.in b/include/lapi/syscalls/mips_o32.in
index 921d5d331..eda7388a3 100644
--- a/include/lapi/syscalls/mips_o32.in
+++ b/include/lapi/syscalls/mips_o32.in
@@ -417,3 +417,5 @@ epoll_pwait2 4441
mount_setattr 4442
quotactl_fd 4443
futex_waitv 4449
+statmount 4457
+listmount 4458
diff --git a/include/lapi/syscalls/powerpc.in b/include/lapi/syscalls/powerpc.in
index 545d9d3d6..1b40ea53d 100644
--- a/include/lapi/syscalls/powerpc.in
+++ b/include/lapi/syscalls/powerpc.in
@@ -424,3 +424,5 @@ faccessat2 439
epoll_pwait2 441
quotactl_fd 443
futex_waitv 449
+statmount 457
+listmount 458
diff --git a/include/lapi/syscalls/powerpc64.in b/include/lapi/syscalls/powerpc64.in
index 545d9d3d6..1b40ea53d 100644
--- a/include/lapi/syscalls/powerpc64.in
+++ b/include/lapi/syscalls/powerpc64.in
@@ -424,3 +424,5 @@ faccessat2 439
epoll_pwait2 441
quotactl_fd 443
futex_waitv 449
+statmount 457
+listmount 458
diff --git a/include/lapi/syscalls/s390.in b/include/lapi/syscalls/s390.in
index 7213ac5f8..6593a4ff7 100644
--- a/include/lapi/syscalls/s390.in
+++ b/include/lapi/syscalls/s390.in
@@ -411,3 +411,5 @@ faccessat2 439
epoll_pwait2 441
quotactl_fd 443
futex_waitv 449
+statmount 457
+listmount 458
diff --git a/include/lapi/syscalls/s390x.in b/include/lapi/syscalls/s390x.in
index 879012e2b..b98e727d6 100644
--- a/include/lapi/syscalls/s390x.in
+++ b/include/lapi/syscalls/s390x.in
@@ -359,3 +359,5 @@ faccessat2 439
epoll_pwait2 441
quotactl_fd 443
futex_waitv 449
+statmount 457
+listmount 458
diff --git a/include/lapi/syscalls/sh.in b/include/lapi/syscalls/sh.in
index 7d5192a27..59178113e 100644
--- a/include/lapi/syscalls/sh.in
+++ b/include/lapi/syscalls/sh.in
@@ -405,3 +405,5 @@ faccessat2 439
epoll_pwait2 441
quotactl_fd 443
futex_waitv 449
+statmount 457
+listmount 458
diff --git a/include/lapi/syscalls/sparc.in b/include/lapi/syscalls/sparc.in
index 91d2fb1c2..56a244ceb 100644
--- a/include/lapi/syscalls/sparc.in
+++ b/include/lapi/syscalls/sparc.in
@@ -410,3 +410,5 @@ faccessat2 439
epoll_pwait2 441
quotactl_fd 443
futex_waitv 449
+statmount 457
+listmount 458
diff --git a/include/lapi/syscalls/sparc64.in b/include/lapi/syscalls/sparc64.in
index 1f2fc59b7..84051a600 100644
--- a/include/lapi/syscalls/sparc64.in
+++ b/include/lapi/syscalls/sparc64.in
@@ -375,3 +375,5 @@ faccessat2 439
epoll_pwait2 441
quotactl_fd 443
futex_waitv 449
+statmount 457
+listmount 458
diff --git a/include/lapi/syscalls/x86_64.in b/include/lapi/syscalls/x86_64.in
index dc61aa56e..935c5d7bc 100644
--- a/include/lapi/syscalls/x86_64.in
+++ b/include/lapi/syscalls/x86_64.in
@@ -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
--
2.35.3
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 18+ messages in thread* Re: [LTP] [PATCH v1 02/10] Add listmount/statmount fallback declarations
2024-05-15 9:33 ` [LTP] [PATCH v1 02/10] Add listmount/statmount fallback declarations Andrea Cervesato
@ 2024-05-16 1:22 ` Petr Vorel
0 siblings, 0 replies; 18+ messages in thread
From: Petr Vorel @ 2024-05-16 1:22 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
Hi Andrea,
> configure.ac | 5 +++
> include/lapi/mount.h | 67 ++++++++++++++++++++++++++++++
> 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 +
I would prefer to separate syscall numbers into it's own commit
(patchset is quite big, this would help to clearly see autoconf and lapi/*.h
changes which are quite small but covered by syscall numbers).
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* [LTP] [PATCH v1 03/10] Add listmount01 test
2024-05-15 9:33 [LTP] [PATCH v1 00/10] statmount/listmount testing suites Andrea Cervesato
2024-05-15 9:33 ` [LTP] [PATCH v1 01/10] Add SAFE_STATX macro Andrea Cervesato
2024-05-15 9:33 ` [LTP] [PATCH v1 02/10] Add listmount/statmount fallback declarations Andrea Cervesato
@ 2024-05-15 9:33 ` Andrea Cervesato
2024-05-15 9:33 ` [LTP] [PATCH v1 04/10] Add listmount02 test Andrea Cervesato
` (7 subsequent siblings)
10 siblings, 0 replies; 18+ messages in thread
From: Andrea Cervesato @ 2024-05-15 9:33 UTC (permalink / raw)
To: ltp
From: Andrea Cervesato <andrea.cervesato@suse.com>
This test verifies that listmount() is properly recognizing a mounted
root directory using LSMT_ROOT flag.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
runtest/syscalls | 2 +
.../kernel/syscalls/listmount/.gitignore | 1 +
testcases/kernel/syscalls/listmount/Makefile | 7 ++
.../kernel/syscalls/listmount/listmount.h | 26 ++++++++
.../kernel/syscalls/listmount/listmount01.c | 66 +++++++++++++++++++
5 files changed, 102 insertions(+)
create mode 100644 testcases/kernel/syscalls/listmount/.gitignore
create mode 100644 testcases/kernel/syscalls/listmount/Makefile
create mode 100644 testcases/kernel/syscalls/listmount/listmount.h
create mode 100644 testcases/kernel/syscalls/listmount/listmount01.c
diff --git a/runtest/syscalls b/runtest/syscalls
index d9cf37510..8fd4a9a0a 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -706,6 +706,8 @@ linkat02 linkat02
listen01 listen01
+listmount01 listmount01
+
listxattr01 listxattr01
listxattr02 listxattr02
listxattr03 listxattr03
diff --git a/testcases/kernel/syscalls/listmount/.gitignore b/testcases/kernel/syscalls/listmount/.gitignore
new file mode 100644
index 000000000..5257b298c
--- /dev/null
+++ b/testcases/kernel/syscalls/listmount/.gitignore
@@ -0,0 +1 @@
+listmount01
diff --git a/testcases/kernel/syscalls/listmount/Makefile b/testcases/kernel/syscalls/listmount/Makefile
new file mode 100644
index 000000000..8cf1b9024
--- /dev/null
+++ b/testcases/kernel/syscalls/listmount/Makefile
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (C) 2024 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
+
+top_srcdir ?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/listmount/listmount.h b/testcases/kernel/syscalls/listmount/listmount.h
new file mode 100644
index 000000000..93766cd33
--- /dev/null
+++ b/testcases/kernel/syscalls/listmount/listmount.h
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2024 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
+ */
+
+#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
diff --git a/testcases/kernel/syscalls/listmount/listmount01.c b/testcases/kernel/syscalls/listmount/listmount01.c
new file mode 100644
index 000000000..20cc90507
--- /dev/null
+++ b/testcases/kernel/syscalls/listmount/listmount01.c
@@ -0,0 +1,66 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2024 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
+ */
+
+/**
+ * [Description]
+ *
+ * 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
+ */
+
+#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;
+}
+
+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,
+ .skip_filesystems = (const char *const []) {
+ "fuse",
+ NULL
+ },
+};
--
2.35.3
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 18+ messages in thread* [LTP] [PATCH v1 04/10] Add listmount02 test
2024-05-15 9:33 [LTP] [PATCH v1 00/10] statmount/listmount testing suites Andrea Cervesato
` (2 preceding siblings ...)
2024-05-15 9:33 ` [LTP] [PATCH v1 03/10] Add listmount01 test Andrea Cervesato
@ 2024-05-15 9:33 ` Andrea Cervesato
2024-05-15 9:33 ` [LTP] [PATCH v1 05/10] Add stamount01 test Andrea Cervesato
` (6 subsequent siblings)
10 siblings, 0 replies; 18+ messages in thread
From: Andrea Cervesato @ 2024-05-15 9:33 UTC (permalink / raw)
To: ltp
From: Andrea Cervesato <andrea.cervesato@suse.com>
This test verifies that listmount() is properly reading groups of
mount IDs.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
runtest/syscalls | 1 +
.../kernel/syscalls/listmount/.gitignore | 1 +
.../kernel/syscalls/listmount/listmount02.c | 106 ++++++++++++++++++
3 files changed, 108 insertions(+)
create mode 100644 testcases/kernel/syscalls/listmount/listmount02.c
diff --git a/runtest/syscalls b/runtest/syscalls
index 8fd4a9a0a..355c182f8 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -707,6 +707,7 @@ linkat02 linkat02
listen01 listen01
listmount01 listmount01
+listmount02 listmount02
listxattr01 listxattr01
listxattr02 listxattr02
diff --git a/testcases/kernel/syscalls/listmount/.gitignore b/testcases/kernel/syscalls/listmount/.gitignore
index 5257b298c..30bbf9f02 100644
--- a/testcases/kernel/syscalls/listmount/.gitignore
+++ b/testcases/kernel/syscalls/listmount/.gitignore
@@ -1 +1,2 @@
listmount01
+listmount02
diff --git a/testcases/kernel/syscalls/listmount/listmount02.c b/testcases/kernel/syscalls/listmount/listmount02.c
new file mode 100644
index 000000000..712f17a50
--- /dev/null
+++ b/testcases/kernel/syscalls/listmount/listmount02.c
@@ -0,0 +1,106 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2024 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
+ */
+
+/**
+ * [Description]
+ *
+ * This test verifies that listmount() is properly reading groups of mount IDs.
+ *
+ * [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
+ */
+
+#include "listmount.h"
+#include "lapi/sched.h"
+
+#define MNTPOINT "mntpoint"
+#define BIND_MOUNTS 7
+#define GROUPS_SIZE 3
+#define LISTSIZE (1 << BIND_MOUNTS)
+
+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++) {
+ 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("/");
+}
+
+static void setup(void)
+{
+ SAFE_UNSHARE(CLONE_NEWNS);
+ SAFE_CHROOT(MNTPOINT);
+
+ SAFE_MOUNT("", "/", NULL, MS_REC | MS_SHARED, NULL);
+}
+
+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,
+ .skip_filesystems = (const char *const []) {
+ "fuse",
+ NULL
+ },
+};
--
2.35.3
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 18+ messages in thread* [LTP] [PATCH v1 05/10] Add stamount01 test
2024-05-15 9:33 [LTP] [PATCH v1 00/10] statmount/listmount testing suites Andrea Cervesato
` (3 preceding siblings ...)
2024-05-15 9:33 ` [LTP] [PATCH v1 04/10] Add listmount02 test Andrea Cervesato
@ 2024-05-15 9:33 ` Andrea Cervesato
2024-05-15 9:33 ` [LTP] [PATCH v1 06/10] Add statmount02 test Andrea Cervesato
` (5 subsequent siblings)
10 siblings, 0 replies; 18+ messages in thread
From: Andrea Cervesato @ 2024-05-15 9:33 UTC (permalink / raw)
To: ltp
From: Andrea Cervesato <andrea.cervesato@suse.com>
This test verifies that statmount() is working with no mask flags.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
runtest/syscalls | 2 +
.../kernel/syscalls/statmount/.gitignore | 1 +
testcases/kernel/syscalls/statmount/Makefile | 7 ++
.../kernel/syscalls/statmount/statmount.h | 26 +++++++
.../kernel/syscalls/statmount/statmount01.c | 69 +++++++++++++++++++
5 files changed, 105 insertions(+)
create mode 100644 testcases/kernel/syscalls/statmount/.gitignore
create mode 100644 testcases/kernel/syscalls/statmount/Makefile
create mode 100644 testcases/kernel/syscalls/statmount/statmount.h
create mode 100644 testcases/kernel/syscalls/statmount/statmount01.c
diff --git a/runtest/syscalls b/runtest/syscalls
index 355c182f8..407cae890 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -1537,6 +1537,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
diff --git a/testcases/kernel/syscalls/statmount/.gitignore b/testcases/kernel/syscalls/statmount/.gitignore
new file mode 100644
index 000000000..f1529eb29
--- /dev/null
+++ b/testcases/kernel/syscalls/statmount/.gitignore
@@ -0,0 +1 @@
+statmount01
diff --git a/testcases/kernel/syscalls/statmount/Makefile b/testcases/kernel/syscalls/statmount/Makefile
new file mode 100644
index 000000000..8cf1b9024
--- /dev/null
+++ b/testcases/kernel/syscalls/statmount/Makefile
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (C) 2024 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
+
+top_srcdir ?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/statmount/statmount.h b/testcases/kernel/syscalls/statmount/statmount.h
new file mode 100644
index 000000000..e807c8288
--- /dev/null
+++ b/testcases/kernel/syscalls/statmount/statmount.h
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2024 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
+ */
+
+#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
diff --git a/testcases/kernel/syscalls/statmount/statmount01.c b/testcases/kernel/syscalls/statmount/statmount01.c
new file mode 100644
index 000000000..4bf879916
--- /dev/null
+++ b/testcases/kernel/syscalls/statmount/statmount01.c
@@ -0,0 +1,69 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2024 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
+ */
+
+/**
+ * [Description]
+ *
+ * This test verifies that statmount() is working with no mask flags.
+ *
+ * [Algorithm]
+ *
+ * * create a mount point
+ * * run statmount() on the mount point without giving any mask
+ * * read results and check that mask and size are correct
+ */
+
+#include "statmount.h"
+#include "lapi/stat.h"
+#include "lapi/sched.h"
+
+#define MNTPOINT "mntpoint"
+
+static uint64_t root_id;
+static struct statmount *st_mount;
+
+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;
+
+ TST_EXP_EQ_LI(st_mount->mask, 0);
+ TST_EXP_EQ_LI(st_mount->size, sizeof(struct statmount));
+}
+
+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 = sizeof(struct statmount)},
+ {}
+ }
+};
--
2.35.3
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 18+ messages in thread* [LTP] [PATCH v1 06/10] Add statmount02 test
2024-05-15 9:33 [LTP] [PATCH v1 00/10] statmount/listmount testing suites Andrea Cervesato
` (4 preceding siblings ...)
2024-05-15 9:33 ` [LTP] [PATCH v1 05/10] Add stamount01 test Andrea Cervesato
@ 2024-05-15 9:33 ` Andrea Cervesato
2024-05-15 9:33 ` [LTP] [PATCH v1 07/10] Add statmount03 test Andrea Cervesato
` (4 subsequent siblings)
10 siblings, 0 replies; 18+ messages in thread
From: Andrea Cervesato @ 2024-05-15 9:33 UTC (permalink / raw)
To: ltp
From: Andrea Cervesato <andrea.cervesato@suse.com>
This test verifies that statmount() is correctly reading basic
filesystem info using STATMOUNT_SB_BASIC.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
runtest/syscalls | 1 +
.../kernel/syscalls/statmount/.gitignore | 1 +
.../kernel/syscalls/statmount/statmount02.c | 76 +++++++++++++++++++
3 files changed, 78 insertions(+)
create mode 100644 testcases/kernel/syscalls/statmount/statmount02.c
diff --git a/runtest/syscalls b/runtest/syscalls
index 407cae890..5f1df42ca 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -1538,6 +1538,7 @@ stat04 symlink01 -T stat04
stat04_64 symlink01 -T stat04_64
statmount01 statmount01
+statmount02 statmount02
statfs01 statfs01
statfs01_64 statfs01_64
diff --git a/testcases/kernel/syscalls/statmount/.gitignore b/testcases/kernel/syscalls/statmount/.gitignore
index f1529eb29..a30b9565f 100644
--- a/testcases/kernel/syscalls/statmount/.gitignore
+++ b/testcases/kernel/syscalls/statmount/.gitignore
@@ -1 +1,2 @@
statmount01
+statmount02
diff --git a/testcases/kernel/syscalls/statmount/statmount02.c b/testcases/kernel/syscalls/statmount/statmount02.c
new file mode 100644
index 000000000..b110e992d
--- /dev/null
+++ b/testcases/kernel/syscalls/statmount/statmount02.c
@@ -0,0 +1,76 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2024 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
+ */
+
+/**
+ * [Description]
+ *
+ * This test verifies that statmount() is correctly reading basic filesystem
+ * info using STATMOUNT_SB_BASIC.
+ * The btrfs validation is currently skipped due to the lack of support for VFS.
+ *
+ * [Algorithm]
+ *
+ * * create a mount point and read its mount info
+ * * run statmount() on the mount point using STATMOUNT_SB_BASIC
+ * * read results and check if mount info are correct
+ */
+
+#include "statmount.h"
+#include "lapi/stat.h"
+#include "lapi/sched.h"
+#include <linux/btrfs.h>
+
+#define MNTPOINT "mntpoint"
+
+static struct statmount *st_mount;
+static struct statx *sx_mount;
+static struct statfs *sf_mount;
+
+static void run(void)
+{
+ memset(st_mount, 0, sizeof(struct statmount));
+
+ TST_EXP_PASS(statmount(
+ sx_mount->stx_mnt_id,
+ STATMOUNT_SB_BASIC,
+ st_mount,
+ sizeof(struct statmount),
+ 0));
+
+ if (TST_RET == -1)
+ return;
+
+ 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);
+}
+
+static void setup(void)
+{
+ SAFE_STATX(AT_FDCWD, MNTPOINT, 0, STATX_MNT_ID_UNIQUE, sx_mount);
+ SAFE_STATFS(MNTPOINT, sf_mount);
+}
+
+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",
+ "btrfs",
+ NULL
+ },
+ .bufs = (struct tst_buffers []) {
+ {&st_mount, .size = sizeof(struct statmount)},
+ {&sx_mount, .size = sizeof(struct statx)},
+ {&sf_mount, .size = sizeof(struct statfs)},
+ {}
+ }
+};
--
2.35.3
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 18+ messages in thread* [LTP] [PATCH v1 07/10] Add statmount03 test
2024-05-15 9:33 [LTP] [PATCH v1 00/10] statmount/listmount testing suites Andrea Cervesato
` (5 preceding siblings ...)
2024-05-15 9:33 ` [LTP] [PATCH v1 06/10] Add statmount02 test Andrea Cervesato
@ 2024-05-15 9:33 ` Andrea Cervesato
2024-05-15 9:33 ` [LTP] [PATCH v1 08/10] Add statmount04 test Andrea Cervesato
` (3 subsequent siblings)
10 siblings, 0 replies; 18+ messages in thread
From: Andrea Cervesato @ 2024-05-15 9:33 UTC (permalink / raw)
To: ltp
From: Andrea Cervesato <andrea.cervesato@suse.com>
This test verifies that statmount() is correctly reading mount
information (mount id, parent mount id, mount attributes etc.)
using STATMOUNT_MNT_BASIC.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
runtest/syscalls | 1 +
.../kernel/syscalls/statmount/.gitignore | 1 +
.../kernel/syscalls/statmount/statmount03.c | 99 +++++++++++++++++++
3 files changed, 101 insertions(+)
create mode 100644 testcases/kernel/syscalls/statmount/statmount03.c
diff --git a/runtest/syscalls b/runtest/syscalls
index 5f1df42ca..116106521 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -1539,6 +1539,7 @@ stat04_64 symlink01 -T stat04_64
statmount01 statmount01
statmount02 statmount02
+statmount03 statmount03
statfs01 statfs01
statfs01_64 statfs01_64
diff --git a/testcases/kernel/syscalls/statmount/.gitignore b/testcases/kernel/syscalls/statmount/.gitignore
index a30b9565f..2a02bf721 100644
--- a/testcases/kernel/syscalls/statmount/.gitignore
+++ b/testcases/kernel/syscalls/statmount/.gitignore
@@ -1,2 +1,3 @@
statmount01
statmount02
+statmount03
diff --git a/testcases/kernel/syscalls/statmount/statmount03.c b/testcases/kernel/syscalls/statmount/statmount03.c
new file mode 100644
index 000000000..6140940bd
--- /dev/null
+++ b/testcases/kernel/syscalls/statmount/statmount03.c
@@ -0,0 +1,99 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2024 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
+ */
+
+/**
+ * [Description]
+ *
+ * This test verifies that statmount() is correctly reading mount information
+ * (mount id, parent mount id, mount attributes etc.) using STATMOUNT_MNT_BASIC.
+ *
+ * [Algorithm]
+ *
+ * * create a mount point
+ * * create a new parent folder inside the mount point and obtain its mount info
+ * * create the new "/" mount folder and obtain its mount info
+ * * run statmount() on the mount point using STATMOUNT_MNT_BASIC
+ * * read results and check if mount info are correct
+ */
+
+#include "statmount.h"
+#include "lapi/stat.h"
+#include "lapi/sched.h"
+
+#define MNTPOINT "mntpoint"
+#define MYPARENT MNTPOINT "/myroot"
+
+static uint64_t root_id;
+static uint64_t root_id_old;
+static uint64_t parent_id;
+static uint64_t parent_id_old;
+static struct statmount *st_mount;
+
+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));
+
+ 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);
+}
+
+static void setup(void)
+{
+ struct statx sx;
+
+ SAFE_UNSHARE(CLONE_NEWNS);
+ SAFE_MKDIR(MYPARENT, 0700);
+
+ SAFE_STATX(AT_FDCWD, MYPARENT, 0, STATX_MNT_ID_UNIQUE, &sx);
+ parent_id = sx.stx_mnt_id;
+
+ SAFE_STATX(AT_FDCWD, MYPARENT, 0, STATX_MNT_ID, &sx);
+ parent_id_old = sx.stx_mnt_id;
+
+ SAFE_MOUNT("", "/", NULL, MS_REC | MS_PRIVATE, NULL);
+ SAFE_MOUNT(MYPARENT, MYPARENT, NULL, MS_BIND, NULL);
+ SAFE_CHROOT(MYPARENT);
+ SAFE_CHDIR("/");
+
+ SAFE_STATX(AT_FDCWD, "/", 0, STATX_MNT_ID_UNIQUE, &sx);
+ root_id = sx.stx_mnt_id;
+
+ SAFE_STATX(AT_FDCWD, "/", 0, STATX_MNT_ID, &sx);
+ root_id_old = sx.stx_mnt_id;
+}
+
+static struct tst_test test = {
+ .test_all = run,
+ .setup = setup,
+ .min_kver = "6.8",
+ .needs_tmpdir = 1,
+ .format_device = 1,
+ .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)},
+ {}
+ }
+};
--
2.35.3
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 18+ messages in thread* [LTP] [PATCH v1 08/10] Add statmount04 test
2024-05-15 9:33 [LTP] [PATCH v1 00/10] statmount/listmount testing suites Andrea Cervesato
` (6 preceding siblings ...)
2024-05-15 9:33 ` [LTP] [PATCH v1 07/10] Add statmount03 test Andrea Cervesato
@ 2024-05-15 9:33 ` Andrea Cervesato
2024-05-15 9:33 ` [LTP] [PATCH v1 09/10] Add statmount05 test Andrea Cervesato
` (2 subsequent siblings)
10 siblings, 0 replies; 18+ messages in thread
From: Andrea Cervesato @ 2024-05-15 9:33 UTC (permalink / raw)
To: ltp
From: Andrea Cervesato <andrea.cervesato@suse.com>
This test verifies that statmount() is correctly reading propagation
from what mount in current namespace using STATMOUNT_PROPAGATE_FROM.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
runtest/syscalls | 1 +
.../kernel/syscalls/statmount/.gitignore | 1 +
.../kernel/syscalls/statmount/statmount04.c | 133 ++++++++++++++++++
3 files changed, 135 insertions(+)
create mode 100644 testcases/kernel/syscalls/statmount/statmount04.c
diff --git a/runtest/syscalls b/runtest/syscalls
index 116106521..3c262ca3e 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -1540,6 +1540,7 @@ stat04_64 symlink01 -T stat04_64
statmount01 statmount01
statmount02 statmount02
statmount03 statmount03
+statmount04 statmount04
statfs01 statfs01
statfs01_64 statfs01_64
diff --git a/testcases/kernel/syscalls/statmount/.gitignore b/testcases/kernel/syscalls/statmount/.gitignore
index 2a02bf721..e720050b5 100644
--- a/testcases/kernel/syscalls/statmount/.gitignore
+++ b/testcases/kernel/syscalls/statmount/.gitignore
@@ -1,3 +1,4 @@
statmount01
statmount02
statmount03
+statmount04
diff --git a/testcases/kernel/syscalls/statmount/statmount04.c b/testcases/kernel/syscalls/statmount/statmount04.c
new file mode 100644
index 000000000..cfb0e9962
--- /dev/null
+++ b/testcases/kernel/syscalls/statmount/statmount04.c
@@ -0,0 +1,133 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2024 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
+ */
+
+/**
+ * [Description]
+ *
+ * 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
+ */
+
+#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");
+
+ 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);
+
+ 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));
+
+ 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();
+}
+
+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);
+}
+
+static struct tst_test test = {
+ .test_all = run,
+ .setup = setup,
+ .cleanup = cleanup,
+ .min_kver = "6.8",
+ .needs_tmpdir = 1,
+ .format_device = 1,
+ .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)},
+ {}
+ }
+};
--
2.35.3
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 18+ messages in thread* [LTP] [PATCH v1 09/10] Add statmount05 test
2024-05-15 9:33 [LTP] [PATCH v1 00/10] statmount/listmount testing suites Andrea Cervesato
` (7 preceding siblings ...)
2024-05-15 9:33 ` [LTP] [PATCH v1 08/10] Add statmount04 test Andrea Cervesato
@ 2024-05-15 9:33 ` Andrea Cervesato
2024-05-15 9:33 ` [LTP] [PATCH v1 10/10] Add statmount06 test Andrea Cervesato
2024-05-15 10:31 ` [LTP] [PATCH v1 00/10] statmount/listmount testing suites Andrea Cervesato via ltp
10 siblings, 0 replies; 18+ messages in thread
From: Andrea Cervesato @ 2024-05-15 9:33 UTC (permalink / raw)
To: ltp
From: Andrea Cervesato <andrea.cervesato@suse.com>
This test verifies STATMOUNT_MNT_ROOT and STATMOUNT_MNT_POINT
functionalities of statmount().
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
runtest/syscalls | 1 +
.../kernel/syscalls/statmount/.gitignore | 1 +
.../kernel/syscalls/statmount/statmount05.c | 138 ++++++++++++++++++
3 files changed, 140 insertions(+)
create mode 100644 testcases/kernel/syscalls/statmount/statmount05.c
diff --git a/runtest/syscalls b/runtest/syscalls
index 3c262ca3e..2984117e6 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -1541,6 +1541,7 @@ statmount01 statmount01
statmount02 statmount02
statmount03 statmount03
statmount04 statmount04
+statmount05 statmount05
statfs01 statfs01
statfs01_64 statfs01_64
diff --git a/testcases/kernel/syscalls/statmount/.gitignore b/testcases/kernel/syscalls/statmount/.gitignore
index e720050b5..f64763242 100644
--- a/testcases/kernel/syscalls/statmount/.gitignore
+++ b/testcases/kernel/syscalls/statmount/.gitignore
@@ -2,3 +2,4 @@ statmount01
statmount02
statmount03
statmount04
+statmount05
diff --git a/testcases/kernel/syscalls/statmount/statmount05.c b/testcases/kernel/syscalls/statmount/statmount05.c
new file mode 100644
index 000000000..9882719f5
--- /dev/null
+++ b/testcases/kernel/syscalls/statmount/statmount05.c
@@ -0,0 +1,138 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2024 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
+ */
+
+/**
+ * [Description]
+ *
+ * This test verifies STATMOUNT_MNT_ROOT and STATMOUNT_MNT_POINT functionalities
+ * of statmount(). In particular, STATMOUNT_MNT_ROOT will give the mount root
+ * (i.e. mount --bind /mnt /bla -> /mnt) and STATMOUNT_MNT_POINT will
+ * give the mount point (i.e. mount --bind /mnt /bla -> /bla).
+ *
+ * [Algorithm]
+ *
+ * * create a mount point
+ * * mount a folder inside the mount point
+ * * run statmount() on the mounted folder using STATMOUNT_MNT_ROOT
+ * * read results and check if contain the mount root path
+ * * run statmount() on the mounted folder using STATMOUNT_MNT_POINT
+ * * read results and check if contain the mount point path
+ */
+
+#include "statmount.h"
+#include "lapi/stat.h"
+#include "lapi/sched.h"
+
+#define MNTPOINT "mntpoint"
+#define DIRA MNTPOINT "/LTP_DIR_A"
+#define DIRB MNTPOINT "/LTP_DIR_B"
+#define SM_SIZE (1 << 10)
+
+static uint64_t root_id;
+static struct statmount *st_mount;
+static char mnt_root[PATH_MAX];
+static char mnt_point[PATH_MAX];
+
+static void test_mount_root(void)
+{
+ tst_res(TINFO, "Testing STATMOUNT_MNT_ROOT");
+
+ char *last_root;
+
+ memset(st_mount, 0, SM_SIZE);
+
+ TST_EXP_PASS(statmount(
+ root_id,
+ STATMOUNT_MNT_ROOT,
+ st_mount,
+ SM_SIZE,
+ 0));
+
+ if (TST_RET == -1)
+ return;
+
+ last_root = strrchr(mnt_root, '/');
+
+ TST_EXP_EQ_LI(st_mount->mask, STATMOUNT_MNT_ROOT);
+ TST_EXP_EXPR(strcmp(st_mount->str + st_mount->mnt_root, last_root) == 0,
+ "statmount() read '%s', expected '%s'",
+ st_mount->str + st_mount->mnt_root,
+ last_root);
+}
+
+static void test_mount_point(void)
+{
+ tst_res(TINFO, "Testing STATMOUNT_MNT_POINT");
+
+ memset(st_mount, 0, SM_SIZE);
+
+ TST_EXP_POSITIVE(statmount(
+ root_id,
+ STATMOUNT_MNT_POINT,
+ st_mount,
+ SM_SIZE,
+ 0));
+
+ if (TST_RET == -1)
+ return;
+
+ TST_EXP_EQ_LI(st_mount->mask, STATMOUNT_MNT_POINT);
+ TST_EXP_EXPR(strcmp(st_mount->str + st_mount->mnt_point, mnt_point) == 0,
+ "mount point is '%s'",
+ st_mount->str + st_mount->mnt_point);
+}
+
+static void run(void)
+{
+ test_mount_root();
+ test_mount_point();
+}
+
+static void setup(void)
+{
+ char *tmpdir;
+ struct statx sx;
+
+ tmpdir = tst_get_tmpdir();
+ snprintf(mnt_root, PATH_MAX, "%s/%s", tmpdir, DIRA);
+ snprintf(mnt_point, PATH_MAX, "%s/%s", tmpdir, DIRB);
+ free(tmpdir);
+
+ SAFE_MKDIR(mnt_root, 0700);
+ SAFE_MKDIR(mnt_point, 0700);
+ SAFE_MOUNT(mnt_root, mnt_point, "none", MS_BIND, NULL);
+
+ SAFE_STATX(AT_FDCWD, mnt_point, 0, STATX_MNT_ID_UNIQUE, &sx);
+ root_id = sx.stx_mnt_id;
+}
+
+static void cleanup(void)
+{
+ if (tst_is_mounted(DIRB))
+ SAFE_UMOUNT(DIRB);
+
+ if (tst_is_mounted(DIRA))
+ SAFE_UMOUNT(DIRA);
+}
+
+static struct tst_test test = {
+ .test_all = run,
+ .setup = setup,
+ .cleanup = cleanup,
+ .min_kver = "6.8",
+ .needs_tmpdir = 1,
+ .format_device = 1,
+ .mount_device = 1,
+ .mntpoint = MNTPOINT,
+ .all_filesystems = 1,
+ .skip_filesystems = (const char *const []) {
+ "fuse",
+ NULL
+ },
+ .bufs = (struct tst_buffers []) {
+ {&st_mount, .size = SM_SIZE},
+ {}
+ }
+};
--
2.35.3
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 18+ messages in thread* [LTP] [PATCH v1 10/10] Add statmount06 test
2024-05-15 9:33 [LTP] [PATCH v1 00/10] statmount/listmount testing suites Andrea Cervesato
` (8 preceding siblings ...)
2024-05-15 9:33 ` [LTP] [PATCH v1 09/10] Add statmount05 test Andrea Cervesato
@ 2024-05-15 9:33 ` Andrea Cervesato
2024-05-15 10:31 ` [LTP] [PATCH v1 00/10] statmount/listmount testing suites Andrea Cervesato via ltp
10 siblings, 0 replies; 18+ messages in thread
From: Andrea Cervesato @ 2024-05-15 9:33 UTC (permalink / raw)
To: ltp
From: Andrea Cervesato <andrea.cervesato@suse.com>
This test verifies that statmount() is correctly reading name of the
filesystem type using STATMOUNT_FS_TYPE.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
runtest/syscalls | 1 +
.../kernel/syscalls/statmount/.gitignore | 1 +
.../kernel/syscalls/statmount/statmount06.c | 73 +++++++++++++++++++
3 files changed, 75 insertions(+)
create mode 100644 testcases/kernel/syscalls/statmount/statmount06.c
diff --git a/runtest/syscalls b/runtest/syscalls
index 2984117e6..86e253f77 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -1542,6 +1542,7 @@ statmount02 statmount02
statmount03 statmount03
statmount04 statmount04
statmount05 statmount05
+statmount06 statmount06
statfs01 statfs01
statfs01_64 statfs01_64
diff --git a/testcases/kernel/syscalls/statmount/.gitignore b/testcases/kernel/syscalls/statmount/.gitignore
index f64763242..03a75bd40 100644
--- a/testcases/kernel/syscalls/statmount/.gitignore
+++ b/testcases/kernel/syscalls/statmount/.gitignore
@@ -3,3 +3,4 @@ statmount02
statmount03
statmount04
statmount05
+statmount06
diff --git a/testcases/kernel/syscalls/statmount/statmount06.c b/testcases/kernel/syscalls/statmount/statmount06.c
new file mode 100644
index 000000000..5c9be9be9
--- /dev/null
+++ b/testcases/kernel/syscalls/statmount/statmount06.c
@@ -0,0 +1,73 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2024 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
+ */
+
+/**
+ * [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,
+ 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);
+}
+
+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",
+ .format_device = 1,
+ .mount_device = 1,
+ .mntpoint = MNTPOINT,
+ .all_filesystems = 1,
+ .skip_filesystems = (const char *const []) {
+ "fuse",
+ NULL
+ },
+ .bufs = (struct tst_buffers []) {
+ {&st_mount, .size = SM_SIZE},
+ {}
+ }
+};
--
2.35.3
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 18+ messages in thread* Re: [LTP] [PATCH v1 00/10] statmount/listmount testing suites
2024-05-15 9:33 [LTP] [PATCH v1 00/10] statmount/listmount testing suites Andrea Cervesato
` (9 preceding siblings ...)
2024-05-15 9:33 ` [LTP] [PATCH v1 10/10] Add statmount06 test Andrea Cervesato
@ 2024-05-15 10:31 ` Andrea Cervesato via ltp
10 siblings, 0 replies; 18+ messages in thread
From: Andrea Cervesato via ltp @ 2024-05-15 10:31 UTC (permalink / raw)
To: Andrea Cervesato, ltp
Hi,
I need to send a second version because I noticed that it's not building
for all supported distros
due to missing headers inclusion.
On 5/15/24 11:33, Andrea Cervesato wrote:
> From: Andrea Cervesato <andrea.cervesato@suse.com>
>
> 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/170474400576.2602.7882507604401153304.pr-tracker-bot@kernel.org/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
>
> Andrea Cervesato (10):
> Add SAFE_STATX macro
> 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 | 67 +++++++++
> 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 | 21 +++
> runtest/syscalls | 10 ++
> .../kernel/syscalls/listmount/.gitignore | 2 +
> testcases/kernel/syscalls/listmount/Makefile | 7 +
> .../kernel/syscalls/listmount/listmount.h | 26 ++++
> .../kernel/syscalls/listmount/listmount01.c | 66 +++++++++
> .../kernel/syscalls/listmount/listmount02.c | 106 ++++++++++++++
> .../kernel/syscalls/statmount/.gitignore | 6 +
> testcases/kernel/syscalls/statmount/Makefile | 7 +
> .../kernel/syscalls/statmount/statmount.h | 26 ++++
> .../kernel/syscalls/statmount/statmount01.c | 69 +++++++++
> .../kernel/syscalls/statmount/statmount02.c | 76 ++++++++++
> .../kernel/syscalls/statmount/statmount03.c | 99 +++++++++++++
> .../kernel/syscalls/statmount/statmount04.c | 133 +++++++++++++++++
> .../kernel/syscalls/statmount/statmount05.c | 138 ++++++++++++++++++
> .../kernel/syscalls/statmount/statmount06.c | 73 +++++++++
> 38 files changed, 989 insertions(+), 1 deletion(-)
> create mode 100644 testcases/kernel/syscalls/listmount/.gitignore
> create mode 100644 testcases/kernel/syscalls/listmount/Makefile
> create mode 100644 testcases/kernel/syscalls/listmount/listmount.h
> create mode 100644 testcases/kernel/syscalls/listmount/listmount01.c
> create mode 100644 testcases/kernel/syscalls/listmount/listmount02.c
> create mode 100644 testcases/kernel/syscalls/statmount/.gitignore
> create mode 100644 testcases/kernel/syscalls/statmount/Makefile
> create mode 100644 testcases/kernel/syscalls/statmount/statmount.h
> create mode 100644 testcases/kernel/syscalls/statmount/statmount01.c
> create mode 100644 testcases/kernel/syscalls/statmount/statmount02.c
> create mode 100644 testcases/kernel/syscalls/statmount/statmount03.c
> create mode 100644 testcases/kernel/syscalls/statmount/statmount04.c
> create mode 100644 testcases/kernel/syscalls/statmount/statmount05.c
> create mode 100644 testcases/kernel/syscalls/statmount/statmount06.c
>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread