1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-24 14:50:17 +03:00

missing_syscall: add {set,remove}xattrat()

This commit is contained in:
Mike Yuan 2025-01-20 19:43:00 +01:00
parent 0f633e5257
commit a0924d96cb
No known key found for this signature in database
GPG Key ID: 417471C0A40F58B3
4 changed files with 245 additions and 71 deletions

View File

@ -682,6 +682,8 @@ foreach ident : [
['strerrorname_np', '''#include <string.h>'''],
['getrandom', '''#include <sys/random.h>'''],
['quotactl_fd', '''#include <sys/quota.h>'''],
['setxattrat', '''#include <sys/xattr.h>'''], # no known header declares setxattrat
['removexattrat', '''#include <sys/xattr.h>'''], # no known header declares removexattrat
]
have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')

View File

@ -637,13 +637,47 @@ int __clone2(int (*fn)(void *), void *stack_base, size_t stack_size, int flags,
#if !HAVE_QUOTACTL_FD
static inline int missing_quotactl_fd(int fd, int cmd, int id, void *addr) {
#if defined __NR_quotactl_fd
# ifdef __NR_quotactl_fd
return syscall(__NR_quotactl_fd, fd, cmd, id, addr);
#else
# else
errno = ENOSYS;
return -1;
#endif
# endif
}
# define quotactl_fd missing_quotactl_fd
#endif
/* ======================================================================= */
#if !HAVE_SETXATTRAT
struct xattr_args {
_align_(8) uint64_t value;
uint32_t size;
uint32_t flags;
};
static inline int missing_setxattrat(int fd, const char *path, int at_flags, const char *name, const struct xattr_args *args, size_t size) {
# ifdef __NR_setxattrat
return syscall(__NR_setxattrat, fd, path, at_flags, name, args, size);
# else
errno = ENOSYS;
return -1;
# endif
}
# define setxattrat missing_setxattrat
#endif
#if !HAVE_REMOVEXATTRAT
static inline int missing_removexattrat(int fd, const char *path, int at_flags, const char *name) {
# ifdef __NR_removexattrat
return syscall(__NR_removexattrat, fd, path, at_flags, name);
# else
errno = ENOSYS;
return -1;
# endif
}
# define removexattrat missing_removexattrat
#endif

View File

@ -994,6 +994,142 @@ assert_cc(__NR_pkey_mprotect == systemd_NR_pkey_mprotect);
# endif
#endif
#ifndef __IGNORE_quotactl_fd
# if defined(__aarch64__)
# define systemd_NR_quotactl_fd 443
# elif defined(__alpha__)
# define systemd_NR_quotactl_fd 553
# elif defined(__arc__) || defined(__tilegx__)
# define systemd_NR_quotactl_fd 443
# elif defined(__arm__)
# define systemd_NR_quotactl_fd 443
# elif defined(__i386__)
# define systemd_NR_quotactl_fd 443
# elif defined(__ia64__)
# define systemd_NR_quotactl_fd 1467
# elif defined(__loongarch_lp64)
# define systemd_NR_quotactl_fd 443
# elif defined(__m68k__)
# define systemd_NR_quotactl_fd 443
# elif defined(_MIPS_SIM)
# if _MIPS_SIM == _MIPS_SIM_ABI32
# define systemd_NR_quotactl_fd 4443
# elif _MIPS_SIM == _MIPS_SIM_NABI32
# define systemd_NR_quotactl_fd 6443
# elif _MIPS_SIM == _MIPS_SIM_ABI64
# define systemd_NR_quotactl_fd 5443
# else
# error "Unknown MIPS ABI"
# endif
# elif defined(__hppa__)
# define systemd_NR_quotactl_fd 443
# elif defined(__powerpc__)
# define systemd_NR_quotactl_fd 443
# elif defined(__riscv)
# if __riscv_xlen == 32
# define systemd_NR_quotactl_fd 443
# elif __riscv_xlen == 64
# define systemd_NR_quotactl_fd 443
# else
# error "Unknown RISC-V ABI"
# endif
# elif defined(__s390__)
# define systemd_NR_quotactl_fd 443
# elif defined(__sparc__)
# define systemd_NR_quotactl_fd 443
# elif defined(__x86_64__)
# if defined(__ILP32__)
# define systemd_NR_quotactl_fd (443 | /* __X32_SYSCALL_BIT */ 0x40000000)
# else
# define systemd_NR_quotactl_fd 443
# endif
# elif !defined(missing_arch_template)
# warning "quotactl_fd() syscall number is unknown for your architecture"
# endif
/* may be an (invalid) negative number due to libseccomp, see PR 13319 */
# if defined __NR_quotactl_fd && __NR_quotactl_fd >= 0
# if defined systemd_NR_quotactl_fd
assert_cc(__NR_quotactl_fd == systemd_NR_quotactl_fd);
# endif
# else
# if defined __NR_quotactl_fd
# undef __NR_quotactl_fd
# endif
# if defined systemd_NR_quotactl_fd && systemd_NR_quotactl_fd >= 0
# define __NR_quotactl_fd systemd_NR_quotactl_fd
# endif
# endif
#endif
#ifndef __IGNORE_removexattrat
# if defined(__aarch64__)
# define systemd_NR_removexattrat 466
# elif defined(__alpha__)
# define systemd_NR_removexattrat 576
# elif defined(__arc__) || defined(__tilegx__)
# define systemd_NR_removexattrat 466
# elif defined(__arm__)
# define systemd_NR_removexattrat 466
# elif defined(__i386__)
# define systemd_NR_removexattrat 466
# elif defined(__ia64__)
# define systemd_NR_removexattrat -1
# elif defined(__loongarch_lp64)
# define systemd_NR_removexattrat 466
# elif defined(__m68k__)
# define systemd_NR_removexattrat 466
# elif defined(_MIPS_SIM)
# if _MIPS_SIM == _MIPS_SIM_ABI32
# define systemd_NR_removexattrat 4466
# elif _MIPS_SIM == _MIPS_SIM_NABI32
# define systemd_NR_removexattrat 6466
# elif _MIPS_SIM == _MIPS_SIM_ABI64
# define systemd_NR_removexattrat 5466
# else
# error "Unknown MIPS ABI"
# endif
# elif defined(__hppa__)
# define systemd_NR_removexattrat 466
# elif defined(__powerpc__)
# define systemd_NR_removexattrat 466
# elif defined(__riscv)
# if __riscv_xlen == 32
# define systemd_NR_removexattrat 466
# elif __riscv_xlen == 64
# define systemd_NR_removexattrat 466
# else
# error "Unknown RISC-V ABI"
# endif
# elif defined(__s390__)
# define systemd_NR_removexattrat 466
# elif defined(__sparc__)
# define systemd_NR_removexattrat 466
# elif defined(__x86_64__)
# if defined(__ILP32__)
# define systemd_NR_removexattrat (466 | /* __X32_SYSCALL_BIT */ 0x40000000)
# else
# define systemd_NR_removexattrat 466
# endif
# elif !defined(missing_arch_template)
# warning "removexattrat() syscall number is unknown for your architecture"
# endif
/* may be an (invalid) negative number due to libseccomp, see PR 13319 */
# if defined __NR_removexattrat && __NR_removexattrat >= 0
# if defined systemd_NR_removexattrat
assert_cc(__NR_removexattrat == systemd_NR_removexattrat);
# endif
# else
# if defined __NR_removexattrat
# undef __NR_removexattrat
# endif
# if defined systemd_NR_removexattrat && systemd_NR_removexattrat >= 0
# define __NR_removexattrat systemd_NR_removexattrat
# endif
# endif
#endif
#ifndef __IGNORE_renameat2
# if defined(__aarch64__)
# define systemd_NR_renameat2 276
@ -1130,6 +1266,74 @@ assert_cc(__NR_setns == systemd_NR_setns);
# endif
#endif
#ifndef __IGNORE_setxattrat
# if defined(__aarch64__)
# define systemd_NR_setxattrat 463
# elif defined(__alpha__)
# define systemd_NR_setxattrat 573
# elif defined(__arc__) || defined(__tilegx__)
# define systemd_NR_setxattrat 463
# elif defined(__arm__)
# define systemd_NR_setxattrat 463
# elif defined(__i386__)
# define systemd_NR_setxattrat 463
# elif defined(__ia64__)
# define systemd_NR_setxattrat -1
# elif defined(__loongarch_lp64)
# define systemd_NR_setxattrat 463
# elif defined(__m68k__)
# define systemd_NR_setxattrat 463
# elif defined(_MIPS_SIM)
# if _MIPS_SIM == _MIPS_SIM_ABI32
# define systemd_NR_setxattrat 4463
# elif _MIPS_SIM == _MIPS_SIM_NABI32
# define systemd_NR_setxattrat 6463
# elif _MIPS_SIM == _MIPS_SIM_ABI64
# define systemd_NR_setxattrat 5463
# else
# error "Unknown MIPS ABI"
# endif
# elif defined(__hppa__)
# define systemd_NR_setxattrat 463
# elif defined(__powerpc__)
# define systemd_NR_setxattrat 463
# elif defined(__riscv)
# if __riscv_xlen == 32
# define systemd_NR_setxattrat 463
# elif __riscv_xlen == 64
# define systemd_NR_setxattrat 463
# else
# error "Unknown RISC-V ABI"
# endif
# elif defined(__s390__)
# define systemd_NR_setxattrat 463
# elif defined(__sparc__)
# define systemd_NR_setxattrat 463
# elif defined(__x86_64__)
# if defined(__ILP32__)
# define systemd_NR_setxattrat (463 | /* __X32_SYSCALL_BIT */ 0x40000000)
# else
# define systemd_NR_setxattrat 463
# endif
# elif !defined(missing_arch_template)
# warning "setxattrat() syscall number is unknown for your architecture"
# endif
/* may be an (invalid) negative number due to libseccomp, see PR 13319 */
# if defined __NR_setxattrat && __NR_setxattrat >= 0
# if defined systemd_NR_setxattrat
assert_cc(__NR_setxattrat == systemd_NR_setxattrat);
# endif
# else
# if defined __NR_setxattrat
# undef __NR_setxattrat
# endif
# if defined systemd_NR_setxattrat && systemd_NR_setxattrat >= 0
# define __NR_setxattrat systemd_NR_setxattrat
# endif
# endif
#endif
#ifndef __IGNORE_statx
# if defined(__aarch64__)
# define systemd_NR_statx 291
@ -1197,71 +1401,3 @@ assert_cc(__NR_statx == systemd_NR_statx);
# endif
# endif
#endif
#ifndef __IGNORE_quotactl_fd
# if defined(__aarch64__)
# define systemd_NR_quotactl_fd 443
# elif defined(__alpha__)
# define systemd_NR_quotactl_fd 553
# elif defined(__arc__) || defined(__tilegx__)
# define systemd_NR_quotactl_fd 443
# elif defined(__arm__)
# define systemd_NR_quotactl_fd 443
# elif defined(__i386__)
# define systemd_NR_quotactl_fd 443
# elif defined(__ia64__)
# define systemd_NR_quotactl_fd 1467
# elif defined(__loongarch_lp64)
# define systemd_NR_quotactl_fd 443
# elif defined(__m68k__)
# define systemd_NR_quotactl_fd 443
# elif defined(_MIPS_SIM)
# if _MIPS_SIM == _MIPS_SIM_ABI32
# define systemd_NR_quotactl_fd 4443
# elif _MIPS_SIM == _MIPS_SIM_NABI32
# define systemd_NR_quotactl_fd 6443
# elif _MIPS_SIM == _MIPS_SIM_ABI64
# define systemd_NR_quotactl_fd 5443
# else
# error "Unknown MIPS ABI"
# endif
# elif defined(__hppa__)
# define systemd_NR_quotactl_fd 443
# elif defined(__powerpc__)
# define systemd_NR_quotactl_fd 443
# elif defined(__riscv)
# if __riscv_xlen == 32
# define systemd_NR_quotactl_fd 443
# elif __riscv_xlen == 64
# define systemd_NR_quotactl_fd 443
# else
# error "Unknown RISC-V ABI"
# endif
# elif defined(__s390__)
# define systemd_NR_quotactl_fd 443
# elif defined(__sparc__)
# define systemd_NR_quotactl_fd 443
# elif defined(__x86_64__)
# if defined(__ILP32__)
# define systemd_NR_quotactl_fd (443 | /* __X32_SYSCALL_BIT */ 0x40000000)
# else
# define systemd_NR_quotactl_fd 443
# endif
# elif !defined(missing_arch_template)
# warning "quotactl_fd() syscall number is unknown for your architecture"
# endif
/* may be an (invalid) negative number due to libseccomp, see PR 13319 */
# if defined __NR_quotactl_fd && __NR_quotactl_fd >= 0
# if defined systemd_NR_quotactl_fd
assert_cc(__NR_quotactl_fd == systemd_NR_quotactl_fd);
# endif
# else
# if defined __NR_quotactl_fd
# undef __NR_quotactl_fd
# endif
# if defined systemd_NR_quotactl_fd && systemd_NR_quotactl_fd >= 0
# define __NR_quotactl_fd systemd_NR_quotactl_fd
# endif
# endif
#endif

View File

@ -21,8 +21,10 @@ SYSCALLS = [
'pidfd_send_signal',
'pkey_mprotect',
'quotactl_fd',
'removexattrat',
'renameat2',
'setns',
'setxattrat',
'statx',
]