fanotify: Make feature tests operate against tested path
v2 cover fanotify: Make feature tests operate against tested path
Hello,
some of the fanotify features are not available across all filesystems. Thus depending on which path is used for placing fanotify mark the feature may or may not be available. This leads to test failures when some feature is supported in tmpdir but not on the tested filesystem. Convert all of the fanotify feature tests to be performed on the path actually being used for testing.
Honza
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 1/6 fanotify: Generalize helper fanotify_flags_supported_on_fs()
From: Amir Goldstein <[email protected]>
The helper fanotify_init_flags_supported_on_fs() is used to check if fanotify init flags (usually FAN_REPORT_FID) are supported by kernel and on a specific filesystem.
The helper fanotify_mark_supported_by_kernel() does not check for support on a specific filesystem.
There are now specific filesystems (e.g. overlayfs, fuse) that do not support FAN_REPORT_FID, but not with filesystem and mount mark types.
Generelize the helper fanotify_init_flags_supported_on_fs() to be used to check also support for mark flags and event flags on a specific filesystem.
The helper fanotify_init_flags_err_msg() was also renamed to reflect the fact that it is already used to report an error message for mark flags and handle flags, not only init flags.
--- testcases/kernel/syscalls/fanotify/fanotify.h | 43 ++++++++++++------- 1 file changed, 27 insertions(+), 16 deletions(-)
testcases/kernel/syscalls/fanotify/fanotify.h +27 -16
@@ -176,17 +176,20 @@ static inline int fanotify_events_supported_by_kernel(uint64_t mask, }/* -* @return 0: fanotify supported both in kernel and on tested filesystem -* @return -1: @flags not supported in kernel -* @return -2: @flags not supported on tested filesystem (tested if @fname is not NULL) -* @return -3: @flags not supported on overlayfs (tested if @fname == OVL_MNT) +* @return 0: fanotify flags supported both in kernel and on tested filesystem +* @return -1: @init_flags not supported in kernel +* @return -2: @mark_flags not supported on tested filesystem (tested if @fname is not NULL) +* @return -3: @mark_flags not supported on overlayfs (tested if @fname == OVL_MNT) */ -static inline int fanotify_init_flags_supported_on_fs (unsigned int flags,const char *fname) +static inline int fanotify_flags_supported_on_fs (unsigned int init_flags, +unsigned int mark_flags, +unsigned int event_flags, +const char *fname) {int fd;int rval =0 ; - fd =fanotify_init (flags,O_RDONLY ); + fd =fanotify_init (init_flags,O_RDONLY );if (fd <0 ) {if (errno ==ENOSYS )
@@ -198,7 +201,7 @@ static inline int fanotify_init_flags_supported_on_fs(unsigned int flags, consttst_brk (TBROK |TERRNO ,"fanotify_init() failed" ); } -if (fname &&fanotify_mark (fd,FAN_MARK_ADD ,FAN_ACCESS ,AT_FDCWD , fname) <0 ) { +if (fname &&fanotify_mark (fd,FAN_MARK_ADD | mark_flags, event_flags,AT_FDCWD , fname) <0 ) {if (errno ==ENODEV || errno ==EOPNOTSUPP || errno ==EXDEV ) { rval =strcmp (fname,OVL_MNT ) ?-2 :-3 ; }else {
@@ -213,6 +216,11 @@ static inline int fanotify_init_flags_supported_on_fs(unsigned int flags, constreturn rval; } +static inline int fanotify_init_flags_supported_on_fs (unsigned int flags,const char *fname) +{ +return fanotify_flags_supported_on_fs (flags,FAN_MARK_INODE ,FAN_ACCESS , fname); +} +static inline int fanotify_init_flags_supported_by_kernel (unsigned int flags) {return fanotify_init_flags_supported_on_fs (flags,NULL );
@@ -264,7 +272,7 @@ static inline unsigned int fanotify_get_supported_init_flags(unsigned int flags,typedef void (*tst_res_func_t )(const char *file,const int lineno,int ttype,const char *fmt, ...); -static inline void fanotify_init_flags_err_msg (const char *flags_str, +static inline void fanotify_flags_err_msg (const char *flags_str,const char *file,const int lineno,tst_res_func_t res_func,int fail) {if (fail ==-1 )
@@ -278,14 +286,17 @@ static inline void fanotify_init_flags_err_msg(const char *flags_str, }#define FANOTIFY_INIT_FLAGS_ERR_MSG (flags, fail) \ - fanotify_init_flags_err_msg(#flags, __FILE__, __LINE__, tst_res_, (fail)) + fanotify_flags_err_msg(#flags, __FILE__, __LINE__, tst_res_, (fail)) + +#define FANOTIFY_MARK_FLAGS_ERR_MSG (mark, fail) \ + fanotify_flags_err_msg((mark)->name, __FILE__, __LINE__, tst_res_, (fail))#define REQUIRE_FANOTIFY_INIT_FLAGS_SUPPORTED_ON_FS (flags, fname) \ - fanotify_init_flags_err_msg(#flags, __FILE__, __LINE__, tst_brk_, \ + fanotify_flags_err_msg(#flags, __FILE__, __LINE__, tst_brk_, \ fanotify_init_flags_supported_on_fs(flags, fname))#define REQUIRE_FANOTIFY_INIT_FLAGS_SUPPORTED_BY_KERNEL (flags) \ - fanotify_init_flags_err_msg(#flags, __FILE__, __LINE__, tst_brk_, \ + fanotify_flags_err_msg(#flags, __FILE__, __LINE__, tst_brk_, \ fanotify_init_flags_supported_by_kernel(flags))static inline int fanotify_mark_supported_by_kernel (uint64_t flag)
@@ -323,19 +334,19 @@ static inline int fanotify_handle_supported_by_kernel(int flag) }#define REQUIRE_MARK_TYPE_SUPPORTED_BY_KERNEL (mark_type) \ - fanotify_init_flags_err_msg(#mark_type, __FILE__, __LINE__, tst_brk_, \ - fanotify_mark_supported_by_kernel(mark_type)) + fanotify_flags_err_msg(#mark_type, __FILE__, __LINE__, tst_brk_, \ + fanotify_mark_supported_by_kernel(mark_type))#define REQUIRE_HANDLE_TYPE_SUPPORTED_BY_KERNEL (handle_type) \ - fanotify_init_flags_err_msg(#handle_type, __FILE__, __LINE__, tst_brk_, \ - fanotify_handle_supported_by_kernel(handle_type)) + fanotify_flags_err_msg(#handle_type, __FILE__, __LINE__, tst_brk_, \ + fanotify_handle_supported_by_kernel(handle_type))#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); \ if (init_flags) \ REQUIRE_FANOTIFY_INIT_FLAGS_SUPPORTED_ON_FS(init_flags, fname); \ - fanotify_init_flags_err_msg(#mask, __FILE__, __LINE__, tst_brk_, \ + fanotify_flags_err_msg(#mask, __FILE__, __LINE__, tst_brk_, \ fanotify_events_supported_by_kernel(mask, init_flags, mark_type)); \ } while (0)
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 2/6 fanotify: Provide fanotify_mark_supported_on_fs()
In reply to Jan KaraProvide 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.
--- testcases/kernel/syscalls/fanotify/fanotify.h | 11 ++++++++--- testcases/kernel/syscalls/fanotify/fanotify23.c | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-)
testcases/kernel/syscalls/fanotify/fanotify.h +8 -3
@@ -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_, \
testcases/kernel/syscalls/fanotify/fanotify23.c +1 -1
@@ -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 ,"." );
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 2/6] fanotify: Provide fanotify_mark_supported_on_fs()
Quoted 17 lines · Jan Kara
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 <[email protected]>--- testcases/kernel/syscalls/fanotify/fanotify.h | 11 ++++++++--- testcases/kernel/syscalls/fanotify/fanotify23.c | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-)testcases/kernel/syscalls/fanotify/fanotify.h +0
-0
testcases/kernel/syscalls/fanotify/fanotify.h static inline int fanotify_init_flags_supported_by_kernel(unsigned int flags) · line 231
Quoted 6 lines
testcases/kernel/syscalls/fanotify/fanotify.h +3
-0@@ -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?
Quoted 42 lines
testcases/kernel/syscalls/fanotify/fanotify.h +5
-3+} +#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_, \testcases/kernel/syscalls/fanotify/fanotify23.c +1
-2@@ -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
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 2/6] fanotify: Provide fanotify_mark_supported_on_fs()
Quoted 8 lines · Amir Goldstein
Quoted 7 lines · Jan Kara
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 <[email protected]>
...
Quoted 5 lines
testcases/kernel/syscalls/fanotify/fanotify.h static inline int fanotify_init_flags_supported_by_kernel(unsigned int flags) · line 231
Quoted 3 lines
testcases/kernel/syscalls/fanotify/fanotify.h +3
-0+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
Signature · 5 lines
Jan Kara <[email protected]> SUSE Labs, CR -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 3/6 fanotify: Switch event and mark tests to *_on_fs() variant
In reply to Jan KaraSwitch event availability and mark type availability tests to be performed on the filesystem actually used for testing instead of on the current directory. This is more reliable as not all filesystems support the same set of features.
--- testcases/kernel/syscalls/fanotify/fanotify.h | 2 +- testcases/kernel/syscalls/fanotify/fanotify01.c | 2 +- testcases/kernel/syscalls/fanotify/fanotify03.c | 7 ++++--- testcases/kernel/syscalls/fanotify/fanotify09.c | 3 ++- testcases/kernel/syscalls/fanotify/fanotify10.c | 13 ++++++++----- testcases/kernel/syscalls/fanotify/fanotify11.c | 2 +- testcases/kernel/syscalls/fanotify/fanotify12.c | 5 ++--- testcases/kernel/syscalls/fanotify/fanotify13.c | 3 ++- testcases/kernel/syscalls/fanotify/fanotify14.c | 3 ++- testcases/kernel/syscalls/fanotify/fanotify16.c | 3 ++- 10 files changed, 25 insertions(+), 18 deletions(-)
testcases/kernel/syscalls/fanotify/fanotify.h +1 -1
@@ -352,7 +352,7 @@ static inline int fanotify_handle_supported_by_kernel(int flag)if (init_flags) \REQUIRE_FANOTIFY_INIT_FLAGS_SUPPORTED_ON_FS (init_flags, fname); \ fanotify_flags_err_msg(#mask, __FILE__, __LINE__, tst_brk_, \ - fanotify_events_supported_by_kernel(mask, init_flags, mark_type)); \ + fanotify_flags_supported_on_fs(init_flags, mark_type, mask, fname)); \ } while (0) static inline struct fanotify_event_info_header *get_event_info(
testcases/kernel/syscalls/fanotify/fanotify01.c +1 -1
@@ -341,7 +341,7 @@ static void setup(void)SAFE_FILE_PRINTF (fname,"1" ); fan_report_fid_unsupported =fanotify_init_flags_supported_on_fs (FAN_REPORT_FID , fname); - filesystem_mark_unsupported =fanotify_mark_supported_by_kernel (FAN_MARK_FILESYSTEM ); + filesystem_mark_unsupported =fanotify_mark_supported_on_fs (FAN_MARK_FILESYSTEM , fname); }static void cleanup (void )
testcases/kernel/syscalls/fanotify/fanotify03.c +4 -3
@@ -322,12 +322,13 @@ static void setup(void) {require_fanotify_access_permissions_supported_by_kernel (); - filesystem_mark_unsupported =fanotify_mark_supported_by_kernel (FAN_MARK_FILESYSTEM ); - exec_events_unsupported =fanotify_events_supported_by_kernel (FAN_OPEN_EXEC_PERM , -FAN_CLASS_CONTENT ,0 );sprintf (fname,MOUNT_PATH "/fname_%d" ,getpid ());SAFE_FILE_PRINTF (fname,"1" ); + filesystem_mark_unsupported =fanotify_mark_supported_on_fs (FAN_MARK_FILESYSTEM , fname); + exec_events_unsupported =fanotify_flags_supported_on_fs (FAN_CLASS_CONTENT , +0 ,FAN_OPEN_EXEC_PERM , fname); +SAFE_CP (TEST_APP ,FILE_EXEC_PATH ); }
testcases/kernel/syscalls/fanotify/fanotify09.c +2 -1
@@ -482,7 +482,8 @@ static void setup(void) { fan_report_dfid_unsupported =fanotify_init_flags_supported_on_fs (FAN_REPORT_DFID_NAME ,MOUNT_PATH ); - ignore_mark_unsupported =fanotify_mark_supported_by_kernel (FAN_MARK_IGNORE_SURV ); + ignore_mark_unsupported =fanotify_mark_supported_on_fs (FAN_MARK_IGNORE_SURV , +MOUNT_PATH );SAFE_MKDIR (MOUNT_NAME ,0755 );SAFE_MOUNT (MOUNT_PATH ,MOUNT_NAME ,"none" ,MS_BIND ,NULL );
testcases/kernel/syscalls/fanotify/fanotify10.c +8 -5
@@ -874,11 +874,14 @@ static void setup(void) {int i; - exec_events_unsupported =fanotify_events_supported_by_kernel (FAN_OPEN_EXEC , -FAN_CLASS_CONTENT ,0 ); - filesystem_mark_unsupported =fanotify_mark_supported_by_kernel (FAN_MARK_FILESYSTEM ); - evictable_mark_unsupported =fanotify_mark_supported_by_kernel (FAN_MARK_EVICTABLE ); - ignore_mark_unsupported =fanotify_mark_supported_by_kernel (FAN_MARK_IGNORE_SURV ); + exec_events_unsupported =fanotify_flags_supported_on_fs (FAN_CLASS_CONTENT , +0 ,FAN_OPEN_EXEC ,MOUNT_PATH ); + filesystem_mark_unsupported =fanotify_mark_supported_on_fs (FAN_MARK_FILESYSTEM , +MOUNT_PATH ); + evictable_mark_unsupported =fanotify_mark_supported_on_fs (FAN_MARK_EVICTABLE , +MOUNT_PATH ); + ignore_mark_unsupported =fanotify_mark_supported_on_fs (FAN_MARK_IGNORE_SURV , +MOUNT_PATH ); fan_report_dfid_unsupported =fanotify_init_flags_supported_on_fs (FAN_REPORT_DFID_NAME ,MOUNT_PATH );if (fan_report_dfid_unsupported) {
testcases/kernel/syscalls/fanotify/fanotify11.c +1 -1
@@ -94,7 +94,7 @@ static void test01(unsigned int i)static void setup (void ) { - fan_report_tid_unsupported =fanotify_init_flags_supported_by_kernel (FAN_REPORT_TID ); + fan_report_tid_unsupported =fanotify_init_flags_supported_on_fs (FAN_REPORT_TID ,"." ); }static struct tst_test test = {
testcases/kernel/syscalls/fanotify/fanotify12.c +2 -3
@@ -222,11 +222,10 @@ cleanup:static void do_setup (void ) { - exec_events_unsupported =fanotify_events_supported_by_kernel (FAN_OPEN_EXEC , -FAN_CLASS_NOTIF ,0 ); -sprintf (fname,"fname_%d" ,getpid ());SAFE_FILE_PRINTF (fname,"1" ); + exec_events_unsupported =fanotify_flags_supported_on_fs (FAN_CLASS_NOTIF , +0 ,FAN_OPEN_EXEC , fname); }static void do_cleanup (void )
testcases/kernel/syscalls/fanotify/fanotify13.c +2 -1
@@ -325,7 +325,8 @@ static void do_setup(void)SAFE_MOUNT (mnt,MOUNT_PATH ,"none" ,MS_BIND ,NULL ); bind_mounted =1 ; - filesystem_mark_unsupported =fanotify_mark_supported_by_kernel (FAN_MARK_FILESYSTEM ); + filesystem_mark_unsupported =fanotify_mark_supported_on_fs (FAN_MARK_FILESYSTEM , +MOUNT_PATH ); nofid_fd =SAFE_FANOTIFY_INIT (FAN_CLASS_NOTIF ,O_RDONLY );
testcases/kernel/syscalls/fanotify/fanotify14.c +2 -1
@@ -325,7 +325,8 @@ static void do_setup(void) supported_init_flags =fanotify_get_supported_init_flags (all_init_flags,MNTPOINT ); - ignore_mark_unsupported =fanotify_mark_supported_by_kernel (FAN_MARK_IGNORE_SURV ); + ignore_mark_unsupported =fanotify_mark_supported_on_fs (FAN_MARK_IGNORE_SURV , +MNTPOINT );/* Create temporary test file to place marks on */ SAFE_FILE_PRINTF (FILE1 ,"0" );
testcases/kernel/syscalls/fanotify/fanotify16.c +2 -1
@@ -766,7 +766,8 @@ static void setup(void) fan_report_target_fid_unsupported =fanotify_init_flags_supported_on_fs (FAN_REPORT_DFID_NAME_TARGET ,MOUNT_PATH ); rename_events_unsupported = -fanotify_events_supported_by_kernel (FAN_RENAME ,FAN_REPORT_DFID_NAME ,0 ); +fanotify_flags_supported_on_fs (FAN_REPORT_DFID_NAME ,0 , +FAN_RENAME ,MOUNT_PATH );SAFE_MKDIR (TEMP_DIR ,0755 );sprintf (dname1,"%s/%s" ,MOUNT_PATH ,DIR_NAME1 );
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 3/6] fanotify: Switch event and mark tests to *_on_fs() variant
Hi Jan, Amir,
Quoted 4 lines
Switch event availability and mark type availability tests to be performed on the filesystem actually used for testing instead of on the current directory. This is more reliable as not all filesystems support the same set of features.
Jan, unfortunately this commit breaks fanotify09 and fanotify10 on SLES15 based kernels:
# ./fanotify09 tst_device.c:97: TINFO: Found free device 0 '/dev/loop0' tst_test.c:1106: TINFO: Formatting /dev/loop0 with ext2 opts='' extra opts='' mke2fs 1.46.4 (18-Aug-2021) tst_test.c:1120: TINFO: Mounting /dev/loop0 to /tmp/LTP_fanRt2Q1k/fs_mnt fstyp=ext2 flags=0 tst_test.c:1690: TINFO: LTP version: 20230929-156-gf7f69b7ef tst_test.c:1576: TINFO: Timeout per run is 0h 00m 30s fanotify.h:210: TBROK: fanotify_mark (3, FAN_MARK_ADD, ..., AT_FDCWD, fs_mnt) failed: EINVAL (22) ...
# ./fanotify10 tst_device.c:97: TINFO: Found free device 0 '/dev/loop0' tst_test.c:1106: TINFO: Formatting /dev/loop0 with ext2 opts='' extra opts='' mke2fs 1.46.4 (18-Aug-2021) tst_test.c:1120: TINFO: Mounting /dev/loop0 to /tmp/LTP_fanTNt5os/fs_mnt fstyp=ext2 flags=0 tst_test.c:1690: TINFO: LTP version: 20230929-156-gf7f69b7ef tst_test.c:1576: TINFO: Timeout per run is 0h 00m 30s fanotify.h:210: TBROK: fanotify_mark (3, FAN_MARK_ADD, ..., AT_FDCWD, fs_mnt) failed: EINVAL (22) fanotify10.c:948: TWARN: unlink(fs_mnt/testdir/testfile) failed: ENOENT (2) fanotify10.c:949: TWARN: rmdir(fs_mnt/testdir/testdir2) failed: ENOENT (2) fanotify10.c:950: TWARN: rmdir(fs_mnt/testdir) failed: ENOENT (2) fanotify10.c:951: TWARN: rmdir(mntpoint) failed: ENOENT (2) ...
I suppose the problem is somewhere in fanotify_flags_supported_on_fs(), i.e. in the first commit. It works well on Tumbleweed, which uses latest official stable kernel.
Can you please have look on the issue?
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 3/6] fanotify: Switch event and mark tests to *_on_fs() variant
Quoted 9 lines · Petr Vorel
Hi Jan, Amir,
Quoted 4 lines
Switch event availability and mark type availability tests to be performed on the filesystem actually used for testing instead of on the current directory. This is more reliable as not all filesystems support the same set of features.
Jan, unfortunately this commit breaks fanotify09 and fanotify10 on SLES15 based kernels:
Quoted 9 lines
# ./fanotify09 tst_device.c:97: TINFO: Found free device 0 '/dev/loop0' tst_test.c:1106: TINFO: Formatting /dev/loop0 with ext2 opts='' extra opts='' mke2fs 1.46.4 (18-Aug-2021) tst_test.c:1120: TINFO: Mounting /dev/loop0 to /tmp/LTP_fanRt2Q1k/fs_mnt fstyp=ext2 flags=0 tst_test.c:1690: TINFO: LTP version: 20230929-156-gf7f69b7ef tst_test.c:1576: TINFO: Timeout per run is 0h 00m 30s fanotify.h:210: TBROK: fanotify_mark (3, FAN_MARK_ADD, ..., AT_FDCWD, fs_mnt) failed: EINVAL (22) ...
Thanks for testing! Indeed this was a bug in Amir's original test function which I didn't notice. I've fixed it up.
Honza
Signature · 5 lines
Jan Kara <[email protected]> SUSE Labs, CR -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 3/6] fanotify: Switch event and mark tests to *_on_fs() variant
In reply to Jan KaraQuoted 7 lines · Jan Kara
Switch event availability and mark type availability tests to be performed on the filesystem actually used for testing instead of on the current directory. This is more reliable as not all filesystems support the same set of features.
Signed-off-by Jan Kara <[email protected]>
Quoted 174 lines
--- testcases/kernel/syscalls/fanotify/fanotify.h | 2 +- testcases/kernel/syscalls/fanotify/fanotify01.c | 2 +- testcases/kernel/syscalls/fanotify/fanotify03.c | 7 ++++--- testcases/kernel/syscalls/fanotify/fanotify09.c | 3 ++- testcases/kernel/syscalls/fanotify/fanotify10.c | 13 ++++++++----- testcases/kernel/syscalls/fanotify/fanotify11.c | 2 +- testcases/kernel/syscalls/fanotify/fanotify12.c | 5 ++--- testcases/kernel/syscalls/fanotify/fanotify13.c | 3 ++- testcases/kernel/syscalls/fanotify/fanotify14.c | 3 ++- testcases/kernel/syscalls/fanotify/fanotify16.c | 3 ++- 10 files changed, 25 insertions(+), 18 deletions(-)testcases/kernel/syscalls/fanotify/fanotify.h +1
-1@@ -352,7 +352,7 @@ static inline int fanotify_handle_supported_by_kernel(int flag)if (init_flags) \REQUIRE_FANOTIFY_INIT_FLAGS_SUPPORTED_ON_FS (init_flags, fname); \ fanotify_flags_err_msg(#mask, __FILE__, __LINE__, tst_brk_, \ - fanotify_events_supported_by_kernel(mask, init_flags, mark_type)); \ + fanotify_flags_supported_on_fs(init_flags, mark_type, mask, fname)); \ } while (0) static inline struct fanotify_event_info_header *get_event_info(testcases/kernel/syscalls/fanotify/fanotify01.c +1
-1@@ -341,7 +341,7 @@ static void setup(void)SAFE_FILE_PRINTF (fname,"1" ); fan_report_fid_unsupported =fanotify_init_flags_supported_on_fs (FAN_REPORT_FID , fname); - filesystem_mark_unsupported =fanotify_mark_supported_by_kernel (FAN_MARK_FILESYSTEM ); + filesystem_mark_unsupported =fanotify_mark_supported_on_fs (FAN_MARK_FILESYSTEM , fname); }static void cleanup (void )testcases/kernel/syscalls/fanotify/fanotify03.c +4
-3@@ -322,12 +322,13 @@ static void setup(void) {require_fanotify_access_permissions_supported_by_kernel (); - filesystem_mark_unsupported =fanotify_mark_supported_by_kernel (FAN_MARK_FILESYSTEM ); - exec_events_unsupported =fanotify_events_supported_by_kernel (FAN_OPEN_EXEC_PERM , -FAN_CLASS_CONTENT ,0 );sprintf (fname,MOUNT_PATH "/fname_%d" ,getpid ());SAFE_FILE_PRINTF (fname,"1" ); + filesystem_mark_unsupported =fanotify_mark_supported_on_fs (FAN_MARK_FILESYSTEM , fname); + exec_events_unsupported =fanotify_flags_supported_on_fs (FAN_CLASS_CONTENT , +0 ,FAN_OPEN_EXEC_PERM , fname); +SAFE_CP (TEST_APP ,FILE_EXEC_PATH ); }testcases/kernel/syscalls/fanotify/fanotify09.c +2
-1@@ -482,7 +482,8 @@ static void setup(void) { fan_report_dfid_unsupported =fanotify_init_flags_supported_on_fs (FAN_REPORT_DFID_NAME ,MOUNT_PATH ); - ignore_mark_unsupported =fanotify_mark_supported_by_kernel (FAN_MARK_IGNORE_SURV ); + ignore_mark_unsupported =fanotify_mark_supported_on_fs (FAN_MARK_IGNORE_SURV , +MOUNT_PATH );SAFE_MKDIR (MOUNT_NAME ,0755 );SAFE_MOUNT (MOUNT_PATH ,MOUNT_NAME ,"none" ,MS_BIND ,NULL );testcases/kernel/syscalls/fanotify/fanotify10.c +8
-5@@ -874,11 +874,14 @@ static void setup(void) {int i; - exec_events_unsupported =fanotify_events_supported_by_kernel (FAN_OPEN_EXEC , -FAN_CLASS_CONTENT ,0 ); - filesystem_mark_unsupported =fanotify_mark_supported_by_kernel (FAN_MARK_FILESYSTEM ); - evictable_mark_unsupported =fanotify_mark_supported_by_kernel (FAN_MARK_EVICTABLE ); - ignore_mark_unsupported =fanotify_mark_supported_by_kernel (FAN_MARK_IGNORE_SURV ); + exec_events_unsupported =fanotify_flags_supported_on_fs (FAN_CLASS_CONTENT , +0 ,FAN_OPEN_EXEC ,MOUNT_PATH ); + filesystem_mark_unsupported =fanotify_mark_supported_on_fs (FAN_MARK_FILESYSTEM , +MOUNT_PATH ); + evictable_mark_unsupported =fanotify_mark_supported_on_fs (FAN_MARK_EVICTABLE , +MOUNT_PATH ); + ignore_mark_unsupported =fanotify_mark_supported_on_fs (FAN_MARK_IGNORE_SURV , +MOUNT_PATH ); fan_report_dfid_unsupported =fanotify_init_flags_supported_on_fs (FAN_REPORT_DFID_NAME ,MOUNT_PATH );if (fan_report_dfid_unsupported) {testcases/kernel/syscalls/fanotify/fanotify11.c +1
-1@@ -94,7 +94,7 @@ static void test01(unsigned int i)static void setup (void ) { - fan_report_tid_unsupported =fanotify_init_flags_supported_by_kernel (FAN_REPORT_TID ); + fan_report_tid_unsupported =fanotify_init_flags_supported_on_fs (FAN_REPORT_TID ,"." ); }static struct tst_test test = {testcases/kernel/syscalls/fanotify/fanotify12.c +2
-3@@ -222,11 +222,10 @@ cleanup:static void do_setup (void ) { - exec_events_unsupported =fanotify_events_supported_by_kernel (FAN_OPEN_EXEC , -FAN_CLASS_NOTIF ,0 ); -sprintf (fname,"fname_%d" ,getpid ());SAFE_FILE_PRINTF (fname,"1" ); + exec_events_unsupported =fanotify_flags_supported_on_fs (FAN_CLASS_NOTIF , +0 ,FAN_OPEN_EXEC , fname); }static void do_cleanup (void )testcases/kernel/syscalls/fanotify/fanotify13.c +2
-1@@ -325,7 +325,8 @@ static void do_setup(void)SAFE_MOUNT (mnt,MOUNT_PATH ,"none" ,MS_BIND ,NULL ); bind_mounted =1 ; - filesystem_mark_unsupported =fanotify_mark_supported_by_kernel (FAN_MARK_FILESYSTEM ); + filesystem_mark_unsupported =fanotify_mark_supported_on_fs (FAN_MARK_FILESYSTEM , +MOUNT_PATH ); nofid_fd =SAFE_FANOTIFY_INIT (FAN_CLASS_NOTIF ,O_RDONLY );testcases/kernel/syscalls/fanotify/fanotify14.c +2
-1@@ -325,7 +325,8 @@ static void do_setup(void) supported_init_flags =fanotify_get_supported_init_flags (all_init_flags,MNTPOINT ); - ignore_mark_unsupported =fanotify_mark_supported_by_kernel (FAN_MARK_IGNORE_SURV ); + ignore_mark_unsupported =fanotify_mark_supported_on_fs (FAN_MARK_IGNORE_SURV , +MNTPOINT );/* Create temporary test file to place marks on */ SAFE_FILE_PRINTF (FILE1 ,"0" );testcases/kernel/syscalls/fanotify/fanotify16.c +2
-2@@ -766,7 +766,8 @@ static void setup(void) fan_report_target_fid_unsupported =fanotify_init_flags_supported_on_fs (FAN_REPORT_DFID_NAME_TARGET ,MOUNT_PATH ); rename_events_unsupported = -fanotify_events_supported_by_kernel (FAN_RENAME ,FAN_REPORT_DFID_NAME ,0 ); +fanotify_flags_supported_on_fs (FAN_REPORT_DFID_NAME ,0 , +FAN_RENAME ,MOUNT_PATH );SAFE_MKDIR (TEMP_DIR ,0755 );sprintf (dname1,"%s/%s" ,MOUNT_PATH ,DIR_NAME1 ); --2.35.3
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 4/6 fanotify: Drop unused feature test macros
In reply to Jan KaraDrop now unused feature test macrosfanotify_events_supported_by_kernel() andfanotify_mark_supported_by_kernel().
--- testcases/kernel/syscalls/fanotify/fanotify.h | 44 ------------------- 1 file changed, 44 deletions(-)
testcases/kernel/syscalls/fanotify/fanotify.h +0 -44
@@ -152,29 +152,6 @@ static inline void require_fanotify_access_permissions_supported_by_kernel(void)SAFE_CLOSE (fd); } -static inline int fanotify_events_supported_by_kernel (uint64_t mask, -unsigned int init_flags, -unsigned int mark_flags) -{ -int fd; -int rval =0 ; - - fd =SAFE_FANOTIFY_INIT (init_flags,O_RDONLY ); - -if (fanotify_mark (fd,FAN_MARK_ADD | mark_flags, mask,AT_FDCWD ,"." ) <0 ) { -if (errno ==EINVAL ) { - rval =-1 ; - }else { -tst_brk (TBROK |TERRNO , -"fanotify_mark (%d, FAN_MARK_ADD, ..., AT_FDCWD, \".\") failed" , fd); - } - } - -SAFE_CLOSE (fd); - -return rval; -} -/* * @return 0: fanotify flags supported both in kernel and on tested filesystem * @return -1: @init_flags not supported in kernel
@@ -304,27 +281,6 @@ static inline void fanotify_flags_err_msg(const char *flags_str, fanotify_flags_err_msg(#flags, __FILE__, __LINE__, tst_brk_, \ fanotify_init_flags_supported_by_kernel(flags)) -static inline int fanotify_mark_supported_by_kernel (uint64_t flag) -{ -int fd; -int rval =0 ; - - fd =SAFE_FANOTIFY_INIT (FAN_CLASS_CONTENT ,O_RDONLY ); - -if (fanotify_mark (fd,FAN_MARK_ADD | flag,FAN_ACCESS ,AT_FDCWD ,"." ) <0 ) { -if (errno ==EINVAL ) { - rval =-1 ; - }else { -tst_brk (TBROK |TERRNO , -"fanotify_mark (%d, FAN_MARK_ADD, ..., FAN_ACCESS, AT_FDCWD, \".\") failed" , fd); - } - } - -SAFE_CLOSE (fd); - -return rval; -} -static inline int fanotify_handle_supported_by_kernel (int flag) {/*
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 4/6] fanotify: Drop unused feature test macros
Quoted 6 lines · Jan Kara
Drop now unused feature test macros
fanotify_events_supported_by_kernel()andfanotify_mark_supported_by_kernel().Signed-off-by Jan Kara <[email protected]>
Quoted 69 lines
--- testcases/kernel/syscalls/fanotify/fanotify.h | 44 ------------------- 1 file changed, 44 deletions(-)testcases/kernel/syscalls/fanotify/fanotify.h +0
-45@@ -152,29 +152,6 @@ static inline void require_fanotify_access_permissions_supported_by_kernel(void)SAFE_CLOSE (fd); } -static inline int fanotify_events_supported_by_kernel (uint64_t mask, -unsigned int init_flags, -unsigned int mark_flags) -{ -int fd; -int rval =0 ; - - fd =SAFE_FANOTIFY_INIT (init_flags,O_RDONLY ); - -if (fanotify_mark (fd,FAN_MARK_ADD | mark_flags, mask,AT_FDCWD ,"." ) <0 ) { -if (errno ==EINVAL ) { - rval =-1 ; - }else { -tst_brk (TBROK |TERRNO , -"fanotify_mark (%d, FAN_MARK_ADD, ..., AT_FDCWD, \".\") failed" , fd); - } - } - -SAFE_CLOSE (fd); - -return rval; -} -/* * @return 0: fanotify flags supported both in kernel and on tested filesystem * @return -1: @init_flags not supported in kernel @@ -304,27 +281,6 @@ static inline void fanotify_flags_err_msg(const char *flags_str, fanotify_flags_err_msg(#flags, __FILE__, __LINE__, tst_brk_, \ fanotify_init_flags_supported_by_kernel(flags)) -static inline int fanotify_mark_supported_by_kernel (uint64_t flag) -{ -int fd; -int rval =0 ; - - fd =SAFE_FANOTIFY_INIT (FAN_CLASS_CONTENT ,O_RDONLY ); - -if (fanotify_mark (fd,FAN_MARK_ADD | flag,FAN_ACCESS ,AT_FDCWD ,"." ) <0 ) { -if (errno ==EINVAL ) { - rval =-1 ; - }else { -tst_brk (TBROK |TERRNO , -"fanotify_mark (%d, FAN_MARK_ADD, ..., FAN_ACCESS, AT_FDCWD, \".\") failed" , fd); - } - } - -SAFE_CLOSE (fd); - -return rval; -} -static inline int fanotify_handle_supported_by_kernel (int flag) {/* -- 2.35.3
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 5/6 fanotify: Convert remaining init_flags tests to be performed on target fs
In reply to Jan KaraConvert remaining tests using REQUIRE_FANOTIFY_INIT_FLAGS_SUPPORTED_BY_KERNEL to be performed on target filesystem using REQUIRE_FANOTIFY_INIT_FLAGS_SUPPORTED_ON_FS and remove the now unused macro and functions.
--- testcases/kernel/syscalls/fanotify/fanotify.h | 9 --------- testcases/kernel/syscalls/fanotify/fanotify20.c | 3 ++- testcases/kernel/syscalls/fanotify/fanotify21.c | 3 ++- 3 files changed, 4 insertions(+), 11 deletions(-)
testcases/kernel/syscalls/fanotify/fanotify.h +0 -9
@@ -198,11 +198,6 @@ static inline int fanotify_init_flags_supported_on_fs(unsigned int flags, constreturn fanotify_flags_supported_on_fs (flags,FAN_MARK_INODE ,FAN_ACCESS , fname); } -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);
@@ -277,10 +272,6 @@ static inline void fanotify_flags_err_msg(const char *flags_str, fanotify_flags_err_msg(#flags, __FILE__, __LINE__, tst_brk_, \ fanotify_init_flags_supported_on_fs(flags, fname)) -#define REQUIRE_FANOTIFY_INIT_FLAGS_SUPPORTED_BY_KERNEL (flags) \ - fanotify_flags_err_msg(#flags, __FILE__, __LINE__, tst_brk_, \ - fanotify_init_flags_supported_by_kernel(flags)) -static inline int fanotify_handle_supported_by_kernel (int flag) {/*
testcases/kernel/syscalls/fanotify/fanotify20.c +2 -1
@@ -50,7 +50,8 @@ static void do_setup(void)* An explicit check for FAN_REPORT_PIDFD is performed early on in the * test initialization as it's a prerequisite for all test cases. */ -REQUIRE_FANOTIFY_INIT_FLAGS_SUPPORTED_BY_KERNEL (FAN_REPORT_PIDFD ); +REQUIRE_FANOTIFY_INIT_FLAGS_SUPPORTED_ON_FS (FAN_REPORT_PIDFD , +MOUNT_PATH ); }static void do_test (unsigned int i)
testcases/kernel/syscalls/fanotify/fanotify21.c +2 -1
@@ -119,7 +119,8 @@ static void do_setup(void)* on in the test initialization as it's a prerequisite for * all test cases. */ -REQUIRE_FANOTIFY_INIT_FLAGS_SUPPORTED_BY_KERNEL (FAN_REPORT_PIDFD ); +REQUIRE_FANOTIFY_INIT_FLAGS_SUPPORTED_ON_FS (FAN_REPORT_PIDFD , +TEST_FILE ); fanotify_fd =SAFE_FANOTIFY_INIT (FAN_REPORT_PIDFD ,O_RDONLY ); SAFE_FANOTIFY_MARK(fanotify_fd, FAN_MARK_ADD, FAN_OPEN, AT_FDCWD,
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 5/6] fanotify: Convert remaining init_flags tests to be performed on target fs
Quoted 7 lines · Jan Kara
Convert remaining tests using
REQUIRE_FANOTIFY_INIT_FLAGS_SUPPORTED_BY_KERNELto be performed on target filesystem usingREQUIRE_FANOTIFY_INIT_FLAGS_SUPPORTED_ON_FSand remove the now unused macro and functions.Signed-off-by Jan Kara <[email protected]>
Quoted 64 lines
--- testcases/kernel/syscalls/fanotify/fanotify.h | 9 --------- testcases/kernel/syscalls/fanotify/fanotify20.c | 3 ++- testcases/kernel/syscalls/fanotify/fanotify21.c | 3 ++- 3 files changed, 4 insertions(+), 11 deletions(-)testcases/kernel/syscalls/fanotify/fanotify.h +0
-9@@ -198,11 +198,6 @@ static inline int fanotify_init_flags_supported_on_fs(unsigned int flags, constreturn fanotify_flags_supported_on_fs (flags,FAN_MARK_INODE ,FAN_ACCESS , fname); } -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);@@ -277,10 +272,6 @@ static inline void fanotify_flags_err_msg(const char *flags_str, fanotify_flags_err_msg(#flags, __FILE__, __LINE__, tst_brk_, \ fanotify_init_flags_supported_on_fs(flags, fname)) -#define REQUIRE_FANOTIFY_INIT_FLAGS_SUPPORTED_BY_KERNEL (flags) \ - fanotify_flags_err_msg(#flags, __FILE__, __LINE__, tst_brk_, \ - fanotify_init_flags_supported_by_kernel(flags)) -static inline int fanotify_handle_supported_by_kernel (int flag) {/* testcases/kernel/syscalls/fanotify/fanotify20.c +2
-1@@ -50,7 +50,8 @@ static void do_setup(void)* An explicit check for FAN_REPORT_PIDFD is performed early on in the * test initialization as it's a prerequisite for all test cases. */ -REQUIRE_FANOTIFY_INIT_FLAGS_SUPPORTED_BY_KERNEL (FAN_REPORT_PIDFD ); +REQUIRE_FANOTIFY_INIT_FLAGS_SUPPORTED_ON_FS (FAN_REPORT_PIDFD , +MOUNT_PATH ); }static void do_test (unsigned int i)testcases/kernel/syscalls/fanotify/fanotify21.c +2
-2@@ -119,7 +119,8 @@ static void do_setup(void)* on in the test initialization as it's a prerequisite for * all test cases. */ -REQUIRE_FANOTIFY_INIT_FLAGS_SUPPORTED_BY_KERNEL (FAN_REPORT_PIDFD ); +REQUIRE_FANOTIFY_INIT_FLAGS_SUPPORTED_ON_FS (FAN_REPORT_PIDFD , +TEST_FILE ); fanotify_fd =SAFE_FANOTIFY_INIT (FAN_REPORT_PIDFD ,O_RDONLY ); SAFE_FANOTIFY_MARK(fanotify_fd, FAN_MARK_ADD, FAN_OPEN, AT_FDCWD, --2.35.3
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 6/6 fanotify: Convert permission events feature check to be performed on fs
In reply to Jan KaraConvert feature check for availability of permission events to be performed on the tested filesystem.
--- testcases/kernel/syscalls/fanotify/fanotify.h | 5 +++-- testcases/kernel/syscalls/fanotify/fanotify03.c | 3 +-- testcases/kernel/syscalls/fanotify/fanotify07.c | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-)
testcases/kernel/syscalls/fanotify/fanotify.h +3 -2
@@ -133,13 +133,14 @@ static inline int fanotify_save_fid(const char *path,#define INIT_FANOTIFY_MARK_TYPE (t) \ { FAN_MARK_ ## t, "FAN_MARK_" #t } -static inline void require_fanotify_access_permissions_supported_by_kernel (void ) +static inline void require_fanotify_access_permissions_supported_on_fs ( +const char *fname) {int fd; fd =SAFE_FANOTIFY_INIT (FAN_CLASS_CONTENT ,O_RDONLY ); -if (fanotify_mark (fd,FAN_MARK_ADD ,FAN_ACCESS_PERM ,AT_FDCWD ,"." ) <0 ) { +if (fanotify_mark (fd,FAN_MARK_ADD ,FAN_ACCESS_PERM ,AT_FDCWD , fname) <0 ) {if (errno ==EINVAL ) {tst_brk (TCONF |TERRNO ,"CONFIG_FANOTIFY_ACCESS_PERMISSIONS not configured in kernel?" );
testcases/kernel/syscalls/fanotify/fanotify03.c +1 -2
@@ -320,11 +320,10 @@ static void test_fanotify(unsigned int n)static void setup (void ) { -require_fanotify_access_permissions_supported_by_kernel (); -sprintf (fname,MOUNT_PATH "/fname_%d" ,getpid ());SAFE_FILE_PRINTF (fname,"1" ); +require_fanotify_access_permissions_supported_on_fs (fname); filesystem_mark_unsupported =fanotify_mark_supported_on_fs (FAN_MARK_FILESYSTEM , fname); exec_events_unsupported =fanotify_flags_supported_on_fs (FAN_CLASS_CONTENT ,0 ,FAN_OPEN_EXEC_PERM , fname);
testcases/kernel/syscalls/fanotify/fanotify07.c +1 -2
@@ -189,10 +189,9 @@ static void test_fanotify(void)static void setup (void ) { -require_fanotify_access_permissions_supported_by_kernel (); -sprintf (fname,"fname_%d" ,getpid ());SAFE_FILE_PRINTF (fname,"%s" , fname); +require_fanotify_access_permissions_supported_on_fs (fname); }static void cleanup (void )
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 6/6] fanotify: Convert permission events feature check to be performed on fs
Quoted 5 lines · Jan Kara
Convert feature check for availability of permission events to be performed on the tested filesystem.
Signed-off-by Jan Kara <[email protected]>
Quoted 63 lines
--- testcases/kernel/syscalls/fanotify/fanotify.h | 5 +++-- testcases/kernel/syscalls/fanotify/fanotify03.c | 3 +-- testcases/kernel/syscalls/fanotify/fanotify07.c | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-)testcases/kernel/syscalls/fanotify/fanotify.h +3
-2@@ -133,13 +133,14 @@ static inline int fanotify_save_fid(const char *path,#define INIT_FANOTIFY_MARK_TYPE (t) \ { FAN_MARK_ ## t, "FAN_MARK_" #t } -static inline void require_fanotify_access_permissions_supported_by_kernel (void ) +static inline void require_fanotify_access_permissions_supported_on_fs ( +const char *fname) {int fd; fd =SAFE_FANOTIFY_INIT (FAN_CLASS_CONTENT ,O_RDONLY ); -if (fanotify_mark (fd,FAN_MARK_ADD ,FAN_ACCESS_PERM ,AT_FDCWD ,"." ) <0 ) { +if (fanotify_mark (fd,FAN_MARK_ADD ,FAN_ACCESS_PERM ,AT_FDCWD , fname) <0 ) {if (errno ==EINVAL ) {tst_brk (TCONF |TERRNO ,"CONFIG_FANOTIFY_ACCESS_PERMISSIONS not configured in kernel?" );testcases/kernel/syscalls/fanotify/fanotify03.c +1
-2@@ -320,11 +320,10 @@ static void test_fanotify(unsigned int n)static void setup (void ) { -require_fanotify_access_permissions_supported_by_kernel (); -sprintf (fname,MOUNT_PATH "/fname_%d" ,getpid ());SAFE_FILE_PRINTF (fname,"1" ); +require_fanotify_access_permissions_supported_on_fs (fname); filesystem_mark_unsupported =fanotify_mark_supported_on_fs (FAN_MARK_FILESYSTEM , fname); exec_events_unsupported =fanotify_flags_supported_on_fs (FAN_CLASS_CONTENT ,0 ,FAN_OPEN_EXEC_PERM , fname);testcases/kernel/syscalls/fanotify/fanotify07.c +1
-3@@ -189,10 +189,9 @@ static void test_fanotify(void)static void setup (void ) { -require_fanotify_access_permissions_supported_by_kernel (); -sprintf (fname,"fname_%d" ,getpid ());SAFE_FILE_PRINTF (fname,"%s" , fname); +require_fanotify_access_permissions_supported_on_fs (fname); }static void cleanup (void ) --2.35.3
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp