@@ -27,6 +27,11 @@ Major new features:
<sys/mount.h>. They retrieve information about a mount and list the
mounts of a mount namespace, using the unique 64-bit mount IDs.
+* On Linux, the setxattrat, getxattrat, listxattrat, and removexattrat
+ functions have been added to <sys/xattr.h>. They are variants of the
+ extended attribute functions which take a directory file descriptor
+ and AT_* flags, like openat.
+
Deprecated and removed features, and other changes affecting compatibility:
* The posix_spawn_file_actions_addchdir and posix_spawn_file_actions_addfchdir
new file mode 100644
@@ -0,0 +1,21 @@
+/* System-specific extensions of <sys/xattr.h>, generic version.
+ Copyright (C) 2026 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_XATTR_H
+# error "Never include <bits/xattr_ext.h> directly; use <sys/xattr.h> instead."
+#endif
@@ -46,6 +46,7 @@ headers := \
bits/types/struct_iovec.h \
bits/uio-ext.h \
bits/uio_lim.h \
+ bits/xattr_ext.h \
err.h \
error.h \
fstab.h \
@@ -104,6 +104,9 @@ extern int lremovexattr (const char *__path, const char *__name) __THROW;
success, -1 for errors. */
extern int fremovexattr (int __fd, const char *__name) __THROW;
+/* System-specific extensions. */
+#include <bits/xattr_ext.h>
+
__END_DECLS
#endif /* sys/xattr.h */
@@ -247,6 +247,7 @@ tests += \
tst-timerfd \
tst-ttyname-direct \
tst-ttyname-namespace \
+ tst-xattrat \
# tests
# process_madvise requires CAP_SYS_ADMIN.
@@ -345,9 +345,13 @@ libc {
}
GLIBC_2.45 {
fchroot;
+ getxattrat;
listmount;
+ listxattrat;
membarrier;
open_tree_attr;
+ removexattrat;
+ setxattrat;
statmount;
}
GLIBC_PRIVATE {
@@ -2776,9 +2776,13 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 getxattrat F
GLIBC_2.45 listmount F
+GLIBC_2.45 listxattrat F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 removexattrat F
+GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -3123,11 +3123,15 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 getxattrat F
GLIBC_2.45 listmount F
+GLIBC_2.45 listxattrat F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 removexattrat F
+GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
@@ -2537,9 +2537,13 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 getxattrat F
GLIBC_2.45 listmount F
+GLIBC_2.45 listxattrat F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 removexattrat F
+GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -2829,11 +2829,15 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 getxattrat F
GLIBC_2.45 listmount F
+GLIBC_2.45 listxattrat F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 removexattrat F
+GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
@@ -2826,11 +2826,15 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 getxattrat F
GLIBC_2.45 listmount F
+GLIBC_2.45 listxattrat F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 removexattrat F
+GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
new file mode 100644
@@ -0,0 +1,63 @@
+/* System-specific extensions of <sys/xattr.h>, Linux version.
+ Copyright (C) 2026 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_XATTR_H
+# error "Never include <bits/xattr_ext.h> directly; use <sys/xattr.h> instead."
+#endif
+
+#ifndef __USE_KERNEL_XATTR_DEFS
+struct xattr_args
+{
+ __uint64_t value __attribute__ ((__aligned__ (8)));
+ /* Address of the attribute value buffer. */
+ __uint32_t size; /* Size of the value (or of the buffer). */
+ __uint32_t flags; /* XATTR_CREATE or XATTR_REPLACE for setxattrat,
+ zero for getxattrat. */
+};
+#endif
+
+/* Kernel headers older than Linux 6.13 do not define it. */
+struct xattr_args;
+
+/* The following functions operate on the file pointed to by PATH, which is
+ relative to the directory DFD. AT_FLAGS can contain AT_SYMLINK_NOFOLLOW
+ and AT_EMPTY_PATH, and it can be empty or a null pointer to operate on DFD
+ itself. */
+
+/* Set the attribute NAME to the value described by ARGS, of size SIZE.
+ Return 0 on success, -1 for errors. */
+extern int setxattrat (int __dfd, const char *__path, unsigned int __at_flags,
+ const char *__name, const struct xattr_args *__args,
+ size_t __size) __THROW;
+
+/* Get the attribute NAME into the buffer described by ARGS, of size SIZE.
+ Return the size of the attribute value on success, -1 for errors. */
+extern ssize_t getxattrat (int __dfd, const char *__path,
+ unsigned int __at_flags, const char *__name,
+ struct xattr_args *__args, size_t __size) __THROW;
+
+/* Store in LIST, of size SIZE, the list of attribute names. Return the
+ size of the list on success, -1 for errors. */
+extern ssize_t listxattrat (int __dfd, const char *__path,
+ unsigned int __at_flags, char *__list,
+ size_t __size) __THROW;
+
+/* Remove the attribute NAME. Return 0 on success, -1 for errors. */
+extern int removexattrat (int __dfd, const char *__path,
+ unsigned int __at_flags, const char *__name)
+ __THROW;
@@ -2813,9 +2813,13 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 getxattrat F
GLIBC_2.45 listmount F
+GLIBC_2.45 listxattrat F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 removexattrat F
+GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -2850,11 +2850,15 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 getxattrat F
GLIBC_2.45 listmount F
+GLIBC_2.45 listxattrat F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 removexattrat F
+GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
@@ -3033,11 +3033,15 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 getxattrat F
GLIBC_2.45 listmount F
+GLIBC_2.45 listxattrat F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 removexattrat F
+GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
@@ -2288,9 +2288,13 @@ GLIBC_2.44 write F
GLIBC_2.44 writev F
GLIBC_2.44 wscanf F
GLIBC_2.45 fchroot F
+GLIBC_2.45 getxattrat F
GLIBC_2.45 listmount F
+GLIBC_2.45 listxattrat F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 removexattrat F
+GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -2297,9 +2297,13 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 getxattrat F
GLIBC_2.45 listmount F
+GLIBC_2.45 listxattrat F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 removexattrat F
+GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -2809,11 +2809,15 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 getxattrat F
GLIBC_2.45 listmount F
+GLIBC_2.45 listxattrat F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 removexattrat F
+GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
@@ -2976,11 +2976,15 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 getxattrat F
GLIBC_2.45 listmount F
+GLIBC_2.45 listxattrat F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 removexattrat F
+GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
@@ -2862,9 +2862,13 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 getxattrat F
GLIBC_2.45 listmount F
+GLIBC_2.45 listxattrat F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 removexattrat F
+GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -2859,9 +2859,13 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 getxattrat F
GLIBC_2.45 listmount F
+GLIBC_2.45 listxattrat F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 removexattrat F
+GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -2939,11 +2939,15 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 getxattrat F
GLIBC_2.45 listmount F
+GLIBC_2.45 listxattrat F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 removexattrat F
+GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
@@ -2937,11 +2937,15 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 getxattrat F
GLIBC_2.45 listmount F
+GLIBC_2.45 listxattrat F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 removexattrat F
+GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
@@ -2945,11 +2945,15 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 getxattrat F
GLIBC_2.45 listmount F
+GLIBC_2.45 listxattrat F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 removexattrat F
+GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
@@ -2847,11 +2847,15 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 getxattrat F
GLIBC_2.45 listmount F
+GLIBC_2.45 listxattrat F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 removexattrat F
+GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
@@ -2287,9 +2287,13 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 getxattrat F
GLIBC_2.45 listmount F
+GLIBC_2.45 listxattrat F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 removexattrat F
+GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -3166,11 +3166,15 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 getxattrat F
GLIBC_2.45 listmount F
+GLIBC_2.45 listxattrat F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 removexattrat F
+GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
@@ -3211,11 +3211,15 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 getxattrat F
GLIBC_2.45 listmount F
+GLIBC_2.45 listxattrat F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 removexattrat F
+GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
@@ -2920,11 +2920,15 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 getxattrat F
GLIBC_2.45 listmount F
+GLIBC_2.45 listxattrat F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 removexattrat F
+GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
@@ -2996,9 +2996,13 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 getxattrat F
GLIBC_2.45 listmount F
+GLIBC_2.45 listxattrat F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 removexattrat F
+GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -2540,9 +2540,13 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 getxattrat F
GLIBC_2.45 listmount F
+GLIBC_2.45 listxattrat F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 removexattrat F
+GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -2740,9 +2740,13 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 getxattrat F
GLIBC_2.45 listmount F
+GLIBC_2.45 listxattrat F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 removexattrat F
+GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -2957,11 +2957,15 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 getxattrat F
GLIBC_2.45 listmount F
+GLIBC_2.45 listxattrat F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 removexattrat F
+GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
@@ -2856,11 +2856,15 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 getxattrat F
GLIBC_2.45 listmount F
+GLIBC_2.45 listxattrat F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 removexattrat F
+GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
@@ -2853,11 +2853,15 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 getxattrat F
GLIBC_2.45 listmount F
+GLIBC_2.45 listxattrat F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 removexattrat F
+GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
@@ -3187,11 +3187,15 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 getxattrat F
GLIBC_2.45 listmount F
+GLIBC_2.45 listxattrat F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 removexattrat F
+GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
@@ -2823,11 +2823,15 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 getxattrat F
GLIBC_2.45 listmount F
+GLIBC_2.45 listxattrat F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 removexattrat F
+GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
@@ -98,6 +98,10 @@ flistxattr - flistxattr i:isU flistxattr
removexattr - removexattr i:ss removexattr
lremovexattr - lremovexattr i:ss lremovexattr
fremovexattr - fremovexattr i:is fremovexattr
+getxattrat EXTRA getxattrat i:iSUspU getxattrat
+listxattrat EXTRA listxattrat i:iSUBU listxattrat
+removexattrat EXTRA removexattrat i:iSUs removexattrat
+setxattrat EXTRA setxattrat i:iSUspU setxattrat
timerfd_create EXTRA timerfd_create i:ii timerfd_create
new file mode 100644
@@ -0,0 +1,154 @@
+/* Basic tests for Linux setxattrat, getxattrat, listxattrat, and
+ removexattrat.
+ Copyright (C) 2026 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/xattr.h>
+#include <support/check.h>
+#include <support/support.h>
+#include <support/temp_file.h>
+#include <support/xunistd.h>
+
+#define FILENAME "file"
+#define NAME "user.glibc-test"
+
+_Static_assert (sizeof (struct xattr_args) == 16,
+ "sizeof (struct xattr_args) != 16");
+
+static char *temp_dir;
+
+static void
+do_prepare (int argc, char *argv[])
+{
+ temp_dir = support_create_temp_directory ("tst-xattrat.");
+ char *path = xasprintf ("%s/%s", temp_dir, FILENAME);
+ add_temp_file (path);
+ xclose (xopen (path, O_WRONLY | O_CREAT | O_EXCL, 0600));
+ free (path);
+}
+#define PREPARE do_prepare
+
+static ssize_t
+get_value (int dfd, const char *path, unsigned int at_flags, char *buf,
+ size_t size)
+{
+ struct xattr_args args =
+ {
+ .value = (uintptr_t) buf,
+ .size = size,
+ };
+ return getxattrat (dfd, path, at_flags, NAME, &args, sizeof (args));
+}
+
+static int
+do_test (void)
+{
+ int dfd = xopen (temp_dir, O_RDONLY | O_DIRECTORY, 0);
+
+ static const char value1[] = "value1";
+ struct xattr_args args =
+ {
+ .value = (uintptr_t) value1,
+ .size = sizeof (value1),
+ .flags = XATTR_CREATE,
+ };
+ if (setxattrat (dfd, FILENAME, 0, NAME, &args, sizeof (args)) != 0)
+ {
+ if (errno == ENOSYS)
+ FAIL_UNSUPPORTED ("setxattrat is not supported by the kernel");
+ if (errno == EOPNOTSUPP)
+ FAIL_UNSUPPORTED ("user extended attributes are not supported");
+ FAIL_EXIT1 ("setxattrat: %m");
+ }
+
+ /* XATTR_CREATE fails if the attribute exists. */
+ TEST_COMPARE (setxattrat (dfd, FILENAME, 0, NAME, &args, sizeof (args)),
+ -1);
+ TEST_COMPARE (errno, EEXIST);
+
+ char buf[64];
+ TEST_COMPARE (get_value (dfd, FILENAME, 0, buf, sizeof (buf)),
+ sizeof (value1));
+ TEST_COMPARE_STRING (buf, value1);
+
+ /* Replace the value, through a descriptor for the file itself. */
+ int fd = openat (dfd, FILENAME, O_RDONLY);
+ TEST_VERIFY_EXIT (fd != -1);
+ static const char value2[] = "value2-replaced";
+ args.value = (uintptr_t) value2;
+ args.size = sizeof (value2);
+ args.flags = XATTR_REPLACE;
+ TEST_COMPARE (setxattrat (fd, "", AT_EMPTY_PATH, NAME, &args,
+ sizeof (args)), 0);
+ TEST_COMPARE (get_value (fd, NULL, AT_EMPTY_PATH, buf, sizeof (buf)),
+ sizeof (value2));
+ TEST_COMPARE_STRING (buf, value2);
+
+ /* The buffer is too small. */
+ TEST_COMPARE (get_value (dfd, FILENAME, 0, buf, 1), -1);
+ TEST_COMPARE (errno, ERANGE);
+
+ /* getxattrat does not accept flags in struct xattr_args. */
+ args.value = (uintptr_t) buf;
+ args.size = sizeof (buf);
+ args.flags = XATTR_CREATE;
+ TEST_COMPARE (getxattrat (dfd, FILENAME, 0, NAME, &args, sizeof (args)),
+ -1);
+ TEST_COMPARE (errno, EINVAL);
+
+ /* The structure size must cover the first version. */
+ args.flags = 0;
+ TEST_COMPARE (getxattrat (dfd, FILENAME, 0, NAME, &args,
+ sizeof (args) - 1), -1);
+ TEST_COMPARE (errno, EINVAL);
+
+ {
+ /* With a zero size, listxattrat returns the size of the list. */
+ ssize_t size = listxattrat (dfd, FILENAME, 0, NULL, 0);
+ TEST_VERIFY_EXIT (size > 0);
+ char *list = xmalloc (size);
+ ssize_t r = listxattrat (dfd, FILENAME, 0, list, size);
+ TEST_COMPARE (r, size);
+ bool found = false;
+ for (char *p = list; p < list + r; p += strlen (p) + 1)
+ found |= strcmp (p, NAME) == 0;
+ TEST_VERIFY (found);
+ free (list);
+ }
+
+ TEST_COMPARE (removexattrat (dfd, FILENAME, 0, NAME), 0);
+ TEST_COMPARE (get_value (dfd, FILENAME, 0, buf, sizeof (buf)), -1);
+ TEST_COMPARE (errno, ENODATA);
+ TEST_COMPARE (removexattrat (fd, NULL, AT_EMPTY_PATH, NAME), -1);
+ TEST_COMPARE (errno, ENODATA);
+
+ /* Only AT_SYMLINK_NOFOLLOW and AT_EMPTY_PATH are accepted. */
+ TEST_COMPARE (removexattrat (dfd, FILENAME, AT_REMOVEDIR, NAME), -1);
+ TEST_COMPARE (errno, EINVAL);
+
+ xclose (fd);
+ xclose (dfd);
+ return 0;
+}
+
+#include <support/test-driver.c>
@@ -2772,11 +2772,15 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 getxattrat F
GLIBC_2.45 listmount F
+GLIBC_2.45 listxattrat F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 removexattrat F
+GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
@@ -2791,9 +2791,13 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 getxattrat F
GLIBC_2.45 listmount F
+GLIBC_2.45 listxattrat F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 removexattrat F
+GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F