[LTP] [PATCH v3 1/3] syscalls/fanotify: Add a helper macro which checks for the presence of specific fanotify initialization flag(s)
Matthew Bobrowski
repnop@google.com
Tue Nov 16 02:06:59 CET 2021
On Mon, Nov 15, 2021 at 10:20:18PM +0100, Petr Vorel wrote:
> Hi Matthew, Amir,
>
> Tested on two distro kernels with support (Tumbleweed and Debian unstable)
> + on various old kernels without support.
>
> Merged with very minor fixes, see diff below.
Noted the changes, they're fine by me. Thanks for the merge!
> NOTE: we now support basic static analysis + checkpatch formatting check - run
> make check in fanotify directory or make check-fanotify20.
Oh, that's great, I had no idea. Quickly running it, looks like
there's a bunch of clean up required for some of the older tests. Will
have to get around to doing that at some point.
> diff --git runtest/syscalls runtest/syscalls
> index 1e6d46744..d57c73e39 100644
> --- runtest/syscalls
> +++ runtest/syscalls
> @@ -605,6 +605,8 @@ fanotify16 fanotify16
> fanotify17 fanotify17
> fanotify18 fanotify18
> fanotify19 fanotify19
> +fanotify20 fanotify20
> +fanotify21 fanotify21
>
> ioperm01 ioperm01
> ioperm02 ioperm02
> diff --git testcases/kernel/syscalls/fanotify/fanotify20.c testcases/kernel/syscalls/fanotify/fanotify20.c
> index 9960d85eb..de0fdb782 100644
> --- testcases/kernel/syscalls/fanotify/fanotify20.c
> +++ testcases/kernel/syscalls/fanotify/fanotify20.c
> @@ -12,6 +12,9 @@
> * returns an expected error code when provided an invalid initialization flag
> * alongside FAN_REPORT_PIDFD. Additionally, it checks that the operability with
> * existing FAN_REPORT_* flags is maintained and functioning as intended.
> + *
> + * NOTE: FAN_REPORT_PIDFD support was added in v5.15-rc1 in af579beb666a
> + * ("fanotify: add pidfd support to the fanotify API").
> */
>
> #define _GNU_SOURCE
> @@ -39,7 +42,7 @@ static struct test_case_t {
> },
> {
> "pass on FAN_REPORT_PIDFD | FAN_REPORT_FID | FAN_REPORT_DFID_NAME",
> - FAN_REPORT_PIDFD | FAN_REPORT_FID | FAN_REPORT_DFID_NAME ,
> + FAN_REPORT_PIDFD | FAN_REPORT_FID | FAN_REPORT_DFID_NAME,
> 0,
> 0,
> },
> diff --git testcases/kernel/syscalls/fanotify/fanotify21.c testcases/kernel/syscalls/fanotify/fanotify21.c
> index e842dad17..6ae70c57e 100644
> --- testcases/kernel/syscalls/fanotify/fanotify21.c
> +++ testcases/kernel/syscalls/fanotify/fanotify21.c
> @@ -11,6 +11,9 @@
> * A test which verifies whether the returned struct
> * fanotify_event_info_pidfd in FAN_REPORT_PIDFD mode contains the
> * expected set of information.
> + *
> + * NOTE: FAN_REPORT_PIDFD support was added in v5.15-rc1 in af579beb666a
> + * ("fanotify: add pidfd support to the fanotify API").
> */
>
> #define _GNU_SOURCE
> @@ -56,7 +59,7 @@ struct test_case_t {
>
> static int fanotify_fd;
> static char event_buf[BUF_SZ];
> -static struct pidfd_fdinfo_t *self_pidfd_fdinfo = NULL;
> +static struct pidfd_fdinfo_t *self_pidfd_fdinfo;
>
> static struct pidfd_fdinfo_t *read_pidfd_fdinfo(int pidfd)
> {
> @@ -158,7 +161,7 @@ static void do_test(unsigned int num)
> * buffer.
> */
> len = SAFE_READ(0, fanotify_fd, event_buf, sizeof(event_buf));
> - while(i < len) {
> + while (i < len) {
> struct fanotify_event_metadata *event;
> struct fanotify_event_info_pidfd *info;
> struct pidfd_fdinfo_t *event_pidfd_fdinfo = NULL;
> @@ -197,7 +200,7 @@ static void do_test(unsigned int num)
> tst_res(TFAIL,
> "pidfd creation failed for pid: %u with pidfd error value "
> "set to: %d",
> - (unsigned)event->pid,
> + (unsigned int)event->pid,
> info->pidfd);
> goto next_event;
> } else if (tc->want_pidfd_err &&
> @@ -205,14 +208,14 @@ static void do_test(unsigned int num)
> tst_res(TFAIL,
> "pidfd set to an unexpected error: %d for pid: %u",
> info->pidfd,
> - (unsigned)event->pid);
> + (unsigned int)event->pid);
> goto next_event;
> } else if (tc->want_pidfd_err &&
> info->pidfd == tc->want_pidfd_err) {
> tst_res(TPASS,
> "pid: %u terminated before pidfd was created, "
> "pidfd set to the value of: %d, as expected",
> - (unsigned)event->pid,
> + (unsigned int)event->pid,
> FAN_NOPIDFD);
> goto next_event;
> }
> @@ -227,15 +230,15 @@ static void do_test(unsigned int num)
> "reading fdinfo for pidfd: %d "
> "describing pid: %u failed",
> info->pidfd,
> - (unsigned)event->pid);
> + (unsigned int)event->pid);
> goto next_event;
> } else if (event_pidfd_fdinfo->pid != event->pid) {
> tst_res(TFAIL,
> "pidfd provided for incorrect pid "
> "(expected pidfd for pid: %u, got pidfd for "
> "pid: %u)",
> - (unsigned)event->pid,
> - (unsigned)event_pidfd_fdinfo->pid);
> + (unsigned int)event->pid,
> + (unsigned int)event_pidfd_fdinfo->pid);
> goto next_event;
> } else if (memcmp(event_pidfd_fdinfo, self_pidfd_fdinfo,
> sizeof(struct pidfd_fdinfo_t))) {
> @@ -261,7 +264,7 @@ static void do_test(unsigned int num)
> "mask: %lld, pid: %u, fd: %d, "
> "pidfd: %d, info_type: %d, info_len: %d",
> (unsigned long long)event->mask,
> - (unsigned)event->pid,
> + (unsigned int)event->pid,
> event->fd,
> info->pidfd,
> info->hdr.info_type,
/M
More information about the ltp
mailing list