syscalls: add file_attr05 test
PATCH v3 1/1 syscalls: add file_attr05 test
From: Andrea Cervesato <[email protected]>
Verify that file_setattr is correctly raising EOPNOTSUPP when filesystem doesn't support FSX operations.
Regression test for "474b155adf39 - fs: make vfs_fileattr_[get|set] return -EOPNOTSUPP".
--- runtest/syscalls | 1 + testcases/kernel/syscalls/file_attr/.gitignore | 1 + testcases/kernel/syscalls/file_attr/file_attr05.c | 63 +++++++++++++++++++++++ 3 files changed, 65 insertions(+)
runtest/syscalls +1 -0
@@ -253,6 +253,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
testcases/kernel/syscalls/file_attr/.gitignore +1 -0
@@ -2,3 +2,4 @@ file_attr01 file_attr02 file_attr03 file_attr04 +file_attr05
testcases/kernel/syscalls/file_attr/file_attr05.c new file +63 -0
63 lines not on this page · raw message
---
base-commit: 36b915cef08adaa833af79301780cdd45a38f0e2
change-id: 20260119-file_attr05-eebcc81b9d46
Best regards,
Signature · 5 lines
Andrea Cervesato <[email protected]> -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Andrea,
Quoted 7 lines
From: Andrea Cervesato <[email protected]>
Verify that
file_setattris correctly raising EOPNOTSUPP when filesystem doesn't support FSX operations.Regression test for "
474b155adf39- fs: make vfs_fileattr_[get|set] return-EOPNOTSUPP".
Reason for changing approach in v3:
https://lore.kernel.org/ltp/[email protected]/
testcases/kernel/syscalls/file_attr/file_attr05.c line 11
Quoted 13 lines
+++
b/testcases/kernel/syscalls/file_attr/file_attr05.ctestcases/kernel/syscalls/file_attr/file_attr05.c new file +11
-0@@ -0,0 +1,63 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (C) 2025 SUSE LLC Andrea Cervesato <[email protected]> +*/ + +/*\ +* Verify that `file_setattr` is correctly raising EOPNOTSUPP when filesystem +* doesn't support FSX operations. +* +* Regression test for "474b155adf39 - fs: make vfs_fileattr_[get|set] return +* -EOPNOTSUPP".
Why not added into .tags?
nit: Also the usual way of referring commits is:474b155adf392 ("fs: make vfs_fileattr_[get|set] return -EOPNOTSUPP")
Quoted 35 lines
testcases/kernel/syscalls/file_attr/file_attr05.c new file +35
-0+*/ + +#include "tst_test.h" +#include "lapi/fs.h" + +#define MNTPOINT "mntpoint" +#define FILEPATH (MNTPOINT "/ltp_file") +#define BLOCKS 128 +#define PROJID 16 + +static struct file_attr *attr_set; + +static void run (void ) +{ +TST_EXP_FAIL (file_setattr (AT_FDCWD ,FILEPATH , + attr_set,FILE_ATTR_SIZE_LATEST ,0 ),EOPNOTSUPP ); +} + +static void setup (void ) +{ +struct stat statbuf; + +SAFE_TOUCH (FILEPATH ,0777 ,NULL ); + +SAFE_STAT (MNTPOINT , &statbuf); + + attr_set->fa_xflags |=FS_XFLAG_EXTSIZE ; + attr_set->fa_xflags |=FS_XFLAG_COWEXTSIZE ; + attr_set->fa_extsize =BLOCKS * statbuf.st_blksize; + attr_set->fa_cowextsize =BLOCKS * statbuf.st_blksize; + attr_set->fa_projid =PROJID ; +} + +static struct tst_test test = { + .test_all = run,
testcases/kernel/syscalls/file_attr/file_attr05.c line 56
Quoted 10 lines
testcases/kernel/syscalls/file_attr/file_attr05.c new file +10
-0+ .setup = setup, + .mntpoint = MNTPOINT, + .needs_root = 1, + .mount_device = 1, + .all_filesystems = 1, + .format_device = 1, + .skip_filesystems = (const char *const []) { +"xfs" , +"fuse" ,/* EINVAL is raised before EOPNOTSUPP */ +"vfat" ,/* vfat is not implementing file_[set|get]attr */
Hm, funny, vfat not implementing also raises EOPNOTSUPP. I wonder if we should keep it as well.
testcases/kernel/syscalls/file_attr/file_attr05.c line 60
Quoted 4 lines
testcases/kernel/syscalls/file_attr/file_attr05.c new file +4
-0+ NULL, + }, + .bufs = (struct tst_buffers []) { + {&attr_set, .size =sizeof (struct file_attr )},
Again, I'd put 474b155adf392 into tags. It's IMHO enough (no need for mentioning it in the docs.
Kind regards,
Petr
Quoted 3 lines
testcases/kernel/syscalls/file_attr/file_attr05.c new file +3
-0+ {} + } +};
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 70 lines · Petr Vorel
Hi Andrea,
Quoted 7 lines
From: Andrea Cervesato <[email protected]>
Verify that
file_setattris correctly raising EOPNOTSUPP when filesystem doesn't support FSX operations.Regression test for "
474b155adf39- fs: make vfs_fileattr_[get|set] return-EOPNOTSUPP".Reason for changing approach in v3:
https://lore.kernel.org/ltp/[email protected]/testcases/kernel/syscalls/file_attr/file_attr05.c line 11
Quoted 13 lines
+++
b/testcases/kernel/syscalls/file_attr/file_attr05.ctestcases/kernel/syscalls/file_attr/file_attr05.c new file +11
-0@@ -0,0 +1,63 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (C) 2025 SUSE LLC Andrea Cervesato <[email protected]> +*/ + +/*\ +* Verify that `file_setattr` is correctly raising EOPNOTSUPP when filesystem +* doesn't support FSX operations. +* +* Regression test for "474b155adf39 - fs: make vfs_fileattr_[get|set] return +* -EOPNOTSUPP". Why not added into .tags?
nit: Also the usual way of referring commits is:474b155adf392("fs: make vfs_fileattr_[get|set] return-EOPNOTSUPP")Quoted 40 lines
testcases/kernel/syscalls/file_attr/file_attr05.c new file +40
-0+*/ + +#include "tst_test.h" +#include "lapi/fs.h" + +#define MNTPOINT "mntpoint" +#define FILEPATH (MNTPOINT "/ltp_file") +#define BLOCKS 128 +#define PROJID 16 + +static struct file_attr *attr_set; + +static void run (void ) +{ +TST_EXP_FAIL (file_setattr (AT_FDCWD ,FILEPATH , + attr_set,FILE_ATTR_SIZE_LATEST ,0 ),EOPNOTSUPP ); +} + +static void setup (void ) +{ +struct stat statbuf; + +SAFE_TOUCH (FILEPATH ,0777 ,NULL ); + +SAFE_STAT (MNTPOINT , &statbuf); + + attr_set->fa_xflags |=FS_XFLAG_EXTSIZE ; + attr_set->fa_xflags |=FS_XFLAG_COWEXTSIZE ; + attr_set->fa_extsize =BLOCKS * statbuf.st_blksize; + attr_set->fa_cowextsize =BLOCKS * statbuf.st_blksize; + attr_set->fa_projid =PROJID ; +} + +static struct tst_test test = { + .test_all = run, + .setup = setup, + .mntpoint =MNTPOINT , + .needs_root =1 , + .mount_device =1 , + .all_filesystems =1 ,
Quoted 8 lines
testcases/kernel/syscalls/file_attr/file_attr05.c line 56
Quoted 5 lines
testcases/kernel/syscalls/file_attr/file_attr05.c new file +5
-0+ .format_device = 1, + .skip_filesystems = (const char *const []) { +"xfs" , +"fuse" ,/* EINVAL is raised before EOPNOTSUPP */ +"vfat" ,/* vfat is not implementing file_[set|get]attr */ Hm, funny, vfat not implementing also raises EOPNOTSUPP. I wonder if we should keep it as well.
It makes sense from the point of view of the results, but it doesn't make sense from the point of view of the test's meaning. EOPNOTSUPP in case of vfat is raised for other reasons.
Quoted 7 lines
testcases/kernel/syscalls/file_attr/file_attr05.c line 60
Quoted 5 lines
testcases/kernel/syscalls/file_attr/file_attr05.c new file +4
-0+ NULL, + }, + .bufs = (struct tst_buffers []) { + {&attr_set, .size =sizeof (struct file_attr )},Again, I'd put
474b155adf392into tags. It's IMHO enough (no need for mentioning it in the docs.
Sorry I forgot, I'm going to send a v4.
Signature · 7 lines
Andrea Cervesato SUSE QE Automation Engineer Linux [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp