[LTP] [PATCH v3 3/6] fs: add file_setattr/file_getattr fallback definitions
Andrea Cervesato
andrea.cervesato@suse.de
Tue Aug 5 09:01:51 CEST 2025
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 9bd139f602b9f174e5314171f8f03338c06f3df4..3ddea62b57270662fe8f24d52d697874ee8768ef 100644
--- a/configure.ac
+++ b/configure.ac
@@ -263,6 +263,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 261f9fd016eaa39e3072d9fb48742616b0c5f571..ac3e09fd6dcc60e3237247bd575b0d8c2796cb07 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
More information about the ltp
mailing list