From: Andrea Cervesato via ltp <ltp@lists.linux.it>
To: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v4 01/13] Add SAFE_STATX macro
Date: Mon, 9 Sep 2024 18:21:26 +0200 [thread overview]
Message-ID: <d13a2438-cbc2-4a67-8df0-61bc1ce26f5a@suse.com> (raw)
In-Reply-To: <20240909-listmount_statmount-v4-1-39558204ddf0@suse.com>
Hi!
read below...
On 9/9/24 12:00, Andrea Cervesato wrote:
> From: Andrea Cervesato <andrea.cervesato@suse.com>
>
> Reviewed-by: Avinesh Kumar <akumar@suse.de>
> Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
> ---
> compile_flags.txt | 1 +
> include/lapi/stat.h | 111 +++++++++++++++------
> testcases/kernel/syscalls/fchmodat2/fchmodat2_01.c | 2 +
> 3 files changed, 82 insertions(+), 32 deletions(-)
>
> diff --git a/compile_flags.txt b/compile_flags.txt
> new file mode 100644
> index 000000000..3e2e7607a
> --- /dev/null
> +++ b/compile_flags.txt
This is a file for configuring clangd. I guess I had a "git add ." in
the folder. Please ignore this part of the patch.
Andrea
> @@ -0,0 +1 @@
> +-Iinclude/
> diff --git a/include/lapi/stat.h b/include/lapi/stat.h
> index 030646a9e..1fa5f4eaf 100644
> --- a/include/lapi/stat.h
> +++ b/include/lapi/stat.h
> @@ -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__ */
> diff --git a/testcases/kernel/syscalls/fchmodat2/fchmodat2_01.c b/testcases/kernel/syscalls/fchmodat2/fchmodat2_01.c
> index a9932287c..f026b18df 100644
> --- a/testcases/kernel/syscalls/fchmodat2/fchmodat2_01.c
> +++ b/testcases/kernel/syscalls/fchmodat2/fchmodat2_01.c
> @@ -12,6 +12,8 @@
> * usage on symlinks will raise EOPNOTSUPP.
> */
>
> +#define _GNU_SOURCE
> +
> #include "tst_test.h"
> #include "tst_safe_file_at.h"
> #include "lapi/fcntl.h"
>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2024-09-09 16:21 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-09 10:00 [LTP] [PATCH v4 00/13] statmount/listmount testing suites Andrea Cervesato
2024-09-09 10:00 ` [LTP] [PATCH v4 01/13] Add SAFE_STATX macro Andrea Cervesato
2024-09-09 16:21 ` Andrea Cervesato via ltp [this message]
2024-10-02 12:27 ` Cyril Hrubis
2024-10-02 13:00 ` Andrea Cervesato via ltp
2024-09-09 10:00 ` [LTP] [PATCH v4 02/13] Add listmount/statmount syscalls Andrea Cervesato
2024-10-02 12:30 ` Cyril Hrubis
2024-09-09 10:00 ` [LTP] [PATCH v4 03/13] Add listmount/statmount fallback declarations Andrea Cervesato
2024-10-02 14:12 ` Cyril Hrubis
2024-09-09 10:00 ` [LTP] [PATCH v4 04/13] Add listmount01 test Andrea Cervesato
2024-10-02 14:05 ` Cyril Hrubis
2024-10-02 14:14 ` Cyril Hrubis
2024-09-09 10:00 ` [LTP] [PATCH v4 05/13] Add listmount02 test Andrea Cervesato
2024-10-02 14:37 ` Cyril Hrubis
2024-09-09 10:00 ` [LTP] [PATCH v4 06/13] Add statmount01 test Andrea Cervesato
2024-10-02 14:45 ` Cyril Hrubis
2024-09-09 10:00 ` [LTP] [PATCH v4 07/13] Add statmount02 test Andrea Cervesato
2024-10-02 15:15 ` Cyril Hrubis
2024-09-09 10:00 ` [LTP] [PATCH v4 08/13] Add statmount03 test Andrea Cervesato
2024-10-03 13:27 ` Cyril Hrubis
2024-09-09 10:00 ` [LTP] [PATCH v4 09/13] Add statmount04 test Andrea Cervesato
2024-10-03 13:51 ` Cyril Hrubis
2024-09-09 10:00 ` [LTP] [PATCH v4 10/13] Add statmount05 test Andrea Cervesato
2024-10-03 14:09 ` Cyril Hrubis
2024-09-09 10:00 ` [LTP] [PATCH v4 11/13] Add TST_EXP_EQ_STR macro Andrea Cervesato
2024-10-03 14:13 ` Cyril Hrubis
2024-09-09 10:00 ` [LTP] [PATCH v4 12/13] Add statmount06 test Andrea Cervesato
2024-10-03 14:20 ` Cyril Hrubis
2024-09-09 10:00 ` [LTP] [PATCH v4 13/13] Add statmount07 test Andrea Cervesato
2024-10-03 14:34 ` Cyril Hrubis
2024-10-04 8:19 ` Andrea Cervesato via ltp
2024-10-04 9:17 ` Cyril Hrubis
2024-10-04 11:03 ` Andrea Cervesato via ltp
2024-10-04 12:02 ` Jan Kara
2024-10-03 14:42 ` [LTP] [PATCH v4 00/13] statmount/listmount testing suites Cyril Hrubis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d13a2438-cbc2-4a67-8df0-61bc1ce26f5a@suse.com \
--to=ltp@lists.linux.it \
--cc=andrea.cervesato@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox