Linux Test Project
 help / color / mirror / Atom feed
* [LTP] [PATCH v5 0/7] file_setattr/file_getattr testing suite
@ 2025-08-05 17:44 Andrea Cervesato
  2025-08-05 17:44 ` [LTP] [PATCH v5 1/7] Update LTP to the latest syscalls Andrea Cervesato
                   ` (6 more replies)
  0 siblings, 7 replies; 17+ messages in thread
From: Andrea Cervesato @ 2025-08-05 17:44 UTC (permalink / raw)
  To: ltp

This testing suite is validating file_getattr and file_setattr
syscalls, introducing tests for error validation and basic
functionalities. These features have been introduced in the kernel 6.17.

https://lore.kernel.org/lkml/20250725-vfs-fileattr-fcfc534aac44@brauner/

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
Changes in v5:
- file_attr04: only check for ENOTDIR
- Link to v4: https://lore.kernel.org/r/20250805-file_setattr_getattr-v4-0-08e23354abc8@suse.com

Changes in v4:
- import <linux/fs.h> in lapi/fs.h via HAVE_LINUX_FS
- file_attr01: initialize variables via .bufs and add one more test case
  for invalid usize
- file_attr02: avoid setting file desc to -1
- file_attr03: make use of AT_FWD
- add file_attr04 test
- Link to v3: https://lore.kernel.org/r/20250805-file_setattr_getattr-v3-0-67a7747d226c@suse.com

Changes in v3:
- fix fallback for fsxattr flags attributes
- Link to v2: https://lore.kernel.org/r/20250804-file_setattr_getattr-v2-0-651e50ec59e7@suse.com

Changes in v2:
- remove unrelated files
- fix fs.h ifndef
- Link to v1: https://lore.kernel.org/r/20250804-file_setattr_getattr-v1-0-6a43c3962c87@suse.com

---
Andrea Cervesato (7):
      Update LTP to the latest syscalls
      fs: add struct fsxattr fallback definitions
      fs: add file_setattr/file_getattr fallback definitions
      Add file_attr01 test
      Add file_attr02 test
      Add file_attr03 test
      Add file_attr04 test

 configure.ac                                      |   4 +
 include/lapi/fs.h                                 |  66 +++++++-
 include/lapi/syscalls/arc.in                      |   7 +
 include/lapi/syscalls/arm.in                      |   7 +
 include/lapi/syscalls/arm64.in                    |   7 +
 include/lapi/syscalls/i386.in                     |   7 +
 include/lapi/syscalls/loongarch64.in              |   7 +
 include/lapi/syscalls/mips64.in                   |   7 +
 include/lapi/syscalls/mips64n32.in                |   7 +
 include/lapi/syscalls/mipso32.in                  |   7 +
 include/lapi/syscalls/parisc.in                   |   7 +
 include/lapi/syscalls/powerpc.in                  |   7 +
 include/lapi/syscalls/powerpc64.in                |   7 +
 include/lapi/syscalls/s390.in                     |   7 +
 include/lapi/syscalls/s390x.in                    |   7 +
 include/lapi/syscalls/sh.in                       |   7 +
 include/lapi/syscalls/sparc.in                    |   7 +
 include/lapi/syscalls/sparc64.in                  |   7 +
 include/lapi/syscalls/x86_64.in                   |   7 +
 runtest/syscalls                                  |   5 +
 testcases/kernel/syscalls/file_attr/.gitignore    |   4 +
 testcases/kernel/syscalls/file_attr/Makefile      |   8 +
 testcases/kernel/syscalls/file_attr/file_attr01.c | 178 ++++++++++++++++++++++
 testcases/kernel/syscalls/file_attr/file_attr02.c |  92 +++++++++++
 testcases/kernel/syscalls/file_attr/file_attr03.c |  76 +++++++++
 testcases/kernel/syscalls/file_attr/file_attr04.c |  62 ++++++++
 26 files changed, 613 insertions(+), 1 deletion(-)
---
base-commit: b62b831cf0ba0420d4f2d4db2989ea0ad139d398
change-id: 20250801-file_setattr_getattr-74963fd52b05

Best regards,
-- 
Andrea Cervesato <andrea.cervesato@suse.com>


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [LTP] [PATCH v5 1/7] Update LTP to the latest syscalls
  2025-08-05 17:44 [LTP] [PATCH v5 0/7] file_setattr/file_getattr testing suite Andrea Cervesato
