]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
missing_syscall: add {set,remove}xattrat()
authorMike Yuan <me@yhndnzj.com>
Mon, 20 Jan 2025 18:43:00 +0000 (19:43 +0100)
committerMike Yuan <me@yhndnzj.com>
Sun, 9 Feb 2025 13:51:03 +0000 (14:51 +0100)
meson.build
src/basic/missing_syscall.h
src/basic/missing_syscall_def.h
src/basic/missing_syscalls.py

index 6d86b057ef7e2292a1e01f42feabee71099daafd..d38f6ef20f928eb1970e4247712bd24af05e8106 100644 (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')
index 47ff5a11aac6191961ee5d786aa21ad2ac30c7c8..f4eb4dd57b28506a7e45f0af8e896af09f07e969 100644 (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
index cd22058cdd4113917bebc817acf86f1e628d0f65..48116fc0f7c828ef547cdb5e4a1b202201127046 100644 (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,138 +1266,138 @@ assert_cc(__NR_setns == systemd_NR_setns);
 #  endif
 #endif
 
-#ifndef __IGNORE_statx
+#ifndef __IGNORE_setxattrat
 #  if defined(__aarch64__)
-#    define systemd_NR_statx 291
+#    define systemd_NR_setxattrat 463
 #  elif defined(__alpha__)
-#    define systemd_NR_statx 522
+#    define systemd_NR_setxattrat 573
 #  elif defined(__arc__) || defined(__tilegx__)
-#    define systemd_NR_statx 291
+#    define systemd_NR_setxattrat 463
 #  elif defined(__arm__)
-#    define systemd_NR_statx 397
+#    define systemd_NR_setxattrat 463
 #  elif defined(__i386__)
-#    define systemd_NR_statx 383
+#    define systemd_NR_setxattrat 463
 #  elif defined(__ia64__)
-#    define systemd_NR_statx 1350
+#    define systemd_NR_setxattrat -1
 #  elif defined(__loongarch_lp64)
-#    define systemd_NR_statx 291
+#    define systemd_NR_setxattrat 463
 #  elif defined(__m68k__)
-#    define systemd_NR_statx 379
+#    define systemd_NR_setxattrat 463
 #  elif defined(_MIPS_SIM)
 #    if _MIPS_SIM == _MIPS_SIM_ABI32
-#      define systemd_NR_statx 4366
+#      define systemd_NR_setxattrat 4463
 #    elif _MIPS_SIM == _MIPS_SIM_NABI32
-#      define systemd_NR_statx 6330
+#      define systemd_NR_setxattrat 6463
 #    elif _MIPS_SIM == _MIPS_SIM_ABI64
-#      define systemd_NR_statx 5326
+#      define systemd_NR_setxattrat 5463
 #    else
 #      error "Unknown MIPS ABI"
 #    endif
 #  elif defined(__hppa__)
-#    define systemd_NR_statx 349
+#    define systemd_NR_setxattrat 463
 #  elif defined(__powerpc__)
-#    define systemd_NR_statx 383
+#    define systemd_NR_setxattrat 463
 #  elif defined(__riscv)
 #    if __riscv_xlen == 32
-#      define systemd_NR_statx 291
+#      define systemd_NR_setxattrat 463
 #    elif __riscv_xlen == 64
-#      define systemd_NR_statx 291
+#      define systemd_NR_setxattrat 463
 #    else
 #      error "Unknown RISC-V ABI"
 #    endif
 #  elif defined(__s390__)
-#    define systemd_NR_statx 379
+#    define systemd_NR_setxattrat 463
 #  elif defined(__sparc__)
-#    define systemd_NR_statx 360
+#    define systemd_NR_setxattrat 463
 #  elif defined(__x86_64__)
 #    if defined(__ILP32__)
-#      define systemd_NR_statx (332 | /* __X32_SYSCALL_BIT */ 0x40000000)
+#      define systemd_NR_setxattrat (463 | /* __X32_SYSCALL_BIT */ 0x40000000)
 #    else
-#      define systemd_NR_statx 332
+#      define systemd_NR_setxattrat 463
 #    endif
 #  elif !defined(missing_arch_template)
-#    warning "statx() syscall number is unknown for your architecture"
+#    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_statx && __NR_statx >= 0
-#    if defined systemd_NR_statx
-assert_cc(__NR_statx == systemd_NR_statx);
+#  if defined __NR_setxattrat && __NR_setxattrat >= 0
+#    if defined systemd_NR_setxattrat
+assert_cc(__NR_setxattrat == systemd_NR_setxattrat);
 #    endif
 #  else
-#    if defined __NR_statx
-#      undef __NR_statx
+#    if defined __NR_setxattrat
+#      undef __NR_setxattrat
 #    endif
-#    if defined systemd_NR_statx && systemd_NR_statx >= 0
-#      define __NR_statx systemd_NR_statx
+#    if defined systemd_NR_setxattrat && systemd_NR_setxattrat >= 0
+#      define __NR_setxattrat systemd_NR_setxattrat
 #    endif
 #  endif
 #endif
 
-#ifndef __IGNORE_quotactl_fd
+#ifndef __IGNORE_statx
 #  if defined(__aarch64__)
-#    define systemd_NR_quotactl_fd 443
+#    define systemd_NR_statx 291
 #  elif defined(__alpha__)
-#    define systemd_NR_quotactl_fd 553
+#    define systemd_NR_statx 522
 #  elif defined(__arc__) || defined(__tilegx__)
-#    define systemd_NR_quotactl_fd 443
+#    define systemd_NR_statx 291
 #  elif defined(__arm__)
-#    define systemd_NR_quotactl_fd 443
+#    define systemd_NR_statx 397
 #  elif defined(__i386__)
-#    define systemd_NR_quotactl_fd 443
+#    define systemd_NR_statx 383
 #  elif defined(__ia64__)
-#    define systemd_NR_quotactl_fd 1467
+#    define systemd_NR_statx 1350
 #  elif defined(__loongarch_lp64)
-#    define systemd_NR_quotactl_fd 443
+#    define systemd_NR_statx 291
 #  elif defined(__m68k__)
-#    define systemd_NR_quotactl_fd 443
+#    define systemd_NR_statx 379
 #  elif defined(_MIPS_SIM)
 #    if _MIPS_SIM == _MIPS_SIM_ABI32
-#      define systemd_NR_quotactl_fd 4443
+#      define systemd_NR_statx 4366
 #    elif _MIPS_SIM == _MIPS_SIM_NABI32
-#      define systemd_NR_quotactl_fd 6443
+#      define systemd_NR_statx 6330
 #    elif _MIPS_SIM == _MIPS_SIM_ABI64
-#      define systemd_NR_quotactl_fd 5443
+#      define systemd_NR_statx 5326
 #    else
 #      error "Unknown MIPS ABI"
 #    endif
 #  elif defined(__hppa__)
-#    define systemd_NR_quotactl_fd 443
+#    define systemd_NR_statx 349
 #  elif defined(__powerpc__)
-#    define systemd_NR_quotactl_fd 443
+#    define systemd_NR_statx 383
 #  elif defined(__riscv)
 #    if __riscv_xlen == 32
-#      define systemd_NR_quotactl_fd 443
+#      define systemd_NR_statx 291
 #    elif __riscv_xlen == 64
-#      define systemd_NR_quotactl_fd 443
+#      define systemd_NR_statx 291
 #    else
 #      error "Unknown RISC-V ABI"
 #    endif
 #  elif defined(__s390__)
-#    define systemd_NR_quotactl_fd 443
+#    define systemd_NR_statx 379
 #  elif defined(__sparc__)
-#    define systemd_NR_quotactl_fd 443
+#    define systemd_NR_statx 360
 #  elif defined(__x86_64__)
 #    if defined(__ILP32__)
-#      define systemd_NR_quotactl_fd (443 | /* __X32_SYSCALL_BIT */ 0x40000000)
+#      define systemd_NR_statx (332 | /* __X32_SYSCALL_BIT */ 0x40000000)
 #    else
-#      define systemd_NR_quotactl_fd 443
+#      define systemd_NR_statx 332
 #    endif
 #  elif !defined(missing_arch_template)
-#    warning "quotactl_fd() syscall number is unknown for your architecture"
+#    warning "statx() 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);
+#  if defined __NR_statx && __NR_statx >= 0
+#    if defined systemd_NR_statx
+assert_cc(__NR_statx == systemd_NR_statx);
 #    endif
 #  else
-#    if defined __NR_quotactl_fd
-#      undef __NR_quotactl_fd
+#    if defined __NR_statx
+#      undef __NR_statx
 #    endif
-#    if defined systemd_NR_quotactl_fd && systemd_NR_quotactl_fd >= 0
-#      define __NR_quotactl_fd systemd_NR_quotactl_fd
+#    if defined systemd_NR_statx && systemd_NR_statx >= 0
+#      define __NR_statx systemd_NR_statx
 #    endif
 #  endif
 #endif
index a15fed03585cc861962ad63d9e87bc3a4700f692..d0e9d7dec4b493b01e2c66428350f53ba8ed845f 100644 (file)
@@ -21,8 +21,10 @@ SYSCALLS = [
     'pidfd_send_signal',
     'pkey_mprotect',
     'quotactl_fd',
+    'removexattrat',
     'renameat2',
     'setns',
+    'setxattrat',
     'statx',
 ]