Sorry, I forget to attach the error message in my previous email.

CC       mount-notify_test_ns
mount-notify_test_ns.c:23:3: error: conflicting types for
‘__kernel_fsid_t’; have ‘struct <anonymous>’
   23 | } __kernel_fsid_t;
      |   ^~~~~~~~~~~~~~~
In file included from /tmp/kselftest/usr/include/asm/posix_types_64.h:18,
                 from /tmp/kselftest/usr/include/asm/posix_types.h:7,
                 from /tmp/kselftest/usr/include/linux/posix_types.h:36,
                 from /tmp/kselftest/usr/include/linux/types.h:9,
                 from /tmp/kselftest/usr/include/linux/sched/types.h:5,
                 from /usr/include/bits/sched.h:63,
                 from /usr/include/sched.h:43,
                 from mount-notify_test_ns.c:6:
/tmp/kselftest/usr/include/asm-generic/posix_types.h:81:3: note:
previous declaration of ‘__kernel_fsid_t’ with type ‘__kernel_fsid_t’
   81 | } __kernel_fsid_t;
      |   ^~~~~~~~~~~~~~~
make[1]: *** [../../lib.mk:222:
/tmp/kselftest/kselftest/filesystems/mount-notify/mount-notify_test_ns]
Error 1
make[1]: Nothing to be done for 'all'.

Best Regards,
Xing






On Wed, Aug 13, 2025 at 11:17 AM Xing Guo <[email protected]> wrote:
>
> Commit c6d9775c2066 ("selftests/fs/mount-notify: build with tools include
> dir") introduces the struct __kernel_fsid_t to decouple dependency with
> headers_install.  The commit forgets to define a macro for __kernel_fsid_t
> and it will cause type re-definition issue.
>
> Signed-off-by: Xing Guo <[email protected]>
> ---
>  .../mount-notify/mount-notify_test.c           | 17 ++++++++---------
>  .../mount-notify/mount-notify_test_ns.c        | 18 ++++++++----------
>  2 files changed, 16 insertions(+), 19 deletions(-)
>
> diff --git 
> a/tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c 
> b/tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c
> index 63ce708d93ed..e4b7c2b457ee 100644
> --- a/tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c
> +++ b/tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c
> @@ -2,6 +2,13 @@
>  // Copyright (c) 2025 Miklos Szeredi <[email protected]>
>
>  #define _GNU_SOURCE
> +
> +// Needed for linux/fanotify.h
> +typedef struct {
> +       int     val[2];
> +} __kernel_fsid_t;
> +#define __kernel_fsid_t __kernel_fsid_t
> +
>  #include <fcntl.h>
>  #include <sched.h>
>  #include <stdio.h>
> @@ -10,20 +17,12 @@
>  #include <sys/mount.h>
>  #include <unistd.h>
>  #include <sys/syscall.h>
> +#include <sys/fanotify.h>
>
>  #include "../../kselftest_harness.h"
>  #include "../statmount/statmount.h"
>  #include "../utils.h"
>
> -// Needed for linux/fanotify.h
> -#ifndef __kernel_fsid_t
> -typedef struct {
> -       int     val[2];
> -} __kernel_fsid_t;
> -#endif
> -
> -#include <sys/fanotify.h>
> -
>  static const char root_mntpoint_templ[] = 
> "/tmp/mount-notify_test_root.XXXXXX";
>
>  static const int mark_cmds[] = {
> diff --git 
> a/tools/testing/selftests/filesystems/mount-notify/mount-notify_test_ns.c 
> b/tools/testing/selftests/filesystems/mount-notify/mount-notify_test_ns.c
> index 090a5ca65004..9f57ca46e3af 100644
> --- a/tools/testing/selftests/filesystems/mount-notify/mount-notify_test_ns.c
> +++ b/tools/testing/selftests/filesystems/mount-notify/mount-notify_test_ns.c
> @@ -2,6 +2,13 @@
>  // Copyright (c) 2025 Miklos Szeredi <[email protected]>
>
>  #define _GNU_SOURCE
> +
> +// Needed for linux/fanotify.h
> +typedef struct {
> +       int     val[2];
> +} __kernel_fsid_t;
> +#define __kernel_fsid_t __kernel_fsid_t
> +
>  #include <fcntl.h>
>  #include <sched.h>
>  #include <stdio.h>
> @@ -10,21 +17,12 @@
>  #include <sys/mount.h>
>  #include <unistd.h>
>  #include <sys/syscall.h>
> +#include <sys/fanotify.h>
>
>  #include "../../kselftest_harness.h"
> -#include "../../pidfd/pidfd.h"
>  #include "../statmount/statmount.h"
>  #include "../utils.h"
>
> -// Needed for linux/fanotify.h
> -#ifndef __kernel_fsid_t
> -typedef struct {
> -       int     val[2];
> -} __kernel_fsid_t;
> -#endif
> -
> -#include <sys/fanotify.h>
> -
>  static const char root_mntpoint_templ[] = 
> "/tmp/mount-notify_test_root.XXXXXX";
>
>  static const int mark_types[] = {
> --
> 2.50.1
>

Reply via email to