@ 2025-08-05 17:44 ` Andrea Cervesato
  2025-08-06 15:11   ` Cyril Hrubis
  2025-08-05 17:44 ` [LTP] [PATCH v5 2/7] fs: add struct fsxattr fallback definitions Andrea Cervesato
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 17+ messages in thread
From: Andrea Cervesato @ 2025-08-05 17:44 UTC (permalink / raw)
  To: ltp

From: Andrea Cervesato <andrea.cervesato@suse.com>

Add the following syscalls:

- setxattrat
- getxattrat
- listxattrat
- removexattrat
- open_tree_attr
- file_getattr
- file_setattr

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
 include/lapi/syscalls/arc.in         | 7 +++++++
 include/lapi/syscalls/arm.in         | 7 +++++++
 include/lapi/syscalls/arm64.in       | 7 +++++++
 include/lapi/syscalls/i386.in        | 7 +++++++
 include/lapi/syscalls/loongarch64.in | 7 +++++++
 include/lapi/syscalls/mips64.in      | 7 +++++++
 include/lapi/syscalls/mips64n32.in   | 7 +++++++
 include/lapi/syscalls/mipso32.in     | 7 +++++++
 include/lapi/syscalls/parisc.in      | 7 +++++++
 include/lapi/syscalls/powerpc.in     | 7 +++++++
 include/lapi/syscalls/powerpc64.in   | 7 +++++++
 include/lapi/syscalls/s390.in        | 7 +++++++
 include/lapi/syscalls/s390x.in       | 7 +++++++
 include/lapi/syscalls/sh.in          | 7 +++++++
 include/lapi/syscalls/sparc.in       | 7 +++++++
 include/lapi/syscalls/sparc64.in     | 7 +++++++
 include/lapi/syscalls/x86_64.in      | 7 +++++++
 17 files changed, 119 insertions(+)

diff --git a/include/lapi/syscalls/arc.in b/include/lapi/syscalls/arc.in
index f680d4119c10f73e2f1b8938c3be4a7254965ed0..0f0fbef6be74d06abbf4f1bbf77eeaf72a1e6b71 100644
--- a/include/lapi/syscalls/arc.in
+++ b/include/lapi/syscalls/arc.in
@@ -340,3 +340,10 @@ lsm_get_self_attr 459
 lsm_set_self_attr 460
 lsm_list_modules 461
 mseal 462
+setxattrat 463
+getxattrat 464
+listxattrat 465
+removexattrat 466
+open_tree_attr 467
+file_getattr 468
+file_setattr 469
diff --git a/include/lapi/syscalls/arm.in b/include/lapi/syscalls/arm.in
index 32e48b2151afbf55a19e493518395e4265c670a0..d0238dec5ecbf3849dff3b2c91ec88866dfb440c 100644
--- a/include/lapi/syscalls/arm.in
+++ b/include/lapi/syscalls/arm.in
@@ -413,3 +413,10 @@ lsm_get_self_attr 459
 lsm_set_self_attr 460
 lsm_list_modules 461
 mseal 462
+setxattrat 463
+getxattrat 464
+listxattrat 465
+removexattrat 466
+open_tree_attr 467
+file_getattr 468
+file_setattr 469
diff --git a/include/lapi/syscalls/arm64.in b/include/lapi/syscalls/arm64.in
index be7e9df6480c065ff63345d55082b1a6b2532760..c76930e20df02905c9c640a749b4ec2df421c665 100644
--- a/include/lapi/syscalls/arm64.in
+++ b/include/lapi/syscalls/arm64.in
@@ -316,3 +316,10 @@ lsm_get_self_attr 459
 lsm_set_self_attr 460
 lsm_list_modules 461
 mseal 462
+setxattrat 463
+getxattrat 464
+listxattrat 465
+removexattrat 466
+open_tree_attr 467
+file_getattr 468
+file_setattr 469
diff --git a/include/lapi/syscalls/i386.in b/include/lapi/syscalls/i386.in
index 13f72e7950ded9393e665cb1a44fe955343f820c..38ea71fb282d9dc69914b863cba352349fd1c9b9 100644
--- a/include/lapi/syscalls/i386.in
+++ b/include/lapi/syscalls/i386.in
@@ -447,3 +447,10 @@ lsm_get_self_attr 459
 lsm_set_self_attr 460
 lsm_list_modules 461
 mseal 462
+setxattrat 463
+getxattrat 464
+listxattrat 465
+removexattrat 466
+open_tree_attr 467
+file_getattr 468
+file_setattr 469
diff --git a/include/lapi/syscalls/loongarch64.in b/include/lapi/syscalls/loongarch64.in
index 2c1ecd7aeeb2fa4f38999bad144cfceee39a4a54..5407b86eaf738354f645f894bd95900ff614b3e1 100644
--- a/include/lapi/syscalls/loongarch64.in
+++ b/include/lapi/syscalls/loongarch64.in
@@ -312,3 +312,10 @@ lsm_get_self_attr 459
 lsm_set_self_attr 460
 lsm_list_modules 461
 mseal 462
+setxattrat 463
+getxattrat 464
+listxattrat 465
+removexattrat 466
+open_tree_attr 467
+file_getattr 468
+file_setattr 469
diff --git a/include/lapi/syscalls/mips64.in b/include/lapi/syscalls/mips64.in
index 8be734158fb7840b7757a012b6ed823f29eb7ab9..436d5c681c21f32623d779268b9c3daaaac5b5e0 100644
--- a/include/lapi/syscalls/mips64.in
+++ b/include/lapi/syscalls/mips64.in
@@ -362,3 +362,10 @@ lsm_get_self_attr 5459
 lsm_set_self_attr 5460
 lsm_list_modules 5461
 mseal 5462
+setxattrat 5463
+getxattrat 5464
+listxattrat 5465
+removexattrat 5466
+open_tree_attr 5467
+file_getattr 5468
+file_setattr 5469
diff --git a/include/lapi/syscalls/mips64n32.in b/include/lapi/syscalls/mips64n32.in
index 153fe50bf9a7c62978e458e1cb7225aa63b9edda..860a19c8b62866aeaf5b03c5c45ef5d6d58cab0f 100644
--- a/include/lapi/syscalls/mips64n32.in
+++ b/include/lapi/syscalls/mips64n32.in
@@ -386,3 +386,10 @@ lsm_get_self_attr 6459
 lsm_set_self_attr 6460
 lsm_list_modules 6461
 mseal 6462
+setxattrat 6463
+getxattrat 6464
+listxattrat 6465
+removexattrat 6466
+open_tree_attr 6467
+file_getattr 6468
+file_setattr 6469
diff --git a/include/lapi/syscalls/mipso32.in b/include/lapi/syscalls/mipso32.in
index 1ed74c1ecf281a3d208eded4a0dbd35fcc57e45f..5e53e46ce1e47c4618ceeeda03130cbdd621b180 100644
--- a/include/lapi/syscalls/mipso32.in
+++ b/include/lapi/syscalls/mipso32.in
@@ -426,3 +426,10 @@ lsm_get_self_attr 4459
 lsm_set_self_attr 4460
 lsm_list_modules 4461
 mseal 4462
+setxattrat 4463
+getxattrat 4464
+listxattrat 4465
+removexattrat 4466
+open_tree_attr 4467
+file_getattr 4468
+file_setattr 4469
diff --git a/include/lapi/syscalls/parisc.in b/include/lapi/syscalls/parisc.in
index 662bfea4428cf3b090b03632f2087251aaf3b513..238756694d9a03bcb063c21d3644aaa2af47f3fc 100644
--- a/include/lapi/syscalls/parisc.in
+++ b/include/lapi/syscalls/parisc.in
@@ -395,3 +395,10 @@ lsm_get_self_attr 459
 lsm_set_self_attr 460
 lsm_list_modules 461
 mseal 462
+setxattrat 463
+getxattrat 464
+listxattrat 465
+removexattrat 466
+open_tree_attr 467
+file_getattr 468
+file_setattr 469
diff --git a/include/lapi/syscalls/powerpc.in b/include/lapi/syscalls/powerpc.in
index faaa75883a7d2a0b70ca0e8064b6c91dae21d20c..6911f9af96247739a1ba7020aa3df77ef70ef55a 100644
--- a/include/lapi/syscalls/powerpc.in
+++ b/include/lapi/syscalls/powerpc.in
@@ -437,3 +437,10 @@ lsm_get_self_attr 459
 lsm_set_self_attr 460
 lsm_list_modules 461
 mseal 462
+setxattrat 463
+getxattrat 464
+listxattrat 465
+removexattrat 466
+open_tree_attr 467
+file_getattr 468
+file_setattr 469
diff --git a/include/lapi/syscalls/powerpc64.in b/include/lapi/syscalls/powerpc64.in
index 23b65e7840869c0cc08559324271b3b0d865ac01..98190ba266a1c7a6c3dbca1346e9d5e55783e271 100644
--- a/include/lapi/syscalls/powerpc64.in
+++ b/include/lapi/syscalls/powerpc64.in
@@ -409,3 +409,10 @@ lsm_get_self_attr 459
 lsm_set_self_attr 460
 lsm_list_modules 461
 mseal 462
+setxattrat 463
+getxattrat 464
+listxattrat 465
+removexattrat 466
+open_tree_attr 467
+file_getattr 468
+file_setattr 469
diff --git a/include/lapi/syscalls/s390.in b/include/lapi/syscalls/s390.in
index 69d7408b7bdf0d9019d3c319cd52ff48022aca39..a6cb85da805bec2540433783be9445645ab913ab 100644
--- a/include/lapi/syscalls/s390.in
+++ b/include/lapi/syscalls/s390.in
@@ -430,3 +430,10 @@ lsm_get_self_attr 459
 lsm_set_self_attr 460
 lsm_list_modules 461
 mseal 462
+setxattrat 463
+getxattrat 464
+listxattrat 465
+removexattrat 466
+open_tree_attr 467
+file_getattr 468
+file_setattr 469
diff --git a/include/lapi/syscalls/s390x.in b/include/lapi/syscalls/s390x.in
index fa98054c732787b62528c71f60b04de490b98958..31f3ec5532c8c3017188b60907f7666b41f44102 100644
--- a/include/lapi/syscalls/s390x.in
+++ b/include/lapi/syscalls/s390x.in
@@ -378,3 +378,10 @@ lsm_get_self_attr 459
 lsm_set_self_attr 460
 lsm_list_modules 461
 mseal 462
+setxattrat 463
+getxattrat 464
+listxattrat 465
+removexattrat 466
+open_tree_attr 467
+file_getattr 468
+file_setattr 469
diff --git a/include/lapi/syscalls/sh.in b/include/lapi/syscalls/sh.in
index 2e584253c61d51b140c3b2f586e3c49e5740e7af..ac281acf81ffe6770fa0d941d406714fbdce1bbd 100644
--- a/include/lapi/syscalls/sh.in
+++ b/include/lapi/syscalls/sh.in
@@ -424,3 +424,10 @@ lsm_get_self_attr 459
 lsm_set_self_attr 460
 lsm_list_modules 461
 mseal 462
+setxattrat 463
+getxattrat 464
+listxattrat 465
+removexattrat 466
+open_tree_attr 467
+file_getattr 468
+file_setattr 469
diff --git a/include/lapi/syscalls/sparc.in b/include/lapi/syscalls/sparc.in
index fcdb9b812ee6844d4981550f3eeed7ff081852f8..ffc0d9f7abdaa8873ec73ed1a5e0ec98b5f8b1d7 100644
--- a/include/lapi/syscalls/sparc.in
+++ b/include/lapi/syscalls/sparc.in
@@ -428,3 +428,10 @@ lsm_get_self_attr 459
 lsm_set_self_attr 460
 lsm_list_modules 461
 mseal 462
+setxattrat 463
+getxattrat 464
+listxattrat 465
+removexattrat 466
+open_tree_attr 467
+file_getattr 468
+file_setattr 469
diff --git a/include/lapi/syscalls/sparc64.in b/include/lapi/syscalls/sparc64.in
index 4256aaf77674ed0c00bbd092d7c715038e52f1c3..992bd307deb07d50ff814c603406842b5aedb431 100644
--- a/include/lapi/syscalls/sparc64.in
+++ b/include/lapi/syscalls/sparc64.in
@@ -391,3 +391,10 @@ lsm_get_self_attr 459
 lsm_set_self_attr 460
 lsm_list_modules 461
 mseal 462
+setxattrat 463
+getxattrat 464
+listxattrat 465
+removexattrat 466
+open_tree_attr 467
+file_getattr 468
+file_setattr 469
diff --git a/include/lapi/syscalls/x86_64.in b/include/lapi/syscalls/x86_64.in
index e6c0a3b4047d60e0e372c023c8f6a9bab76697af..e9c0d0599e25e3fa408686544c5d80c5a3e876d7 100644
--- a/include/lapi/syscalls/x86_64.in
+++ b/include/lapi/syscalls/x86_64.in
@@ -373,3 +373,10 @@ lsm_get_self_attr 459
 lsm_set_self_attr 460
 lsm_list_modules 461
 mseal 462
+setxattrat 463
+getxattrat 464
+listxattrat 465
+removexattrat 466
+open_tree_attr 467
+file_getattr 468
+file_setattr 469

-- 
2.50.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [LTP] [PATCH v5 2/7] fs: add struct fsxattr fallback definitions
  2025-08-05 17:44 [LTP] [PATCH v5 0/7] file_setattr/file_getattr testing suite Andrea Cervesato
  2025-08-05 17:44 ` [LTP] [PATCH v5 1/7] Update LTP to the latest syscalls Andrea Cervesato
