[LTP] [PATCH] syscalls: add file_attr05 test

Cyril Hrubis chrubis@suse.cz
Mon Oct 13 16:45:29 CEST 2025


Hi!
> Verify that `file_getattr` and `file_setattr` are correctly raising
> EOPNOTSUPP when filesystem doesn't support them.
> 
> Regression test for "474b155adf39 - fs: make vfs_fileattr_[get|set]
> return -EOPNOTSUPP".
> 
> Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
> ---
>  runtest/syscalls                                  |  1 +
>  testcases/kernel/syscalls/file_attr/.gitignore    |  1 +
>  testcases/kernel/syscalls/file_attr/file_attr05.c | 64 +++++++++++++++++++++++
>  3 files changed, 66 insertions(+)
> 
> diff --git a/runtest/syscalls b/runtest/syscalls
> index 4b284f279..b8a1988e1 100644
> --- a/runtest/syscalls
> +++ b/runtest/syscalls
> @@ -250,6 +250,7 @@ file_attr01 file_attr01
>  file_attr02 file_attr02
>  file_attr03 file_attr03
>  file_attr04 file_attr04
> +file_attr05 file_attr05
>  
>  #posix_fadvise test cases
>  posix_fadvise01                      posix_fadvise01
> diff --git a/testcases/kernel/syscalls/file_attr/.gitignore b/testcases/kernel/syscalls/file_attr/.gitignore
> index 3fcb9004d..42f830a7e 100644
> --- a/testcases/kernel/syscalls/file_attr/.gitignore
> +++ b/testcases/kernel/syscalls/file_attr/.gitignore
> @@ -2,3 +2,4 @@ file_attr01
>  file_attr02
>  file_attr03
>  file_attr04
> +file_attr05
> diff --git a/testcases/kernel/syscalls/file_attr/file_attr05.c b/testcases/kernel/syscalls/file_attr/file_attr05.c
> new file mode 100644
> index 000000000..127ca35ae
> --- /dev/null
> +++ b/testcases/kernel/syscalls/file_attr/file_attr05.c
> @@ -0,0 +1,64 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (C) 2025 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
> + */
> +
> +/*\
> + * Verify that `file_getattr` and `file_setattr` are correctly raising
> + * EOPNOTSUPP when filesystem doesn't support them.
> + *
> + * Regression test for "474b155adf39 - fs: make vfs_fileattr_[get|set] return
> + * -EOPNOTSUPP".
> + */
> +
> +#include "tst_test.h"
> +#include "lapi/fs.h"
> +
> +#define MNTPOINT "mntpoint"
> +#define FILEPATH (MNTPOINT "/ltp_file")
> +#define BLOCKS 1024
> +#define PROJID 16
> +
> +static struct file_attr *attr_set;
> +static struct file_attr *attr_get;
> +
> +static void run(void)
> +{
> +	TST_EXP_FAIL(file_setattr(AT_FDCWD, FILEPATH,
> +			   attr_set, FILE_ATTR_SIZE_LATEST, 0), EOPNOTSUPP);
> +
> +	TST_EXP_FAIL(file_getattr(AT_FDCWD, FILEPATH,
> +			   attr_get, FILE_ATTR_SIZE_LATEST, 0), EOPNOTSUPP);
> +}
> +
> +static void setup(void)
> +{
> +	int block_size;
> +
> +	SAFE_TOUCH(FILEPATH, 0777, NULL);
> +
> +	block_size = tst_dev_block_size(MNTPOINT);

Isn't this wrong?

See:

commit f4af1fb44161d719695c3ce1bcad61d6f3638ba8
Author: Martin Doucha <mdoucha@suse.cz>
Date:   Tue Sep 23 17:32:24 2025 +0200

    file_attr02: Enable reflinks and fix blocksize detection

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list