[LTP] [PATCH v2 01/10] lapi: add struct xattr_args fallback

Andrea Cervesato andrea.cervesato@suse.de
Tue Oct 7 08:46:53 CEST 2025


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

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

diff --git a/configure.ac b/configure.ac
index 0480f46ca..c32d9992c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -83,6 +83,7 @@ AC_CHECK_HEADERS_ONCE([ \
     linux/tty.h \
     linux/types.h \
     linux/userfaultfd.h \
+    linux/xattr.h \
     netinet/sctp.h \
     pthread.h \
     sys/epoll.h \
@@ -266,6 +267,7 @@ AC_CHECK_TYPES([struct mnt_id_req],,,[#include <sys/mount.h>])
 AC_CHECK_TYPES([struct statmount],,,[#include <sys/mount.h>])
 AC_CHECK_MEMBERS([struct statmount.mnt_ns_id],,,[#include <unistd.h>
 #include <linux/mount.h>])
+AC_CHECK_TYPES([struct xattr_args],,,[#include <linux/xattr.h>])
 
 AC_CHECK_TYPES([struct pidfd_info],,,[#include <sys/pidfd.h>])
 AC_CHECK_TYPES([struct file_attr],,,[#include <linux/fs.h>])
diff --git a/include/lapi/xattr.h b/include/lapi/xattr.h
new file mode 100644
index 000000000..8bd2d45e4
--- /dev/null
+++ b/include/lapi/xattr.h
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (c) 2025 Linux Test Project
+ */
+
+#ifndef LAPI_XATTR_H__
+#define LAPI_XATTR_H__
+
+#include <stdint.h>
+#include "config.h"
+
+#ifdef HAVE_LINUX_XATTR_H
+# include <linux/xattr.h>
+#endif
+
+#ifndef XATTR_CREATE
+# define XATTR_CREATE	0x1	/* set value, fail if attr already exists */
+#endif
+
+#ifndef XATTR_REPLACE
+# define XATTR_REPLACE	0x2	/* set value, fail if attr does not exist */
+#endif
+
+#ifndef HAVE_STRUCT_XATTR_ARGS
+struct xattr_args {
+	uint64_t value;
+	uint32_t size;
+	uint32_t flags;
+};
+#endif
+
+#endif /* LAPI_XATTR_H__ */

-- 
2.51.0



More information about the ltp mailing list