Re: [PATCH 3/5] selftests/fs/mount-notify: build with tools include dir

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, May 8, 2025 at 9:38 AM John Hubbard <jhubbard@xxxxxxxxxx> wrote:
>
> On 5/7/25 1:43 PM, Amir Goldstein wrote:
> > Copy the fanotify uapi header files to the tools include dir
> > and define __kernel_fsid_t to decouple dependency with headers_install
> > and then remove the redundant re-definitions of fanotify macros.
> >
> > Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxx>
> > ---
...
> > 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 59a71f22fb11..4f0f325379b5 100644
> > --- a/tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c
> > +++ b/tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c
> > @@ -8,33 +8,20 @@
> >   #include <string.h>
> >   #include <sys/stat.h>
> >   #include <sys/mount.h>
> > -#include <linux/fanotify.h>
> >   #include <unistd.h>
> > -#include <sys/fanotify.h>
> >   #include <sys/syscall.h>
> >
> >   #include "../../kselftest_harness.h"
> >   #include "../statmount/statmount.h"
> >
> > -#ifndef FAN_MNT_ATTACH
> > -struct fanotify_event_info_mnt {
> > -     struct fanotify_event_info_header hdr;
> > -     __u64 mnt_id;
> > -};
> > -#define FAN_MNT_ATTACH 0x01000000 /* Mount was attached */
> > -#endif
> > -
> > -#ifndef FAN_MNT_DETACH
> > -#define FAN_MNT_DETACH 0x02000000 /* Mount was detached */
> > +// Needed for linux/fanotify.h
>
> Is the comment accurate? Below, we are include sys/fanotify.h, not
> linux/fanotify.h
>

Yes, it is accurate.
sys/fanotify.h includes linux/fanotify.h
linux/fanotify.h needs __kernel_fsid_t
I considered copying posix_types.h, but it seemed wrong
and I think __kernel_fsid_t definition is the same on all archs anyway.

>
> > +#ifndef __kernel_fsid_t
> > +typedef struct {
> > +     int     val[2];
> > +} __kernel_fsid_t;
> >   #endif
> >
> > -#ifndef FAN_REPORT_MNT
> > -#define FAN_REPORT_MNT 0x00004000 /* Report mount events */
> > -#endif
> > -
> > -#ifndef FAN_MARK_MNTNS
> > -#define FAN_MARK_MNTNS 0x00000110
> > -#endif
> > +#include <sys/fanotify.h>
>
> Are you sure that you're including your newly added fanotify.h? Because
> it looks to me like you might be including your local installed version,
> instead. I don't see how it can include
>
>      tools/include/uapi/linux/fanotify.h
>
> ...with the above invocation.
>

Yes, it works.

My local installed linux/fanotify.h does not include FAN_MARK_MNTNS
it is only available in my source and tools include dirs.

Does the fact that sys/fanotify.h includes linux/fanotify.h explains what
didn't make sense to you?

Thanks,
Amir.





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux