From: DaanDeMeyer Date: Fri, 4 Jul 2025 18:18:39 +0000 (+0200) Subject: basic: Add open_tree_attr() syscall wrapper X-Git-Tag: v258-rc1~141^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2d9759ae6afc25a8cb36154bf5a97f5dcd23ae65;p=thirdparty%2Fsystemd.git basic: Add open_tree_attr() syscall wrapper --- diff --git a/meson.build b/meson.build index 55874ee6c6a..127daa419b7 100644 --- a/meson.build +++ b/meson.build @@ -607,6 +607,7 @@ foreach ident : [ ['pivot_root', '''#include '''], # no known header declares pivot_root ['setxattrat', '''#include '''], # no known header declares setxattrat ['removexattrat', '''#include '''], # no known header declares removexattrat + ['open_tree_attr', '''#include '''], # no known header declares open_tree_attr ] have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE') diff --git a/src/basic/include/sys/mount.h b/src/basic/include/sys/mount.h index 3f42a61233c..3c9cd8ef5bd 100644 --- a/src/basic/include/sys/mount.h +++ b/src/basic/include/sys/mount.h @@ -120,3 +120,13 @@ static inline int missing_mount_setattr(int dfd, const char *path, unsigned flag } # define mount_setattr missing_mount_setattr #endif + +#if HAVE_OPEN_TREE_ATTR +extern int open_tree_attr(int __dfd, const char *__filename, unsigned int __flags, struct mount_attr *__uattr, size_t __usize) __THROW; +#else +static inline int missing_open_tree_attr(int dfd, const char *filename, unsigned int flags, struct mount_attr *attr, size_t size) { + return syscall(__NR_open_tree_attr, dfd, filename, flags, attr, size); +} + +# define open_tree_attr missing_open_tree_attr +#endif diff --git a/src/basic/missing_syscall_def.h b/src/basic/missing_syscall_def.h index 4db051a0b09..a34cb36f14d 100644 --- a/src/basic/missing_syscall_def.h +++ b/src/basic/missing_syscall_def.h @@ -517,3 +517,71 @@ _Static_assert(__NR_setxattrat == systemd_NR_setxattrat, ""); # endif # endif #endif + +#ifndef __IGNORE_open_tree_attr +# if defined(__aarch64__) +# define systemd_NR_open_tree_attr 467 +# elif defined(__alpha__) +# define systemd_NR_open_tree_attr 577 +# elif defined(__arc__) || defined(__tilegx__) +# define systemd_NR_open_tree_attr 467 +# elif defined(__arm__) +# define systemd_NR_open_tree_attr 467 +# elif defined(__i386__) +# define systemd_NR_open_tree_attr 467 +# elif defined(__ia64__) +# define systemd_NR_open_tree_attr -1 +# elif defined(__loongarch_lp64) +# define systemd_NR_open_tree_attr 467 +# elif defined(__m68k__) +# define systemd_NR_open_tree_attr 467 +# elif defined(_MIPS_SIM) +# if _MIPS_SIM == _MIPS_SIM_ABI32 +# define systemd_NR_open_tree_attr 4467 +# elif _MIPS_SIM == _MIPS_SIM_NABI32 +# define systemd_NR_open_tree_attr 6467 +# elif _MIPS_SIM == _MIPS_SIM_ABI64 +# define systemd_NR_open_tree_attr 5467 +# else +# error "Unknown MIPS ABI" +# endif +# elif defined(__hppa__) +# define systemd_NR_open_tree_attr 467 +# elif defined(__powerpc__) +# define systemd_NR_open_tree_attr 467 +# elif defined(__riscv) +# if __riscv_xlen == 32 +# define systemd_NR_open_tree_attr 467 +# elif __riscv_xlen == 64 +# define systemd_NR_open_tree_attr 467 +# else +# error "Unknown RISC-V ABI" +# endif +# elif defined(__s390__) +# define systemd_NR_open_tree_attr 467 +# elif defined(__sparc__) +# define systemd_NR_open_tree_attr 467 +# elif defined(__x86_64__) +# if defined(__ILP32__) +# define systemd_NR_open_tree_attr (467 | /* __X32_SYSCALL_BIT */ 0x40000000) +# else +# define systemd_NR_open_tree_attr 467 +# endif +# elif !defined(missing_arch_template) +# warning "open_tree_attr() syscall number is unknown for your architecture" +# endif + +/* may be an (invalid) negative number due to libseccomp, see PR 13319 */ +# if defined __NR_open_tree_attr && __NR_open_tree_attr >= 0 +# if defined systemd_NR_open_tree_attr +_Static_assert(__NR_open_tree_attr == systemd_NR_open_tree_attr, ""); +# endif +# else +# if defined __NR_open_tree_attr +# undef __NR_open_tree_attr +# endif +# if defined systemd_NR_open_tree_attr && systemd_NR_open_tree_attr >= 0 +# define __NR_open_tree_attr systemd_NR_open_tree_attr +# endif +# endif +#endif diff --git a/src/basic/missing_syscalls.py b/src/basic/missing_syscalls.py index 646ab4e34e3..dd26b76b4c9 100644 --- a/src/basic/missing_syscalls.py +++ b/src/basic/missing_syscalls.py @@ -9,6 +9,7 @@ SYSCALLS = [ 'close_range', # defined in glibc header since glibc-2.33 'fchmodat2', # defined in glibc header since glibc-2.39 'mount_setattr', # defined in glibc header since glibc-2.34 + 'open_tree_attr', 'openat2', # defined in glibc header since glibc-2.32 'quotactl_fd', # defined in glibc header since glibc-2.35 'removexattrat',