@ 2025-08-05 17:44 ` Andrea Cervesato
  2025-08-06 15:28   ` Cyril Hrubis
  2025-08-05 17:44 ` [LTP] [PATCH v5 3/7] fs: add file_setattr/file_getattr " Andrea Cervesato
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 17+ messages in thread
From: Andrea Cervesato @ 2025-08-05 17:44 UTC (permalink / raw)
  To: ltp

From: Andrea Cervesato <andrea.cervesato@suse.com>

Add strut fsxattr fallback, as well as FS_IOC_FSGETFLAGS and
FS_IOC_FSSETFLAGS.

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
 configure.ac      |  3 +++
 include/lapi/fs.h | 22 +++++++++++++++++++++-
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 12025be51c865719b68c06ec3c286210dafbfa43..8b506e43f8c8549f6dc9cbc4154db2be95851e59 100644
--- a/configure.ac
+++ b/configure.ac
@@ -61,6 +61,7 @@ AC_CHECK_HEADERS_ONCE([ \
     linux/cryptouser.h \
     linux/close_range.h \
     linux/dccp.h \
+    linux/fs.h \
     linux/futex.h \
     linux/genetlink.h \
     linux/genhd.h \
@@ -264,6 +265,8 @@ AC_CHECK_TYPES([struct statmount],,,[#include <sys/mount.h>])
 
 AC_CHECK_TYPES([struct pidfd_info],,,[#include <sys/pidfd.h>])
 
+AC_CHECK_TYPES([struct fsxattr],,,[#include <linux/fs.h>])
+
 # Tools knobs
 
 # Bash
diff --git a/include/lapi/fs.h b/include/lapi/fs.h
index 8261ca41dab7d01ea5e7dc9d65e3d5604013cd46..44f299149abd9415c243b2052b93f1524442beb7 100644
--- a/include/lapi/fs.h
+++ b/include/lapi/fs.h
@@ -10,14 +10,26 @@
 #define LAPI_FS_H__
 
 #include "config.h"
-#ifndef HAVE_MOUNT_SETATTR
+#ifndef HAVE_LINUX_FS
 # include <linux/fs.h>
 #endif
 
+#include <stdint.h>
 #include <sys/user.h>
 #include <limits.h>
 #include "lapi/abisize.h"
 
+#ifndef HAVE_STRUCT_FSXATTR
+struct fsxattr {
+	uint32_t fsx_xflags;	        /* xflags field value (get/set) */
+	uint32_t fsx_extsize;	        /* extsize field value (get/set)*/
+	uint32_t fsx_nextents;	        /* nextents field value (get)	*/
+	uint32_t fsx_projid;            /* project identifier (get/set) */
+	uint32_t fsx_cowextsize;	/* CoW extsize field value (get/set)*/
+	unsigned char fsx_pad[8];
+};
+#endif
+
 #ifndef FS_IOC_GETFLAGS
 # define	FS_IOC_GETFLAGS	_IOR('f', 1, long)
 #endif
@@ -26,6 +38,14 @@
 # define	FS_IOC_SETFLAGS	_IOW('f', 2, long)
 #endif
 
+#ifndef FS_IOC_FSGETXATTR
+# define FS_IOC_FSGETXATTR _IOR('X', 31, struct fsxattr)
+#endif
+
+#ifndef FS_IOC_FSSETXATTR
+# define FS_IOC_FSSETXATTR _IOW('X', 32, struct fsxattr)
+#endif
+
 #ifndef FS_COMPR_FL
 # define	FS_COMPR_FL        0x00000004 /* Compress file */
 #endif

-- 
2.50.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [LTP] [PATCH v5 3/7] fs: add file_setattr/file_getattr fallback definitions
  2025-08-05 17:44 [LTP] [PATCH v5 0/7] file_setattr/file_getattr testing suite Andrea Cervesato
  2025-08-05 17:44 ` [LTP] [PATCH v5 1/7] Update LTP to the latest syscalls Andrea Cervesato
  2025-08-05 17:44 ` [LTP] [PATCH v5 2/7] fs: add struct fsxattr fallback definitions Andrea Cervesato
@ 2025-08-05 17:44 ` Andrea Cervesato
  2025-08-06 15:36   ` Cyril Hrubis
  2025-08-05 17:44 ` [LTP] [PATCH v5 4/7] Add file_attr01 test Andrea Cervesato
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 17+ messages in thread
From: Andrea Cervesato @ 2025-08-05 17:44 UTC (permalink / raw)
  To: ltp

