[LTP] [PATCH] fanotify01: Fix regression on kernels < v6.8

Jan Kara jack@suse.cz
Mon Jun 30 10:43:30 CEST 2025


On Sat 28-06-25 13:33:34, Amir Goldstein wrote:
> There was a test regression in case the TMPDIR has a zero fsid.
> 
> Kernels < v6.8 do not allow setting inodes marks on such fs, while
> kernels >= v6.8 do allow to set inode marks but on on a single fs.
> 
> Adjust the test expectation in those two different cases.
> 
> Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
> Link: https://lore.kernel.org/ltp/CA+G9fYtJO4DbiabJwpSamTPHjPzyrD3O6ZCwm2+CDEUA7f+ZYw@mail.gmail.com/
> Fixes: db197b7b5 ("fanotify01: fix test failure when running with nfs TMPDIR")
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>

Thanks for fixing this up. The patch looks good to me. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
> 
> Petr,
> 
> I reproduced this but with TMPDIR set to ntfs-3g mount path,
> which has zero fsid link nfs.
> 
> Tested that fix works on new (upstream) and old v6.6 kernels.
> 
> Thanks,
> Amir.
> 
>  testcases/kernel/syscalls/fanotify/fanotify01.c | 16 +++++++++++-----
>  1 file changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/fanotify/fanotify01.c b/testcases/kernel/syscalls/fanotify/fanotify01.c
> index f514dc1df..df50d84a1 100644
> --- a/testcases/kernel/syscalls/fanotify/fanotify01.c
> +++ b/testcases/kernel/syscalls/fanotify/fanotify01.c
> @@ -75,6 +75,7 @@ static char fname[BUF_SIZE];
>  static char buf[BUF_SIZE];
>  static int fd_notify;
>  static int fan_report_fid_unsupported;
> +static int tmpfs_report_fid_unsupported;
>  static int mount_mark_fid_unsupported;
>  static int inode_mark_fid_xdev;
>  static int filesystem_mark_unsupported;
> @@ -335,9 +336,11 @@ pass:
>  	 * When tested fs has zero fsid (e.g. fuse) and events are reported
>  	 * with fsid+fid, watching different filesystems is not supported.
>  	 */
> -	ret = report_fid ? inode_mark_fid_xdev : 0;
> -	TST_EXP_FD_OR_FAIL(fanotify_mark(fd_notify, FAN_MARK_ADD, FAN_CLOSE_WRITE,
> -					 AT_FDCWD, "."), ret);
> +	if (!tmpfs_report_fid_unsupported) {
> +		ret = report_fid ? inode_mark_fid_xdev : 0;
> +		TST_EXP_FD_OR_FAIL(fanotify_mark(fd_notify, FAN_MARK_ADD, FAN_CLOSE_WRITE,
> +						 AT_FDCWD, "."), ret);
> +	}
>  
>  	/* Remove mark to clear FAN_MARK_IGNORED_SURV_MODIFY */
>  	SAFE_FANOTIFY_MARK(fd_notify, FAN_MARK_REMOVE | mark->flag,
> @@ -373,8 +376,11 @@ static void setup(void)
>  		inode_mark_fid_xdev = EXDEV;
>  	}
>  
> -	if (fanotify_flags_supported_on_fs(FAN_REPORT_FID, FAN_MARK_MOUNT, FAN_OPEN, ".")) {
> -		inode_mark_fid_xdev = (errno == ENODEV) ? EXDEV : errno;
> +	tmpfs_report_fid_unsupported = fanotify_init_flags_supported_on_fs(FAN_REPORT_FID, ".");
> +	if (!tmpfs_report_fid_unsupported &&
> +	    fanotify_flags_supported_on_fs(FAN_REPORT_FID, FAN_MARK_MOUNT, FAN_OPEN, ".") &&
> +	    (errno == ENODEV || errno == EXDEV)) {
> +		inode_mark_fid_xdev = EXDEV;
>  		tst_res(TINFO | TERRNO, "TMPDIR does not support reporting events with fid from multi fs");
>  	}
>  }
> -- 
> 2.43.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR


More information about the ltp mailing list