Message ID | 20231129115440.19100-2-jack@suse.cz |
---|---|
State | Changes Requested |
Headers | show |
Series | fanotify: Make feature tests operate against tested path | expand |
On Wed, Nov 29, 2023 at 1:54 PM Jan Kara <jack@suse.cz> wrote: > > Provide helper checking whether a mark is supported on a filesystem > since some marks need not be available on all filesystems (e.g. btrfs > subvolumes). Also convert REQUIRE_MARK_TYPE_SUPPORTED_BY_KERNEL() and > its only user to use this new function. > > Signed-off-by: Jan Kara <jack@suse.cz> > --- > testcases/kernel/syscalls/fanotify/fanotify.h | 11 ++++++++--- > testcases/kernel/syscalls/fanotify/fanotify23.c | 2 +- > 2 files changed, 9 insertions(+), 4 deletions(-) > > diff --git a/testcases/kernel/syscalls/fanotify/fanotify.h b/testcases/kernel/syscalls/fanotify/fanotify.h > index ee74c2fffbd5..f28da1a5ee55 100644 > --- a/testcases/kernel/syscalls/fanotify/fanotify.h > +++ b/testcases/kernel/syscalls/fanotify/fanotify.h > @@ -226,6 +226,11 @@ static inline int fanotify_init_flags_supported_by_kernel(unsigned int flags) > return fanotify_init_flags_supported_on_fs(flags, NULL); > } > > +static inline int fanotify_mark_supported_on_fs(uint64_t flag, const char *fname) > +{ > + return fanotify_flags_supported_on_fs(FAN_CLASS_CONTENT, flag, FAN_ACCESS, fname); Why not FAN_CLASS_NOTIF? > +} > + > #define TST_FANOTIFY_INIT_KNOWN_FLAGS \ > (FAN_REPORT_DFID_NAME_TARGET | FAN_REPORT_TID | FAN_REPORT_PIDFD | \ > FAN_CLASS_NOTIF | FAN_CLASS_CONTENT | FAN_CLASS_PRE_CONTENT) > @@ -333,9 +338,9 @@ static inline int fanotify_handle_supported_by_kernel(int flag) > return 0; > } > > -#define REQUIRE_MARK_TYPE_SUPPORTED_BY_KERNEL(mark_type) \ > +#define REQUIRE_MARK_TYPE_SUPPORTED_ON_FS(mark_type, fname) \ > fanotify_flags_err_msg(#mark_type, __FILE__, __LINE__, tst_brk_, \ > - fanotify_mark_supported_by_kernel(mark_type)) > + fanotify_mark_supported_on_fs(mark_type, fname)) > > #define REQUIRE_HANDLE_TYPE_SUPPORTED_BY_KERNEL(handle_type) \ > fanotify_flags_err_msg(#handle_type, __FILE__, __LINE__, tst_brk_, \ > @@ -343,7 +348,7 @@ static inline int fanotify_handle_supported_by_kernel(int flag) > > #define REQUIRE_FANOTIFY_EVENTS_SUPPORTED_ON_FS(init_flags, mark_type, mask, fname) do { \ > if (mark_type) \ > - REQUIRE_MARK_TYPE_SUPPORTED_BY_KERNEL(mark_type); \ > + REQUIRE_MARK_TYPE_SUPPORTED_ON_FS(mark_type, fname); \ > if (init_flags) \ > REQUIRE_FANOTIFY_INIT_FLAGS_SUPPORTED_ON_FS(init_flags, fname); \ > fanotify_flags_err_msg(#mask, __FILE__, __LINE__, tst_brk_, \ > diff --git a/testcases/kernel/syscalls/fanotify/fanotify23.c b/testcases/kernel/syscalls/fanotify/fanotify23.c > index fb812c51e34e..5a03503e952a 100644 > --- a/testcases/kernel/syscalls/fanotify/fanotify23.c > +++ b/testcases/kernel/syscalls/fanotify/fanotify23.c > @@ -230,7 +230,7 @@ static void setup(void) > { > SAFE_TOUCH(TEST_FILE, 0666, NULL); > > - REQUIRE_MARK_TYPE_SUPPORTED_BY_KERNEL(FAN_MARK_EVICTABLE); > + REQUIRE_MARK_TYPE_SUPPORTED_ON_FS(FAN_MARK_EVICTABLE, "."); > REQUIRE_FANOTIFY_EVENTS_SUPPORTED_ON_FS(FAN_CLASS_NOTIF|FAN_REPORT_FID, > FAN_MARK_FILESYSTEM, > FAN_ATTRIB, "."); > -- > 2.35.3 >
On Wed 29-11-23 16:47:56, Amir Goldstein wrote: > On Wed, Nov 29, 2023 at 1:54 PM Jan Kara <jack@suse.cz> wrote: > > > > Provide helper checking whether a mark is supported on a filesystem > > since some marks need not be available on all filesystems (e.g. btrfs > > subvolumes). Also convert REQUIRE_MARK_TYPE_SUPPORTED_BY_KERNEL() and > > its only user to use this new function. > > > > Signed-off-by: Jan Kara <jack@suse.cz> ... > > +static inline int fanotify_mark_supported_on_fs(uint64_t flag, const char *fname) > > +{ > > + return fanotify_flags_supported_on_fs(FAN_CLASS_CONTENT, flag, FAN_ACCESS, fname); > > Why not FAN_CLASS_NOTIF? Cut'n'paste from somewhere ;) Fixed. Thanks! Honza
diff --git a/testcases/kernel/syscalls/fanotify/fanotify.h b/testcases/kernel/syscalls/fanotify/fanotify.h index ee74c2fffbd5..f28da1a5ee55 100644 --- a/testcases/kernel/syscalls/fanotify/fanotify.h +++ b/testcases/kernel/syscalls/fanotify/fanotify.h @@ -226,6 +226,11 @@ static inline int fanotify_init_flags_supported_by_kernel(unsigned int flags) return fanotify_init_flags_supported_on_fs(flags, NULL); } +static inline int fanotify_mark_supported_on_fs(uint64_t flag, const char *fname) +{ + return fanotify_flags_supported_on_fs(FAN_CLASS_CONTENT, flag, FAN_ACCESS, fname); +} + #define TST_FANOTIFY_INIT_KNOWN_FLAGS \ (FAN_REPORT_DFID_NAME_TARGET | FAN_REPORT_TID | FAN_REPORT_PIDFD | \ FAN_CLASS_NOTIF | FAN_CLASS_CONTENT | FAN_CLASS_PRE_CONTENT) @@ -333,9 +338,9 @@ static inline int fanotify_handle_supported_by_kernel(int flag) return 0; } -#define REQUIRE_MARK_TYPE_SUPPORTED_BY_KERNEL(mark_type) \ +#define REQUIRE_MARK_TYPE_SUPPORTED_ON_FS(mark_type, fname) \ fanotify_flags_err_msg(#mark_type, __FILE__, __LINE__, tst_brk_, \ - fanotify_mark_supported_by_kernel(mark_type)) + fanotify_mark_supported_on_fs(mark_type, fname)) #define REQUIRE_HANDLE_TYPE_SUPPORTED_BY_KERNEL(handle_type) \ fanotify_flags_err_msg(#handle_type, __FILE__, __LINE__, tst_brk_, \ @@ -343,7 +348,7 @@ static inline int fanotify_handle_supported_by_kernel(int flag) #define REQUIRE_FANOTIFY_EVENTS_SUPPORTED_ON_FS(init_flags, mark_type, mask, fname) do { \ if (mark_type) \ - REQUIRE_MARK_TYPE_SUPPORTED_BY_KERNEL(mark_type); \ + REQUIRE_MARK_TYPE_SUPPORTED_ON_FS(mark_type, fname); \ if (init_flags) \ REQUIRE_FANOTIFY_INIT_FLAGS_SUPPORTED_ON_FS(init_flags, fname); \ fanotify_flags_err_msg(#mask, __FILE__, __LINE__, tst_brk_, \ diff --git a/testcases/kernel/syscalls/fanotify/fanotify23.c b/testcases/kernel/syscalls/fanotify/fanotify23.c index fb812c51e34e..5a03503e952a 100644 --- a/testcases/kernel/syscalls/fanotify/fanotify23.c +++ b/testcases/kernel/syscalls/fanotify/fanotify23.c @@ -230,7 +230,7 @@ static void setup(void) { SAFE_TOUCH(TEST_FILE, 0666, NULL); - REQUIRE_MARK_TYPE_SUPPORTED_BY_KERNEL(FAN_MARK_EVICTABLE); + REQUIRE_MARK_TYPE_SUPPORTED_ON_FS(FAN_MARK_EVICTABLE, "."); REQUIRE_FANOTIFY_EVENTS_SUPPORTED_ON_FS(FAN_CLASS_NOTIF|FAN_REPORT_FID, FAN_MARK_FILESYSTEM, FAN_ATTRIB, ".");
Provide helper checking whether a mark is supported on a filesystem since some marks need not be available on all filesystems (e.g. btrfs subvolumes). Also convert REQUIRE_MARK_TYPE_SUPPORTED_BY_KERNEL() and its only user to use this new function. Signed-off-by: Jan Kara <jack@suse.cz> --- testcases/kernel/syscalls/fanotify/fanotify.h | 11 ++++++++--- testcases/kernel/syscalls/fanotify/fanotify23.c | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-)