From: Andrea Cervesato <andrea.cervesato@suse.com>

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
 configure.ac      |  1 +
 include/lapi/fs.h | 44 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+)

diff --git a/configure.ac b/configure.ac
index 8b506e43f8c8549f6dc9cbc4154db2be95851e59..9657adfcf5fc26d704f36e159f7e3abb7de86900 100644
--- a/configure.ac
+++ b/configure.ac
@@ -264,6 +264,7 @@ AC_CHECK_TYPES([struct mnt_id_req],,,[#include <sys/mount.h>])
 AC_CHECK_TYPES([struct statmount],,,[#include <sys/mount.h>])
 
 AC_CHECK_TYPES([struct pidfd_info],,,[#include <sys/pidfd.h>])
+AC_CHECK_TYPES([struct file_attr],,,[#include <linux/fs.h>])
 
 AC_CHECK_TYPES([struct fsxattr],,,[#include <linux/fs.h>])
 
diff --git a/include/lapi/fs.h b/include/lapi/fs.h
index 44f299149abd9415c243b2052b93f1524442beb7..66eb0abfb675b6209ad4f9d47c1217fc9b1742e2 100644
--- a/include/lapi/fs.h
+++ b/include/lapi/fs.h
@@ -14,10 +14,13 @@
 # include <linux/fs.h>
 #endif
 
+#include <stddef.h>
 #include <stdint.h>
 #include <sys/user.h>
 #include <limits.h>
+#include "tst_test.h"
 #include "lapi/abisize.h"
+#include "lapi/syscalls.h"
 
 #ifndef HAVE_STRUCT_FSXATTR
 struct fsxattr {
@@ -66,6 +69,18 @@ struct fsxattr {
 # define FS_VERITY_FL	   0x00100000 /* Verity protected inode */
 #endif
 
+#ifndef FS_XFLAG_APPEND
+# define FS_XFLAG_APPEND	0x00000010	/* all writes append */
+#endif
+
+#ifndef FS_XFLAG_EXTSIZE
+# define FS_XFLAG_EXTSIZE	0x00000800	/* extent size allocator hint */
+#endif
+
+#ifndef FS_XFLAG_COWEXTSIZE
+# define FS_XFLAG_COWEXTSIZE	0x00010000	/* CoW extent size allocator hint */
+#endif
+
 /*
  * Helper function to get MAX_LFS_FILESIZE.
  * Missing PAGE_SHIFT on some libc prevents defining MAX_LFS_FILESIZE.
@@ -88,4 +103,33 @@ static inline long long tst_max_lfs_filesize(void)
 #endif
 }
 
+#ifndef HAVE_STRUCT_FILE_ATTR
+struct file_attr {
+	uint64_t fa_xflags;	/* xflags field value (get/set) */
+	uint32_t fa_extsize;	/* extsize field value (get/set)*/
+	uint32_t fa_nextents;	/* nextents field value (get)   */
+	uint32_t fa_projid;	/* project identifier (get/set) */
+	uint32_t fa_cowextsize;	/* CoW extsize field value (get/set) */
+};
+#endif
+
+#define FILE_ATTR_SIZE_VER0 24
+#define FILE_ATTR_SIZE_LATEST FILE_ATTR_SIZE_VER0
+
+static inline int file_getattr(int dfd, const char *filename,
+			    struct file_attr *ufattr, size_t usize,
+			    unsigned int at_flags)
+{
+	return tst_syscall(__NR_file_getattr, dfd, filename, ufattr, usize,
+		    at_flags);
+}
+
+static inline int file_setattr(int dfd, const char *filename,
+			    struct file_attr *ufattr, size_t usize,
+			    unsigned int at_flags)
+{
+	return tst_syscall(__NR_file_setattr, dfd, filename, ufattr, usize,
+		    at_flags);
+}
+
 #endif /* LAPI_FS_H__ */

-- 
2.50.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [LTP] [PATCH v5 4/7] Add file_attr01 test
  2025-08-05 17:44 [LTP] [PATCH v5 0/7] file_setattr/file_getattr testing suite Andrea Cervesato
                   ` (2 preceding siblings ...)
  2025-08-05 17:44 ` [LTP] [PATCH v5 3/7] fs: add file_setattr/file_getattr " Andrea Cervesato
@ 2025-08-05 17:44 ` Andrea Cervesato
  2025-08-06 15:03   ` Cyril Hrubis
  2025-08-05 17:44 ` [LTP] [PATCH v5 5/7] Add file_attr02 test Andrea Cervesato
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 17+ messages in thread
From: Andrea Cervesato @ 2025-08-05 17:44 UTC (permalink / raw)
  To: ltp

From: Andrea Cervesato <andrea.cervesato@suse.com>

Verify that `file_getattr` and `file_setattr` syscalls are raising the
correct errors according to the invalid input arguments. In particular:

- EBADFD: Invalid file descriptor.
- ENOENT: File doesn't exist
- EFAULT: File name is NULL
- EFAULT: File attributes is NULL
- EINVAL: File attributes size is zero
- E2BIG: File attributes size is too big
- EINVAL: Invalid AT flags

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
 runtest/syscalls                                  |   2 +
 testcases/kernel/syscalls/file_attr/.gitignore    |   1 +
 testcases/kernel/syscalls/file_attr/Makefile      |   8 +
 testcases/kernel/syscalls/file_attr/file_attr01.c | 178 ++++++++++++++++++++++
 4 files changed, 189 insertions(+)

diff --git a/runtest/syscalls b/runtest/syscalls
index 6a17a34f8b5fc1289947d4504b7a146f3d022f1c..fed17a38baf0586ec886876b58c04158fa11e8e0 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -246,6 +246,8 @@ fallocate06 fallocate06
 fsetxattr01 fsetxattr01
 fsetxattr02 fsetxattr02
 
+file_attr01 file_attr01
+
 #posix_fadvise test cases
 posix_fadvise01                      posix_fadvise01
 posix_fadvise01_64                posix_fadvise01_64
diff --git a/testcases/kernel/syscalls/file_attr/.gitignore b/testcases/kernel/syscalls/file_attr/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..de06f204d34be482a6401f2a5e7931caa5e3ab12
--- /dev/null
+++ b/testcases/kernel/syscalls/file_attr/.gitignore
@@ -0,0 +1 @@
+file_attr01
diff --git a/testcases/kernel/syscalls/file_attr/Makefile b/testcases/kernel/syscalls/file_attr/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..3b19b0ce6be00839038c405eea027b0102761e45
--- /dev/null
+++ b/testcases/kernel/syscalls/file_attr/Makefile
@@ -0,0 +1,8 @@
+# Copyright (c) 2025 - Linaro Limited. All rights reserved.
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/file_attr/file_attr01.c b/testcases/kernel/syscalls/file_attr/file_attr01.c
new file mode 100644
index 0000000000000000000000000000000000000000..b1eae6a465ff9f036f3baf8914899729e7933005
--- /dev/null
+++ b/testcases/kernel/syscalls/file_attr/file_attr01.c
@@ -0,0 +1,178 @@
+// 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` syscalls are raising the
+ * correct errors according to the invalid input arguments. In particular:
+ *
+ * - EBADFD: Invalid file descriptor.
+ * - ENOENT: File doesn't exist
+ * - EFAULT: File name is NULL
+ * - EFAULT: File attributes is NULL
+ * - EINVAL: File attributes size is zero
+ * - E2BIG: File attributes size is too big
+ * - EINVAL: Invalid AT flags
+ */
+
+#include <string.h>
+#include "tst_test.h"
+#include "lapi/fs.h"
+#include "lapi/fcntl.h"
+
+#define MNTPOINT "mntpoint"
+#define FILENAME "ltp_file"
+#define NO_FILENAME "ltp_file_doesnt_exist"
+
+static int valid_dfd = -1;
+static int invalid_dfd = -1;
+static char *valid_filename;
+static char *invalid_filename;
+static char *null_ptr;
+static size_t zero;
+static size_t small_usize;
+static size_t valid_usize;
+static size_t big_usize;
+static struct file_attr *valid_file_attr;
+
+static struct tcase {
+	int *dfd;
+	char **filename;
+	struct file_attr **ufattr;
+	size_t *usize;
+	int at_flags;
+	int exp_errno;
+	char *msg;
+} tcases[] = {
+	{
+		.dfd = &invalid_dfd,
+		.filename = &valid_filename,
+		.ufattr = &valid_file_attr,
+		.usize = &valid_usize,
+		.exp_errno = EBADF,
+		.msg = "Invalid file descriptor",
+	},
+	{
+		.dfd = &valid_dfd,
+		.filename = &invalid_filename,
+		.ufattr = &valid_file_attr,
+		.usize = &valid_usize,
+		.exp_errno = ENOENT,
+		.msg = "File doesn't exist",
+	},
+	{
+		.dfd = &valid_dfd,
+		.filename = &null_ptr,
+		.ufattr = &valid_file_attr,
+		.usize = &valid_usize,
+		.exp_errno = EFAULT,
+		.msg = "Filename is NULL",
+	},
+	{
+		.dfd = &valid_dfd,
+		.filename = &valid_filename,
+		.ufattr = (struct file_attr **)(&null_ptr),
+		.usize = &valid_usize,
+		.exp_errno = EFAULT,
+		.msg = "File attributes is NULL",
+	},
+	{
+		.dfd = &valid_dfd,
+		.filename = &valid_filename,
+		.ufattr = &valid_file_attr,
+		.usize = &zero,
+		.exp_errno = EINVAL,
+		.msg = "File attributes size is zero",
+	},
+	{
+		.dfd = &valid_dfd,
+		.filename = &valid_filename,
+		.ufattr = &valid_file_attr,
+		.usize = &small_usize,
+		.exp_errno = EINVAL,
+		.msg = "File attributes size is too small",
+	},
+	{
+		.dfd = &valid_dfd,
+		.filename = &valid_filename,
+		.ufattr = &valid_file_attr,
+		.usize = &big_usize,
+		.exp_errno = E2BIG,
+		.msg = "File attributes size is too big",
+	},
+	{
+		.dfd = &valid_dfd,
+		.filename = &valid_filename,
+		.ufattr = &valid_file_attr,
+		.usize = &valid_usize,
+		.at_flags = -1,
+		.exp_errno = EINVAL,
+		.msg = "Invalid AT flags",
+	},
+};
+
+static void run(unsigned int i)
+{
+	struct tcase *tc = &tcases[i];
+
+	if (tst_variant) {
+		TST_EXP_FAIL(file_getattr(
+			*tc->dfd, *tc->filename,
+			*tc->ufattr, *tc->usize,
+			tc->at_flags),
+			tc->exp_errno,
+			"%s", tc->msg);
+	} else {
+		TST_EXP_FAIL(file_setattr(
+			*tc->dfd, *tc->filename,
+			*tc->ufattr, *tc->usize,
+			tc->at_flags),
+			tc->exp_errno,
+			"%s", tc->msg);
+	}
+}
+
+static void setup(void)
+{
+	valid_dfd = SAFE_OPEN(MNTPOINT, O_RDONLY);
+
+	SAFE_CHDIR(MNTPOINT);
+	SAFE_TOUCH(FILENAME, 0777, NULL);
+	SAFE_CHDIR("..");
+
+	valid_usize = FILE_ATTR_SIZE_LATEST;
+	small_usize = FILE_ATTR_SIZE_LATEST - 1;
+	big_usize = SAFE_SYSCONF(_SC_PAGESIZE) + 100;
+}
+
+static void cleanup(void)
+{
+	if (valid_dfd != -1)
+		SAFE_CLOSE(valid_dfd);
+}
+
+static struct tst_test test = {
+	.test = run,
+	.setup = setup,
+	.cleanup = cleanup,
+	.tcnt = ARRAY_SIZE(tcases),
+	.mntpoint = MNTPOINT,
+	.needs_root = 1,
+	.mount_device = 1,
+	.all_filesystems = 1,
+	.test_variants = 2,
+	.skip_filesystems = (const char *const []) {
+		"fuse",
+		"ntfs",
+		"vfat",
+		"exfat",
+		NULL
+	},
+	.bufs = (struct tst_buffers []) {
+		{&valid_filename, .str = FILENAME},
+		{&invalid_filename, .str = NO_FILENAME},
+		{&valid_file_attr, .size = sizeof(struct file_attr)},
+		{}
+	}
+};

-- 
2.50.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [LTP] [PATCH v5 5/7] Add file_attr02 test
  2025-08-05 17:44 [LTP] [PATCH v5 0/7] file_setattr/file_getattr testing suite Andrea Cervesato
                   ` (3 preceding siblings ...)
  2025-08-05 17:44 ` [LTP] [PATCH v5 4/7] Add file_attr01 test Andrea Cervesato
@ 2025-08-05 17:44 ` Andrea Cervesato
  2025-08-06 14:56   ` Cyril Hrubis
  2025-08-05 17:44 ` [LTP] [PATCH v5 6/7] Add file_attr03 test Andrea Cervesato
  2025-08-05 17:44 ` [LTP] [PATCH v5 7/7] Add file_attr04 test Andrea Cervesato
  6 siblings, 1 reply; 17+ messages in thread
From: Andrea Cervesato @ 2025-08-05 17:44 UTC (permalink / raw)
  To: ltp

From: Andrea Cervesato <andrea.cervesato@suse.com>

Verify that `file_getattr` is correctly reading filesystems additional
attributes. We are running test on XFS only, since it's the only filesystem
currently implementing the features we need.

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_attr02.c | 92 +++++++++++++++++++++++
 3 files changed, 94 insertions(+)

diff --git a/runtest/syscalls b/runtest/syscalls
index fed17a38baf0586ec886876b58c04158fa11e8e0..b69e474a6a596359bb1ace30312b55d6bf2b65cc 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -247,6 +247,7 @@ fsetxattr01 fsetxattr01
 fsetxattr02 fsetxattr02
 
 file_attr01 file_attr01
+file_attr02 file_attr02
 
 #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 de06f204d34be482a6401f2a5e7931caa5e3ab12..afe9c2fc9a4218dc032f044c1d317355a784a525 100644
--- a/testcases/kernel/syscalls/file_attr/.gitignore
+++ b/testcases/kernel/syscalls/file_attr/.gitignore
@@ -1 +1,2 @@
 file_attr01
+file_attr02
diff --git a/testcases/kernel/syscalls/file_attr/file_attr02.c b/testcases/kernel/syscalls/file_attr/file_attr02.c
new file mode 100644
index 0000000000000000000000000000000000000000..4e0d87f0f3edc946bf9cd14e76cce9518bf928d0
--- /dev/null
+++ b/testcases/kernel/syscalls/file_attr/file_attr02.c
@@ -0,0 +1,92 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2025 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
+ */
+
+/*\
+ * Verify that `file_getattr` is correctly reading filesystems additional
+ * attributes. We are running test on XFS only, since it's the only filesystem
+ * currently implementing the features we need.
+ */
+
+#include "tst_test.h"
+#include "lapi/fs.h"
+
+#define MNTPOINT "mntpoint"
+#define FILENAME "ltp_file"
+#define BLOCKS 1024
+#define PROJID 16
+
+static int fd = -1;
+static int dfd = -1;
+static struct fsxattr xattr;
+static struct file_attr *attr;
+
+static void run(void)
+{
+	memset(attr, 0, sizeof(*attr));
+
+	TST_EXP_PASS(file_getattr(
+		dfd, FILENAME,
+		attr, FILE_ATTR_SIZE_LATEST,
+		0));
+
+	TST_EXP_EQ_LI(attr->fa_xflags, xattr.fsx_xflags);
+	TST_EXP_EQ_LI(attr->fa_extsize, xattr.fsx_extsize);
+	TST_EXP_EQ_LI(attr->fa_cowextsize, xattr.fsx_cowextsize);
+	TST_EXP_EQ_LI(attr->fa_nextents, xattr.fsx_nextents);
+	TST_EXP_EQ_LI(attr->fa_projid, PROJID);
+	TST_EXP_EQ_LI(attr->fa_projid, xattr.fsx_projid);
+}
+
+static void setup(void)
+{
+	int block_size;
+
+	block_size = tst_dev_block_size(MNTPOINT);
+
+	dfd = SAFE_OPEN(MNTPOINT, O_RDONLY);
+	fd = SAFE_CREAT(MNTPOINT "/" FILENAME, 0777);
+
+	SAFE_IOCTL(fd, FS_IOC_FSGETXATTR, &xattr);
+
+	xattr.fsx_xflags |= FS_XFLAG_EXTSIZE;
+	xattr.fsx_xflags |= FS_XFLAG_COWEXTSIZE;
+	xattr.fsx_extsize = BLOCKS * block_size;
+	xattr.fsx_cowextsize = BLOCKS * block_size;
+	xattr.fsx_projid = PROJID;
+
+	SAFE_IOCTL(fd, FS_IOC_FSSETXATTR, &xattr);
+
+	/* this will force at least one extent to be allocated */
+	SAFE_WRITE(SAFE_WRITE_ALL, fd, "a", 1);
+
+	SAFE_IOCTL(fd, FS_IOC_FSGETXATTR, &xattr);
+	SAFE_CLOSE(fd);
+}
+
+static void cleanup(void)
+{
+	if (fd != -1)
+		SAFE_CLOSE(fd);
+
+	if (dfd != -1)
+		SAFE_CLOSE(dfd);
+}
+
+static struct tst_test test = {
+	.test_all = run,
+	.setup = setup,
+	.cleanup = cleanup,
+	.mntpoint = MNTPOINT,
+	.needs_root = 1,
+	.mount_device = 1,
+	.filesystems = (struct tst_fs []) {
+		{.type = "xfs"},
+		{}
+	},
+	.bufs = (struct tst_buffers []) {
+		{&attr, .size = sizeof(struct file_attr)},
+		{}
+	}
+};

-- 
2.50.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [LTP] [PATCH v5 6/7] Add file_attr03 test
  2025-08-05 17:44 [LTP] [PATCH v5 0/7] file_setattr/file_getattr testing suite Andrea Cervesato
                   ` (4 preceding siblings ...)
  2025-08-05 17:44 ` [LTP] [PATCH v5 5/7] Add file_attr02 test Andrea Cervesato
@ 2025-08-05 17:44 ` Andrea Cervesato
  2025-08-06 14:42   ` Cyril Hrubis
  2025-08-05 17:44 ` [LTP] [PATCH v5 7/7] Add file_attr04 test Andrea Cervesato
  6 siblings, 1 reply; 17+ messages in thread
From: Andrea Cervesato @ 2025-08-05 17:44 UTC (permalink / raw)
  To: ltp

From: Andrea Cervesato <andrea.cervesato@suse.com>

Verify that `file_setattr` is correctly setting filesystems additional
attributes. We are running test on XFS only, since it's the only filesystem
currently implementing the features we need.

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_attr03.c | 76 +++++++++++++++++++++++
 3 files changed, 78 insertions(+)

diff --git a/runtest/syscalls b/runtest/syscalls
index b69e474a6a596359bb1ace30312b55d6bf2b65cc..c33987328d3d6ec96660260aaee4f9ca8c4f0aee 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -248,6 +248,7 @@ fsetxattr02 fsetxattr02
 
 file_attr01 file_attr01
 file_attr02 file_attr02
+file_attr03 file_attr03
 
 #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 afe9c2fc9a4218dc032f044c1d317355a784a525..b79a340b733f7407dc135c5c3b0a9cd0e003e6c9 100644
--- a/testcases/kernel/syscalls/file_attr/.gitignore
+++ b/testcases/kernel/syscalls/file_attr/.gitignore
@@ -1,2 +1,3 @@
 file_attr01
 file_attr02
+file_attr03
diff --git a/testcases/kernel/syscalls/file_attr/file_attr03.c b/testcases/kernel/syscalls/file_attr/file_attr03.c
new file mode 100644
index 0000000000000000000000000000000000000000..9ad7790411a87f72bb0bd41a01063c3a0eccff2f
--- /dev/null
+++ b/testcases/kernel/syscalls/file_attr/file_attr03.c
@@ -0,0 +1,76 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2025 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
+ */
+
+/*\
+ * Verify that `file_setattr` is correctly setting filesystems additional
+ * attributes. We are running test on XFS only, since it's the only filesystem
+ * currently implementing the features we need.
+ */
+
+#include "tst_test.h"
+#include "lapi/fs.h"
+
+#define MNTPOINT "mntpoint"
+#define FILEPATH (MNTPOINT "/ltp_file")
+#define BLOCKS 1024
+#define PROJID 16
+
+static int fd = -1;
+static int block_size;
+static struct fsxattr xattr;
+static struct file_attr *attr;
+
+static void run(void)
+{
+	fd = SAFE_CREAT(FILEPATH, 0777);
+
+	TST_EXP_PASS(file_setattr(AT_FDCWD, FILEPATH,
+			   attr, FILE_ATTR_SIZE_LATEST, 0));
+
+	SAFE_IOCTL(fd, FS_IOC_FSGETXATTR, &xattr);
+	SAFE_CLOSE(fd);
+
+	TST_EXP_EQ_LI(xattr.fsx_xflags & FS_XFLAG_EXTSIZE, FS_XFLAG_EXTSIZE);
+	TST_EXP_EQ_LI(xattr.fsx_xflags & FS_XFLAG_COWEXTSIZE, FS_XFLAG_COWEXTSIZE);
+	TST_EXP_EQ_LI(xattr.fsx_extsize, BLOCKS * block_size);
+	TST_EXP_EQ_LI(xattr.fsx_cowextsize, BLOCKS * block_size);
+	TST_EXP_EQ_LI(xattr.fsx_projid, PROJID);
+
+	SAFE_UNLINK(FILEPATH);
+}
+
+static void setup(void)
+{
+	block_size = tst_dev_block_size(MNTPOINT);
+
+	attr->fa_xflags |= FS_XFLAG_EXTSIZE;
+	attr->fa_xflags |= FS_XFLAG_COWEXTSIZE;
+	attr->fa_extsize = BLOCKS * block_size;
+	attr->fa_cowextsize = BLOCKS * block_size;
+	attr->fa_projid = PROJID;
+}
+
+static void cleanup(void)
+{
+	if (fd != -1)
+		SAFE_CLOSE(fd);
+}
+
+static struct tst_test test = {
+	.test_all = run,
+	.setup = setup,
+	.cleanup = cleanup,
+	.mntpoint = MNTPOINT,
+	.needs_root = 1,
+	.mount_device = 1,
+	.filesystems = (struct tst_fs []) {
+		{.type = "xfs"},
+		{}
+	},
+	.bufs = (struct tst_buffers []) {
+		{&attr, .size = sizeof(struct file_attr)},
+		{}
+	}
+};

-- 
2.50.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [LTP] [PATCH v5 7/7] Add file_attr04 test
  2025-08-05 17:44 [LTP] [PATCH v5 0/7] file_setattr/file_getattr testing suite Andrea Cervesato
                   ` (5 preceding siblings ...)
  2025-08-05 17:44 ` [LTP] [PATCH v5 6/7] Add file_attr03 test Andrea Cervesato
@ 2025-08-05 17:44 ` Andrea Cervesato
  2025-08-06 14:23   ` Cyril Hrubis
  6 siblings, 1 reply; 17+ messages in thread
From: Andrea Cervesato @ 2025-08-05 17:44 UTC (permalink / raw)
  To: ltp

From: Andrea Cervesato <andrea.cervesato@suse.com>

Verify that `file_getattr` and `file_setattr` are correctly raising
an error when the wrong file descriptors types are passed to them.

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_attr04.c | 62 +++++++++++++++++++++++
 3 files changed, 64 insertions(+)

diff --git a/runtest/syscalls b/runtest/syscalls
index c33987328d3d6ec96660260aaee4f9ca8c4f0aee..c9b46b8efe3217150ee0740e982ea5a133b3aa46 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -249,6 +249,7 @@ fsetxattr02 fsetxattr02
 file_attr01 file_attr01
 file_attr02 file_attr02
 file_attr03 file_attr03
+file_attr04 file_attr04
 
 #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 b79a340b733f7407dc135c5c3b0a9cd0e003e6c9..3fcb9004dd301ef4ee8cc1067c6a3763acb8d299 100644
--- a/testcases/kernel/syscalls/file_attr/.gitignore
+++ b/testcases/kernel/syscalls/file_attr/.gitignore
@@ -1,3 +1,4 @@
 file_attr01
 file_attr02
 file_attr03
+file_attr04
diff --git a/testcases/kernel/syscalls/file_attr/file_attr04.c b/testcases/kernel/syscalls/file_attr/file_attr04.c
new file mode 100644
index 0000000000000000000000000000000000000000..364fad08e339e713d590b166136dc1c506daac0d
--- /dev/null
+++ b/testcases/kernel/syscalls/file_attr/file_attr04.c
@@ -0,0 +1,62 @@
+// 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 an error
+ * when the wrong file descriptors types are passed to them.
+ */
+
+#include "tst_test.h"
+#include "lapi/fs.h"
+
+#define FILENAME "ltp_file"
+
+static struct file_attr *attr;
+
+static void test_invalid_fd(struct tst_fd *fd)
+{
+	if (fd->type == TST_FD_DIR || fd->type == TST_FD_OPEN_TREE) {
+		tst_res(TCONF, "Skipping DIR fd");
+		return;
+	}
+
+	memset(attr, 0, sizeof(*attr));
+
+	if (tst_variant) {
+		TST_EXP_FAIL(file_getattr(
+			fd->fd, FILENAME,
+			attr, FILE_ATTR_SIZE_LATEST,
+			0), ENOTDIR);
+	} else {
+		TST_EXP_FAIL(file_setattr(
+			fd->fd, FILENAME,
+			attr, FILE_ATTR_SIZE_LATEST,
+			0), ENOTDIR);
+	}
+}
+
+static void run(void)
+{
+	TST_FD_FOREACH(fd) {
+		tst_res(TINFO, "%s -> ...", tst_fd_desc(&fd));
+		test_invalid_fd(&fd);
+	}
+}
+
+static void setup(void)
+{
+	SAFE_TOUCH(FILENAME, 0640, NULL);
+}
+
+static struct tst_test test = {
+	.test_all = run,
+	.setup = setup,
+	.test_variants = 2,
+	.needs_tmpdir = 1,
+	.bufs = (struct tst_buffers []) {
+		{&attr, .size = sizeof(struct file_attr)},
+		{}
+	}
+};

-- 
2.50.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [LTP] [PATCH v5 7/7] Add file_attr04 test
  2025-08-05 17:44 ` [LTP] [PATCH v5 7/7] Add file_attr04 test Andrea Cervesato
@ 2025-08-06 14:23   ` Cyril Hrubis
  2025-08-06 14:30     ` Cyril Hrubis
  0 siblings, 1 reply; 17+ messages in thread
From: Cyril Hrubis @ 2025-08-06 14:23 UTC (permalink / raw)
  To: Andrea Cervesato; +Cc: ltp

Hi!
> +/*\
> + * Verify that `file_getattr` and `file_setattr` are correctly raising an error
> + * when the wrong file descriptors types are passed to them.
> + */
> +
> +#include "tst_test.h"
> +#include "lapi/fs.h"
> +
> +#define FILENAME "ltp_file"
> +
> +static struct file_attr *attr;
> +
> +static void test_invalid_fd(struct tst_fd *fd)
> +{
> +	if (fd->type == TST_FD_DIR || fd->type == TST_FD_OPEN_TREE) {

Just curious, does the fd from open_tree() work fine as dirfd or do we
just get differnt errno? I think second one may be the case, since the
file descriptor from open_tree() syscall usually behaves a bit strange.

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [LTP] [PATCH v5 7/7] Add file_attr04 test
  2025-08-06 14:23   ` Cyril Hrubis
@ 2025-08-06 14:30     ` Cyril Hrubis
  0 siblings, 0 replies; 17+ messages in thread
From: Cyril Hrubis @ 2025-08-06 14:30 UTC (permalink / raw)
  To: Andrea Cervesato; +Cc: ltp

Hi!
> Just curious, does the fd from open_tree() work fine as dirfd or do we
> just get differnt errno? I think second one may be the case, since the
> file descriptor from open_tree() syscall usually behaves a bit strange.

Looks like kernel internally does:

return dentry_open(&path, O_PATH, current_cred());

So I suppose that the fd from open_tree() is actually usable as a dirfd.

Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [LTP] [PATCH v5 6/7] Add file_attr03 test
  2025-08-05 17:44 ` [LTP] [PATCH v5 6/7] Add file_attr03 test Andrea Cervesato
@ 2025-08-06 14:42   ` Cyril Hrubis
  0 siblings, 0 replies; 17+ messages in thread
From: Cyril Hrubis @ 2025-08-06 14:42 UTC (permalink / raw)
  To: Andrea Cervesato; +Cc: ltp

Hi!
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [LTP] [PATCH v5 5/7] Add file_attr02 test
  2025-08-05 17:44 ` [LTP] [PATCH v5 5/7] Add file_attr02 test Andrea Cervesato
@ 2025-08-06 14:56   ` Cyril Hrubis
  0 siblings, 0 replies; 17+ messages in thread
From: Cyril Hrubis @ 2025-08-06 14:56 UTC (permalink / raw)
  To: Andrea Cervesato; +Cc: ltp

Hi!
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [LTP] [PATCH v5 4/7] Add file_attr01 test
  2025-08-05 17:44 ` [LTP] [PATCH v5 4/7] Add file_attr01 test Andrea Cervesato
@ 2025-08-06 15:03   ` Cyril Hrubis
  0 siblings, 0 replies; 17+ messages in thread
From: Cyril Hrubis @ 2025-08-06 15:03 UTC (permalink / raw)
  To: Andrea Cervesato; +Cc: ltp

Hi!
> +
> +	valid_usize = FILE_ATTR_SIZE_LATEST;
> +	small_usize = FILE_ATTR_SIZE_LATEST - 1;
                                     ^
				     VER0

Otherwise:

Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [LTP] [PATCH v5 1/7] Update LTP to the latest syscalls
  2025-08-05 17:44 ` [LTP] [PATCH v5 1/7] Update LTP to the latest syscalls Andrea Cervesato
@ 2025-08-06 15:11   ` Cyril Hrubis
  0 siblings, 0 replies; 17+ messages in thread
From: Cyril Hrubis @ 2025-08-06 15:11 UTC (permalink / raw)
  To: Andrea Cervesato; +Cc: ltp

Hi!
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [LTP] [PATCH v5 2/7] fs: add struct fsxattr fallback definitions
  2025-08-05 17:44 ` [LTP] [PATCH v5 2/7] fs: add struct fsxattr fallback definitions Andrea Cervesato
@ 2025-08-06 15:28   ` Cyril Hrubis
  0 siblings, 0 replies; 17+ messages in thread
From: Cyril Hrubis @ 2025-08-06 15:28 UTC (permalink / raw)
  To: Andrea Cervesato; +Cc: ltp

Hi!
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [LTP] [PATCH v5 3/7] fs: add file_setattr/file_getattr fallback definitions
  2025-08-05 17:44 ` [LTP] [PATCH v5 3/7] fs: add file_setattr/file_getattr " Andrea Cervesato
@ 2025-08-06 15:36   ` Cyril Hrubis
  2025-08-07  6:39     ` Andrea Cervesato via ltp
  0 siblings, 1 reply; 17+ messages in thread
From: Cyril Hrubis @ 2025-08-06 15:36 UTC (permalink / raw)
  To: Andrea Cervesato; +Cc: ltp

Hi!
> +#define FILE_ATTR_SIZE_VER0 24
> +#define FILE_ATTR_SIZE_LATEST FILE_ATTR_SIZE_VER0
> +
> +static inline int file_getattr(int dfd, const char *filename,
> +			    struct file_attr *ufattr, size_t usize,
> +			    unsigned int at_flags)
> +{
> +	return tst_syscall(__NR_file_getattr, dfd, filename, ufattr, usize,
> +		    at_flags);
> +}
> +
> +static inline int file_setattr(int dfd, const char *filename,
> +			    struct file_attr *ufattr, size_t usize,
> +			    unsigned int at_flags)
> +{
> +	return tst_syscall(__NR_file_setattr, dfd, filename, ufattr, usize,
> +		    at_flags);
> +}

I wonder if we need configure checks for these (i.e. if glibc is going
to add these as syscall wrappers) but I guess we can add them later on
when needed.

Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [LTP] [PATCH v5 3/7] fs: add file_setattr/file_getattr fallback definitions
  2025-08-06 15:36   ` Cyril Hrubis
@ 2025-08-07  6:39     ` Andrea Cervesato via ltp
  0 siblings, 0 replies; 17+ messages in thread
From: Andrea Cervesato via ltp @ 2025-08-07  6:39 UTC (permalink / raw)
  To: Cyril Hrubis, Andrea Cervesato; +Cc: ltp

On 8/6/25 5:36 PM, Cyril Hrubis wrote:

> I wonder if we need configure checks for these (i.e. if glibc is going
> to add these as syscall wrappers) but I guess we can add them later on
> when needed.

Better to do it now, they seem to be an important update in the kernel. 
I will send it in the next version.

- Andrea


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2025-08-07  6:39 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-05 17:44 [LTP] [PATCH v5 0/7] file_setattr/file_getattr testing suite Andrea Cervesato
2025-08-05 17:44 ` [LTP] [PATCH v5 1/7] Update LTP to the latest syscalls Andrea Cervesato
2025-08-06 15:11   ` Cyril Hrubis
2025-08-05 17:44 ` [LTP] [PATCH v5 2/7] fs: add struct fsxattr fallback definitions Andrea Cervesato
2025-08-06 15:28   ` Cyril Hrubis
2025-08-05 17:44 ` [LTP] [PATCH v5 3/7] fs: add file_setattr/file_getattr " Andrea Cervesato
2025-08-06 15:36   ` Cyril Hrubis
2025-08-07  6:39     ` Andrea Cervesato via ltp
2025-08-05 17:44 ` [LTP] [PATCH v5 4/7] Add file_attr01 test Andrea Cervesato
2025-08-06 15:03   ` Cyril Hrubis
2025-08-05 17:44 ` [LTP] [PATCH v5 5/7] Add file_attr02 test Andrea Cervesato
2025-08-06 14:56   ` Cyril Hrubis
2025-08-05 17:44 ` [LTP] [PATCH v5 6/7] Add file_attr03 test Andrea Cervesato
2025-08-06 14:42   ` Cyril Hrubis
2025-08-05 17:44 ` [LTP] [PATCH v5 7/7] Add file_attr04 test Andrea Cervesato
2025-08-06 14:23   ` Cyril Hrubis
2025-08-06 14:30     ` Cyril Hrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox