diff --git a/meson.build b/meson.build index b97fe3aa41..f5362ece8a 100644 --- a/meson.build +++ b/meson.build @@ -580,7 +580,6 @@ foreach ident : [ ['fsconfig', '''#include '''], # since glibc-2.36 ['fsmount', '''#include '''], # since glibc-2.36 ['fsopen', '''#include '''], # since glibc-2.36 - ['fspick', '''#include '''], # since glibc-2.36 ['mount_setattr', '''#include '''], # since glibc-2.36 ['move_mount', '''#include '''], # since glibc-2.36 ['open_tree', '''#include '''], # since glibc-2.36 @@ -591,15 +590,17 @@ foreach ident : [ ['ioprio_get', '''#include '''], # no known header declares ioprio_get ['ioprio_set', '''#include '''], # no known header declares ioprio_set ['rt_tgsigqueueinfo', '''#include '''], # no known header declares rt_tgsigqueueinfo + ['open_tree_attr', '''#include '''], # no known header declares open_tree_attr ['quotactl_fd', '''#include '''], # no known header declares quotactl_fd ['fchmodat2', '''#include '''], # no known header declares fchmodat2 ['bpf', '''#include '''], # no known header declares bpf ['kcmp', '''#include '''], # no known header declares kcmp ['keyctl', '''#include '''], # no known header declares keyctl - ['pivot_root', '''#include '''], # no known header declares pivot_root + ['add_key', '''#include '''], # no known header declares add_key + ['request_key', '''#include '''], # no known header declares request_key ['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 + ['pivot_root', '''#include '''], # no known header declares pivot_root ] have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE') @@ -2057,6 +2058,7 @@ includes = [libsystemd_includes, include_directories('src/shared')] subdir('po') subdir('catalog') subdir('src/include') +subdir('src/libc') subdir('src/fundamental') subdir('src/basic') subdir('src/libsystemd') @@ -2072,7 +2074,8 @@ libsystemd = shared_library( # Make sure our library is never deleted from memory, so that our open logging fds don't leak on dlopen/dlclose cycles. '-z', 'nodelete', '-Wl,--version-script=' + libsystemd_sym_path], - link_with : [libbasic_static], + link_with : [libc_wrapper_static, + libbasic_static], link_whole : [libsystemd_static], dependencies : [librt, threads, @@ -2085,6 +2088,7 @@ libsystemd = shared_library( if static_libsystemd != 'false' install_libsystemd_static = static_library( 'systemd', + libc_wrapper_sources, libsystemd_sources, basic_sources, fundamental_sources, @@ -2130,6 +2134,7 @@ libudev = shared_library( if static_libudev != 'false' install_libudev_static = static_library( 'udev', + libc_wrapper_sources, basic_sources, fundamental_sources, shared_sources, @@ -2234,6 +2239,7 @@ nss_template = { # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned 'link_args' : ['-z', 'nodelete'], 'link_with' : [ + libc_wrapper_static, libsystemd_static, libshared_static, libbasic_static, diff --git a/src/basic/fd-util.c b/src/basic/fd-util.c index 9cfaf8a849..a6118b4247 100644 --- a/src/basic/fd-util.c +++ b/src/basic/fd-util.c @@ -2,8 +2,8 @@ #include #include -#include #include +#include #include #include #include @@ -16,7 +16,6 @@ #include "format-util.h" #include "fs-util.h" #include "log.h" -#include "missing_syscall.h" #include "mountpoint-util.h" #include "parse-util.h" #include "path-util.h" diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c index 3a3b09776a..9fb6f5d0b8 100644 --- a/src/basic/fs-util.c +++ b/src/basic/fs-util.c @@ -16,7 +16,6 @@ #include "label.h" #include "lock-util.h" #include "log.h" -#include "missing_syscall.h" #include "mkdir.h" #include "path-util.h" #include "process-util.h" diff --git a/src/basic/keyring-util.c b/src/basic/keyring-util.c index 6bfc5e38f6..4158537bd4 100644 --- a/src/basic/keyring-util.c +++ b/src/basic/keyring-util.c @@ -3,7 +3,6 @@ #include "alloc-util.h" #include "keyring-util.h" #include "log.h" -#include "missing_syscall.h" int keyring_read(key_serial_t serial, void **ret, size_t *ret_size) { size_t bufsize = 100; diff --git a/src/basic/keyring-util.h b/src/basic/keyring-util.h index a949f8907e..b8a36a9ad6 100644 --- a/src/basic/keyring-util.h +++ b/src/basic/keyring-util.h @@ -1,8 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once +#include /* IWYU pragma: export */ + #include "forward.h" -#include "missing_keyctl.h" /* Like TAKE_PTR() but for key_serial_t, resetting them to -1 */ #define TAKE_KEY_SERIAL(key_serial) TAKE_GENERIC(key_serial, key_serial_t, -1) diff --git a/src/basic/missing_syscall.h b/src/basic/missing_syscall.h deleted file mode 100644 index 994bda9a3e..0000000000 --- a/src/basic/missing_syscall.h +++ /dev/null @@ -1,244 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -#pragma once - -/* Missing glibc definitions to access certain kernel APIs */ - -#include -#include -#include -#include -#include -#include - -#include "forward.h" -#include "missing_keyctl.h" - -/* ======================================================================= */ - -#if !HAVE_FCHMODAT2 -/* since kernel v6.6 (78252deb023cf0879256fcfbafe37022c390762b) */ -static inline int missing_fchmodat2(int dirfd, const char *path, mode_t mode, int flags) { - return syscall(__NR_fchmodat2, dirfd, path, mode, flags); -} - -# define fchmodat2 missing_fchmodat2 -#endif - -/* ======================================================================= */ - -#if !HAVE_PIVOT_ROOT -static inline int missing_pivot_root(const char *new_root, const char *put_old) { - return syscall(__NR_pivot_root, new_root, put_old); -} - -# define pivot_root missing_pivot_root -#endif - -/* ======================================================================= */ - -#if !HAVE_IOPRIO_GET -static inline int missing_ioprio_get(int which, int who) { - return syscall(__NR_ioprio_get, which, who); -} - -# define ioprio_get missing_ioprio_get -#endif - -/* ======================================================================= */ - -#if !HAVE_IOPRIO_SET -static inline int missing_ioprio_set(int which, int who, int ioprio) { - return syscall(__NR_ioprio_set, which, who, ioprio); -} - -# define ioprio_set missing_ioprio_set -#endif - -/* ======================================================================= */ - -#if !HAVE_KCMP -static inline int missing_kcmp(pid_t pid1, pid_t pid2, int type, unsigned long idx1, unsigned long idx2) { - return syscall(__NR_kcmp, pid1, pid2, type, idx1, idx2); -} - -# define kcmp missing_kcmp -#endif - -/* ======================================================================= */ - -#if !HAVE_KEYCTL -static inline long missing_keyctl(int cmd, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5) { - return syscall(__NR_keyctl, cmd, arg2, arg3, arg4, arg5); - -# define keyctl missing_keyctl -} - -/* ======================================================================= */ - -static inline key_serial_t missing_add_key(const char *type, const char *description, const void *payload, size_t plen, key_serial_t ringid) { - return syscall(__NR_add_key, type, description, payload, plen, ringid); - -# define add_key missing_add_key -} - -/* ======================================================================= */ - -static inline key_serial_t missing_request_key(const char *type, const char *description, const char * callout_info, key_serial_t destringid) { - return syscall(__NR_request_key, type, description, callout_info, destringid); - -# define request_key missing_request_key -} -#endif - -/* ======================================================================= */ - -#if !HAVE_BPF -union bpf_attr; - -static inline int missing_bpf(int cmd, union bpf_attr *attr, size_t size) { - return (int) syscall(__NR_bpf, cmd, attr, size); -} - -# define bpf missing_bpf -#endif - -/* ======================================================================= */ - -#if !HAVE_SET_MEMPOLICY -static inline long missing_set_mempolicy(int mode, const unsigned long *nodemask, - unsigned long maxnode) { - return syscall(__NR_set_mempolicy, mode, nodemask, maxnode); -} - -# define set_mempolicy missing_set_mempolicy -#endif - -#if !HAVE_GET_MEMPOLICY -static inline long missing_get_mempolicy(int *mode, unsigned long *nodemask, - unsigned long maxnode, void *addr, - unsigned long flags) { - return syscall(__NR_get_mempolicy, mode, nodemask, maxnode, addr, flags); -} - -# define get_mempolicy missing_get_mempolicy -#endif - -/* ======================================================================= */ - -#if !HAVE_PIDFD_SEND_SIGNAL -/* since kernel v5.1 (3eb39f47934f9d5a3027fe00d906a45fe3a15fad) */ -static inline int missing_pidfd_send_signal(int fd, int sig, siginfo_t *info, unsigned flags) { - return syscall(__NR_pidfd_send_signal, fd, sig, info, flags); -} - -# define pidfd_send_signal missing_pidfd_send_signal -#endif - -/* ======================================================================= */ - -#if !HAVE_PIDFD_OPEN -/* since kernel v5.3 (7615d9e1780e26e0178c93c55b73309a5dc093d7) */ -static inline int missing_pidfd_open(pid_t pid, unsigned flags) { - return syscall(__NR_pidfd_open, pid, flags); -} - -# define pidfd_open missing_pidfd_open -#endif - -/* ======================================================================= */ - -#if !HAVE_RT_TGSIGQUEUEINFO -static inline int missing_rt_tgsigqueueinfo(pid_t tgid, pid_t tid, int sig, siginfo_t *info) { - return syscall(__NR_rt_tgsigqueueinfo, tgid, tid, sig, info); -} - -# define rt_tgsigqueueinfo missing_rt_tgsigqueueinfo -#endif - -/* ======================================================================= */ - -#if !HAVE_EXECVEAT -/* since kernel v3.19 (51f39a1f0cea1cacf8c787f652f26dfee9611874) */ -static inline int missing_execveat(int dirfd, const char *pathname, - char *const argv[], char *const envp[], - int flags) { - return syscall(__NR_execveat, dirfd, pathname, argv, envp, flags); -} - -# define execveat missing_execveat -#endif - -/* ======================================================================= */ - -#if !HAVE_CLOSE_RANGE -/* since kernel v5.9 (9b4feb630e8e9801603f3cab3a36369e3c1cf88d) */ -static inline int missing_close_range(unsigned first_fd, unsigned end_fd, unsigned flags) { - /* Kernel-side the syscall expects fds as unsigned integers (just like close() actually), while - * userspace exclusively uses signed integers for fds. glibc chose to expose it 1:1 however, hence we - * do so here too, even if we end up passing signed fds to it most of the time. */ - return syscall(__NR_close_range, - first_fd, - end_fd, - flags); -} - -# define close_range missing_close_range -#endif - -/* ======================================================================= */ - -#if !HAVE_SCHED_SETATTR -/* since kernel 3.14 (e6cfc0295c7d51b008999a8b13a44fb43f8685ea) */ -static inline ssize_t missing_sched_setattr(pid_t pid, struct sched_attr *attr, unsigned int flags) { - return syscall(__NR_sched_setattr, pid, attr, flags); -} - -# define sched_setattr missing_sched_setattr -#endif - -/* ======================================================================= */ - -/* glibc does not provide clone() on ia64, only clone2(). Not only that, but it also doesn't provide a - * prototype, only the symbol in the shared library (it provides a prototype for clone(), but not the - * symbol in the shared library). */ -#if defined(__ia64__) -int __clone2(int (*fn)(void *), void *stack_base, size_t stack_size, int flags, void *arg); -#define HAVE_CLONE 0 -#else -/* We know that everywhere else clone() is available, so we don't bother with a meson check (that takes time - * at build time) and just define it. Once the kernel drops ia64 support, we can drop this too. */ -#define HAVE_CLONE 1 -#endif - -/* ======================================================================= */ - -#if !HAVE_QUOTACTL_FD -/* since kernel v5.14 (64c2c2c62f92339b176ea24403d8db16db36f9e6) */ -static inline int missing_quotactl_fd(int fd, int cmd, int id, void *addr) { - return syscall(__NR_quotactl_fd, fd, cmd, id, addr); -} - -# define quotactl_fd missing_quotactl_fd -#endif - -/* ======================================================================= */ - -#if !HAVE_SETXATTRAT -/* since kernel v6.13 (6140be90ec70c39fa844741ca3cc807dd0866394) */ -static inline int missing_setxattrat(int fd, const char *path, int at_flags, const char *name, const struct xattr_args *args, size_t size) { - return syscall(__NR_setxattrat, fd, path, at_flags, name, args, size); -} - -# define setxattrat missing_setxattrat -#endif - -/* ======================================================================= */ - -#if !HAVE_REMOVEXATTRAT -/* since kernel v6.13 (6140be90ec70c39fa844741ca3cc807dd0866394) */ -static inline int missing_removexattrat(int fd, const char *path, int at_flags, const char *name) { - return syscall(__NR_removexattrat, fd, path, at_flags, name); -} - -# define removexattrat missing_removexattrat -#endif diff --git a/src/basic/pidfd-util.h b/src/basic/pidfd-util.h index 0cc247ced1..811d40dce9 100644 --- a/src/basic/pidfd-util.h +++ b/src/basic/pidfd-util.h @@ -4,7 +4,6 @@ #include /* IWYU pragma: export */ #include "forward.h" -#include "missing_syscall.h" /* IWYU pragma: export */ int pidfd_get_namespace(int fd, unsigned long ns_type_cmd); diff --git a/src/basic/process-util.c b/src/basic/process-util.c index 1d341aa0a7..de97843816 100644 --- a/src/basic/process-util.c +++ b/src/basic/process-util.c @@ -34,7 +34,6 @@ #include "locale-util.h" #include "log.h" #include "memory-util.h" -#include "missing_syscall.h" #include "mountpoint-util.h" #include "namespace-util.h" #include "nulstr-util.h" diff --git a/src/basic/signal-util.c b/src/basic/signal-util.c index 5a14046f01..459328a3c7 100644 --- a/src/basic/signal-util.c +++ b/src/basic/signal-util.c @@ -4,7 +4,6 @@ #include #include "errno-util.h" -#include "missing_syscall.h" #include "parse-util.h" #include "signal-util.h" #include "stdio-util.h" diff --git a/src/basic/xattr-util.c b/src/basic/xattr-util.c index 15072add78..1bde725d1a 100644 --- a/src/basic/xattr-util.c +++ b/src/basic/xattr-util.c @@ -8,7 +8,6 @@ #include "errno-util.h" #include "fd-util.h" #include "fs-util.h" -#include "missing_syscall.h" #include "nulstr-util.h" #include "parse-util.h" #include "sparse-endian.h" diff --git a/src/core/bpf-devices.c b/src/core/bpf-devices.c index 7e6a1d15a4..ef8ba3d572 100644 --- a/src/core/bpf-devices.c +++ b/src/core/bpf-devices.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #include +#include #include #include @@ -12,7 +13,6 @@ #include "fd-util.h" #include "fileio.h" #include "log.h" -#include "missing_bpf.h" #include "nulstr-util.h" #include "parse-util.h" #include "path-util.h" diff --git a/src/core/exec-invoke.c b/src/core/exec-invoke.c index 3853aef4af..771308848a 100644 --- a/src/core/exec-invoke.c +++ b/src/core/exec-invoke.c @@ -1,13 +1,14 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #include -#include #include #include #include #include #include #include +#include +#include #include #include #include @@ -54,7 +55,6 @@ #include "journal-send.h" #include "manager.h" #include "memfd-util.h" -#include "missing_syscall.h" #include "mkdir-label.h" #include "mount-util.h" #include "namespace-util.h" diff --git a/src/core/meson.build b/src/core/meson.build index 067ecee303..991c3bb0d1 100644 --- a/src/core/meson.build +++ b/src/core/meson.build @@ -181,6 +181,7 @@ executor_libs = get_option('link-executor-shared') ? \ libcore, libshared, ] : [ + libc_wrapper_static, libcore_static, libshared_static, libbasic_static, diff --git a/src/home/homework-fscrypt.c b/src/home/homework-fscrypt.c index 8a3bb27655..bfcfb6774f 100644 --- a/src/home/homework-fscrypt.c +++ b/src/home/homework-fscrypt.c @@ -22,8 +22,6 @@ #include "keyring-util.h" #include "log.h" #include "memory-util.h" -#include "missing_keyctl.h" -#include "missing_syscall.h" #include "mkdir.h" #include "mount-util.h" #include "nulstr-util.h" diff --git a/src/home/homework-luks.c b/src/home/homework-luks.c index 326f941312..5c6bd28088 100644 --- a/src/home/homework-luks.c +++ b/src/home/homework-luks.c @@ -46,7 +46,6 @@ #include "loop-util.h" #include "memory-util.h" #include "missing_magic.h" -#include "missing_syscall.h" #include "mkdir.h" #include "mkfs-util.h" #include "openssl-util.h" diff --git a/src/home/homework-password-cache.c b/src/home/homework-password-cache.c index cd497b46e7..fb205153bc 100644 --- a/src/home/homework-password-cache.c +++ b/src/home/homework-password-cache.c @@ -4,7 +4,6 @@ #include "homework-password-cache.h" #include "keyring-util.h" #include "log.h" -#include "missing_syscall.h" #include "string-util.h" #include "user-record.h" diff --git a/src/home/homework.c b/src/home/homework.c index 57a7b77344..1056d27b8b 100644 --- a/src/home/homework.c +++ b/src/home/homework.c @@ -36,7 +36,6 @@ #include "main-func.h" #include "memory-util.h" #include "missing_magic.h" -#include "missing_syscall.h" #include "mount-util.h" #include "path-util.h" #include "recovery-key.h" diff --git a/src/home/homework.h b/src/home/homework.h index abd1c482da..2060d15827 100644 --- a/src/home/homework.h +++ b/src/home/homework.h @@ -2,11 +2,11 @@ #pragma once #include +#include #include "sd-id128.h" #include "homework-forward.h" -#include "missing_keyctl.h" #include "user-record-util.h" typedef struct HomeSetup { diff --git a/src/basic/missing_bpf.h b/src/include/override/linux/bpf.h similarity index 90% rename from src/basic/missing_bpf.h rename to src/include/override/linux/bpf.h index 968bcdfb2d..f33c748fde 100644 --- a/src/basic/missing_bpf.h +++ b/src/include/override/linux/bpf.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include /* IWYU pragma: export */ +#include_next /* IWYU pragma: export */ /* defined in linux/filter.h */ /* Unconditional jumps, goto pc + off16 */ diff --git a/src/basic/missing_keyctl.h b/src/include/override/linux/keyctl.h similarity index 90% rename from src/basic/missing_keyctl.h rename to src/include/override/linux/keyctl.h index 8a9c82b9b4..1f0988371a 100644 --- a/src/basic/missing_keyctl.h +++ b/src/include/override/linux/keyctl.h @@ -1,9 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include /* IWYU pragma: export */ +#include_next /* IWYU pragma: export */ -#include "forward.h" +#include /* From linux/key.h */ #ifndef KEY_POS_VIEW @@ -42,5 +42,5 @@ typedef int32_t key_serial_t; # define KEY_OTH_SETATTR 0x00000020 # define KEY_OTH_ALL 0x0000003f #else -assert_cc(KEY_OTH_ALL == 0x0000003f); +static_assert(KEY_OTH_ALL == 0x0000003f, ""); #endif diff --git a/src/include/override/sched.h b/src/include/override/sched.h index 41c830e26b..f2748b1608 100644 --- a/src/include/override/sched.h +++ b/src/include/override/sched.h @@ -35,3 +35,22 @@ static_assert(PF_KTHREAD == 0x00200000, ""); #else static_assert(TASK_COMM_LEN == 16, ""); #endif + +/* glibc does not provide clone() on ia64, only clone2(). Not only that, but it also doesn't provide a + * prototype, only the symbol in the shared library (it provides a prototype for clone(), but not the + * symbol in the shared library). */ +#if defined(__ia64__) +int __clone2(int (*fn)(void *), void *stack_base, size_t stack_size, int flags, void *arg); +#define HAVE_CLONE 0 +#else +/* We know that everywhere else clone() is available, so we don't bother with a meson check (that takes time + * at build time) and just define it. Once the kernel drops ia64 support, we can drop this too. */ +#define HAVE_CLONE 1 +#endif + +/* Defined since glibc-2.41. + * Supported since kernel 3.14 (e6cfc0295c7d51b008999a8b13a44fb43f8685ea). */ +#if !HAVE_SCHED_SETATTR +int missing_sched_setattr(pid_t pid, struct sched_attr *attr, unsigned flags); +# define sched_setattr missing_sched_setattr +#endif diff --git a/src/include/override/signal.h b/src/include/override/signal.h new file mode 100644 index 0000000000..83aa18dc8f --- /dev/null +++ b/src/include/override/signal.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +#pragma once + +#include_next + +#if !HAVE_RT_TGSIGQUEUEINFO +int missing_rt_tgsigqueueinfo(pid_t tgid, pid_t tid, int sig, siginfo_t *info); +# define rt_tgsigqueueinfo missing_rt_tgsigqueueinfo +#endif diff --git a/src/include/override/sys/bpf.h b/src/include/override/sys/bpf.h new file mode 100644 index 0000000000..56e1466b89 --- /dev/null +++ b/src/include/override/sys/bpf.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +#pragma once + +#include /* IWYU pragma: export */ +#include + +/* Supported since kernel v3.18 (749730ce42a2121e1c88350d69478bff3994b10a). */ +#if !HAVE_BPF +int missing_bpf(int cmd, union bpf_attr *attr, size_t size); +# define bpf missing_bpf +#endif diff --git a/src/include/override/sys/ioprio.h b/src/include/override/sys/ioprio.h new file mode 100644 index 0000000000..c361eba6e6 --- /dev/null +++ b/src/include/override/sys/ioprio.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +#pragma once + +#include /* IWYU pragma: export */ + +#if !HAVE_IOPRIO_GET +int missing_ioprio_get(int which, int who); +# define ioprio_get missing_ioprio_get +#endif + +#if !HAVE_IOPRIO_SET +int missing_ioprio_set(int which, int who, int ioprio); +# define ioprio_set missing_ioprio_set +#endif diff --git a/src/include/override/sys/kcmp.h b/src/include/override/sys/kcmp.h new file mode 100644 index 0000000000..4e47825ac5 --- /dev/null +++ b/src/include/override/sys/kcmp.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +#pragma once + +#include /* IWYU pragma: export */ +#include + +/* Supported since kernel v3.5 (d97b46a64674a267bc41c9e16132ee2a98c3347d). */ +#if !HAVE_KCMP +int missing_kcmp(pid_t pid1, pid_t pid2, int type, unsigned long idx1, unsigned long idx2); +# define kcmp missing_kcmp +#endif diff --git a/src/include/override/sys/keyctl.h b/src/include/override/sys/keyctl.h new file mode 100644 index 0000000000..88c9c40ea7 --- /dev/null +++ b/src/include/override/sys/keyctl.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +#pragma once + +#include /* IWYU pragma: export */ +#include + +#if !HAVE_KEYCTL +long missing_keyctl(int cmd, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5); +# define keyctl missing_keyctl +#endif + +#if !HAVE_ADD_KEY +key_serial_t missing_add_key(const char *type, const char *description, const void *payload, size_t plen, key_serial_t ringid); +# define add_key missing_add_key +#endif + +#if !HAVE_REQUEST_KEY +key_serial_t missing_request_key(const char *type, const char *description, const char *callout_info, key_serial_t destringid); +# define request_key missing_request_key +#endif diff --git a/src/include/override/sys/mempolicy.h b/src/include/override/sys/mempolicy.h new file mode 100644 index 0000000000..9858f2812b --- /dev/null +++ b/src/include/override/sys/mempolicy.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +#pragma once + +#include /* IWYU pragma: export */ + +#if !HAVE_SET_MEMPOLICY +int missing_set_mempolicy(int mode, const unsigned long *nodemask, unsigned long maxnode); +# define set_mempolicy missing_set_mempolicy +#endif + +#if !HAVE_GET_MEMPOLICY +int missing_get_mempolicy(int *mode, unsigned long *nodemask, unsigned long maxnode, void *addr, unsigned long flags); +# define get_mempolicy missing_get_mempolicy +#endif diff --git a/src/include/override/sys/mount.h b/src/include/override/sys/mount.h index 050c23cc6a..33a843b8f4 100644 --- a/src/include/override/sys/mount.h +++ b/src/include/override/sys/mount.h @@ -8,8 +8,6 @@ #include #include #include -#include -#include /* Since glibc-2.37 (774058d72942249f71d74e7f2b639f77184160a6), sys/mount.h includes linux/mount.h, and * we can safely include both headers in the same source file. However, we cannot do that with older glibc. @@ -41,67 +39,56 @@ extern int umount2(const char *__special_file, int __flags) __THROW; /* Open the filesystem referenced by FS_NAME so it can be configured for mouting. */ +/* Defined since glibc-2.36. + * Supported since kernel v5.2 (24dcb3d90a1f67fe08c68a004af37df059d74005). */ #if HAVE_FSOPEN extern int fsopen(const char *__fs_name, unsigned int __flags) __THROW; #else -static inline int missing_fsopen(const char *fsname, unsigned flags) { - return syscall(__NR_fsopen, fsname, flags); -} +int missing_fsopen(const char *fsname, unsigned flags); # define fsopen missing_fsopen #endif /* Create a mount representation for the FD created by fsopen using FLAGS with ATTR_FLAGS describing how the mount is to be performed. */ +/* Defined since glibc-2.36. + * Supported since kernel v5.2 (93766fbd2696c2c4453dd8e1070977e9cd4e6b6d). */ #if HAVE_FSMOUNT extern int fsmount(int __fd, unsigned int __flags, unsigned int __ms_flags) __THROW; #else -static inline int missing_fsmount(int fd, unsigned flags, unsigned ms_flags) { - return syscall(__NR_fsmount, fd, flags, ms_flags); -} +int missing_fsmount(int fd, unsigned flags, unsigned ms_flags); # define fsmount missing_fsmount #endif /* Add the mounted FROM_DFD referenced by FROM_PATHNAME filesystem returned by fsmount in the hierarchy in the place TO_DFD reference by TO_PATHNAME using FLAGS. */ +/* Defined since glibc-2.36. + * Supported since kernel v5.2 (2db154b3ea8e14b04fee23e3fdfd5e9d17fbc6ae). */ #if HAVE_MOVE_MOUNT extern int move_mount(int __from_dfd, const char *__from_pathname, int __to_dfd, const char *__to_pathname, unsigned int flags) __THROW; #else -static inline int missing_move_mount( - int from_dfd, - const char *from_pathname, - int to_dfd, - const char *to_pathname, - unsigned flags) { - - return syscall(__NR_move_mount, from_dfd, from_pathname, to_dfd, to_pathname, flags); -} +int missing_move_mount(int from_dfd, const char *from_pathname, int to_dfd, const char *to_pathname, unsigned flags); # define move_mount missing_move_mount #endif /* Set parameters and trigger CMD action on the FD context. KEY, VALUE, and AUX are used depending ng of the CMD. */ +/* Defined since glibc-2.36. + * Supported since kernel v5.2 (ecdab150fddb42fe6a739335257949220033b782). */ #if HAVE_FSCONFIG extern int fsconfig(int __fd, unsigned int __cmd, const char *__key, const void *__value, int __aux) __THROW; #else -static inline int missing_fsconfig(int fd, unsigned cmd, const char *key, const void *value, int aux) { - return syscall(__NR_fsconfig, fd, cmd, key, value, aux); -} +int missing_fsconfig(int fd, unsigned cmd, const char *key, const void *value, int aux); # define fsconfig missing_fsconfig #endif -/* Equivalent of fopen for an existing mount point. */ -#if HAVE_FSPICK -extern int fspick(int __dfd, const char *__path, unsigned int __flags) __THROW; -#endif - /* Open the mount point FILENAME in directory DFD using FLAGS. */ +/* Defined since glibc-2.36. + * Supported since kernel v5.2 (a07b20004793d8926f78d63eb5980559f7813404). */ #if HAVE_OPEN_TREE extern int open_tree(int __dfd, const char *__filename, unsigned int __flags) __THROW; #else -static inline int missing_open_tree(int dfd, const char *filename, unsigned flags) { - return syscall(__NR_open_tree, dfd, filename, flags); -} +int missing_open_tree(int dfd, const char *filename, unsigned flags); # define open_tree missing_open_tree #endif @@ -110,21 +97,20 @@ static inline int missing_open_tree(int dfd, const char *filename, unsigned flag directory referred to by the file descriptor dirfd. Otherwise if DFD is the special value AT_FDCWD then PATH is interpreted relative to the current working directory of the calling process. */ +/* Defined since glibc-2.36. + * Supported since kernel v5.12 (2a1867219c7b27f928e2545782b86daaf9ad50bd). */ #if HAVE_MOUNT_SETATTR extern int mount_setattr(int __dfd, const char *__path, unsigned int __flags, struct mount_attr *__uattr, size_t __usize) __THROW; #else -static inline int missing_mount_setattr(int dfd, const char *path, unsigned flags, struct mount_attr *attr, size_t size) { - return syscall(__NR_mount_setattr, dfd, path, flags, attr, size); -} +int missing_mount_setattr(int dfd, const char *path, unsigned flags, struct mount_attr *attr, size_t size); # define mount_setattr missing_mount_setattr #endif +/* Not defined in glibc yet as of glibc-2.41. + * Supported since kernel v6.15 (c4a16820d90199409c9bf01c4f794e1e9e8d8fd8). */ #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); -} - +int missing_open_tree_attr(int dfd, const char *filename, unsigned int flags, struct mount_attr *attr, size_t size); # define open_tree_attr missing_open_tree_attr #endif diff --git a/src/include/override/sys/pidfd.h b/src/include/override/sys/pidfd.h index de13144524..69eb2eaff9 100644 --- a/src/include/override/sys/pidfd.h +++ b/src/include/override/sys/pidfd.h @@ -1,14 +1,29 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include - /* since glibc-2.36 */ #if HAVE_PIDFD_OPEN #include_next #endif +#include +#include +#include + +/* Defined since glibc-2.36. + * Supported since kernel v5.3 (7615d9e1780e26e0178c93c55b73309a5dc093d7). */ +#if !HAVE_PIDFD_OPEN +int missing_pidfd_open(pid_t pid, unsigned flags); +# define pidfd_open missing_pidfd_open +#endif + +/* Defined since glibc-2.36. + * Supported since kernel v5.1 (3eb39f47934f9d5a3027fe00d906a45fe3a15fad). */ +#if !HAVE_PIDFD_SEND_SIGNAL +int missing_pidfd_send_signal(int fd, int sig, siginfo_t *info, unsigned flags); +# define pidfd_send_signal missing_pidfd_send_signal +#endif + /* since glibc-2.41 */ #ifndef PIDFS_IOCTL_MAGIC # define PIDFS_IOCTL_MAGIC 0xFF diff --git a/src/include/override/sys/quota.h b/src/include/override/sys/quota.h new file mode 100644 index 0000000000..481dbaba21 --- /dev/null +++ b/src/include/override/sys/quota.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +#pragma once + +#include_next + +/* Supported since kernel v5.14 (64c2c2c62f92339b176ea24403d8db16db36f9e6). */ +#if !HAVE_QUOTACTL_FD +int missing_quotactl_fd(int fd, int cmd, int id, void *addr); +# define quotactl_fd missing_quotactl_fd +#endif diff --git a/src/include/override/sys/stat.h b/src/include/override/sys/stat.h new file mode 100644 index 0000000000..37793cff19 --- /dev/null +++ b/src/include/override/sys/stat.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +#pragma once + +#include_next + +/* Supported since kernel v6.6 (78252deb023cf0879256fcfbafe37022c390762b). */ +#if !HAVE_FCHMODAT2 +int missing_fchmodat2(int dirfd, const char *path, mode_t mode, int flags); +# define fchmodat2 missing_fchmodat2 +#endif diff --git a/src/include/override/sys/xattr.h b/src/include/override/sys/xattr.h index 96534832ce..711c5387c1 100644 --- a/src/include/override/sys/xattr.h +++ b/src/include/override/sys/xattr.h @@ -6,3 +6,15 @@ #include #include_next + +/* Supported since kernel v6.13 (6140be90ec70c39fa844741ca3cc807dd0866394). */ +#if !HAVE_SETXATTRAT +int missing_setxattrat(int fd, const char *path, int at_flags, const char *name, const struct xattr_args *args, size_t size); +# define setxattrat missing_setxattrat +#endif + +/* Supported since kernel v6.13 (6140be90ec70c39fa844741ca3cc807dd0866394). */ +#if !HAVE_REMOVEXATTRAT +int missing_removexattrat(int fd, const char *path, int at_flags, const char *name); +# define removexattrat missing_removexattrat +#endif diff --git a/src/include/override/unistd.h b/src/include/override/unistd.h new file mode 100644 index 0000000000..d381f06a53 --- /dev/null +++ b/src/include/override/unistd.h @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +#pragma once + +#include_next + +/* Defined since glibc-2.34. + * Supported since kernel v5.9 (9b4feb630e8e9801603f3cab3a36369e3c1cf88d). */ +#if !HAVE_CLOSE_RANGE +int missing_close_range(unsigned first_fd, unsigned end_fd, unsigned flags); +# define close_range missing_close_range +#endif + +/* Defined since glibc-2.34. + * Supported since kernel v3.19 (51f39a1f0cea1cacf8c787f652f26dfee9611874). */ +#if !HAVE_EXECVEAT +int missing_execveat(int dirfd, const char *pathname, char * const argv[], char * const envp[], int flags); +# define execveat missing_execveat +#endif + +#if !HAVE_PIVOT_ROOT +int missing_pivot_root(const char *new_root, const char *put_old); +# define pivot_root missing_pivot_root +#endif diff --git a/src/libc/bpf.c b/src/libc/bpf.c new file mode 100644 index 0000000000..4a7498e502 --- /dev/null +++ b/src/libc/bpf.c @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#include +#include +#include + +#if !HAVE_BPF +int missing_bpf(int cmd, union bpf_attr *attr, size_t size) { + return syscall(__NR_bpf, cmd, attr, size); +} +#endif diff --git a/src/libc/ioprio.c b/src/libc/ioprio.c new file mode 100644 index 0000000000..5bb640457d --- /dev/null +++ b/src/libc/ioprio.c @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#include +#include +#include + +#if !HAVE_IOPRIO_GET +int missing_ioprio_get(int which, int who) { + return syscall(__NR_ioprio_get, which, who); +} +#endif + +#if !HAVE_IOPRIO_SET +int missing_ioprio_set(int which, int who, int ioprio) { + return syscall(__NR_ioprio_set, which, who, ioprio); +} +#endif diff --git a/src/libc/kcmp.c b/src/libc/kcmp.c new file mode 100644 index 0000000000..aafff999ef --- /dev/null +++ b/src/libc/kcmp.c @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#include +#include +#include + +#if !HAVE_KCMP +int missing_kcmp(pid_t pid1, pid_t pid2, int type, unsigned long idx1, unsigned long idx2) { + return syscall(__NR_kcmp, pid1, pid2, type, idx1, idx2); +} +#endif diff --git a/src/libc/keyctl.c b/src/libc/keyctl.c new file mode 100644 index 0000000000..af4bca87f5 --- /dev/null +++ b/src/libc/keyctl.c @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#include +#include +#include + +#if !HAVE_KEYCTL +long missing_keyctl(int cmd, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5) { + return syscall(__NR_keyctl, cmd, arg2, arg3, arg4, arg5); +} +#endif + +#if !HAVE_ADD_KEY +key_serial_t missing_add_key(const char *type, const char *description, const void *payload, size_t plen, key_serial_t ringid) { + return syscall(__NR_add_key, type, description, payload, plen, ringid); +} +#endif + +#if !HAVE_REQUEST_KEY +key_serial_t missing_request_key(const char *type, const char *description, const char *callout_info, key_serial_t destringid) { + return syscall(__NR_request_key, type, description, callout_info, destringid); +} +#endif diff --git a/src/libc/mempolicy.c b/src/libc/mempolicy.c new file mode 100644 index 0000000000..77b0e1ac01 --- /dev/null +++ b/src/libc/mempolicy.c @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#include +#include +#include + +#if !HAVE_SET_MEMPOLICY +int missing_set_mempolicy(int mode, const unsigned long *nodemask, unsigned long maxnode) { + return syscall(__NR_set_mempolicy, mode, nodemask, maxnode); +} +#endif + +#if !HAVE_GET_MEMPOLICY +int missing_get_mempolicy(int *mode, unsigned long *nodemask, unsigned long maxnode, void *addr, unsigned long flags) { + return syscall(__NR_get_mempolicy, mode, nodemask, maxnode, addr, flags); +} +#endif diff --git a/src/libc/meson.build b/src/libc/meson.build new file mode 100644 index 0000000000..eeee98c9d6 --- /dev/null +++ b/src/libc/meson.build @@ -0,0 +1,28 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +libc_wrapper_sources = files( + 'bpf.c', + 'ioprio.c', + 'kcmp.c', + 'keyctl.c', + 'mempolicy.c', + 'mount.c', + 'pidfd.c', + 'quota.c', + 'sched.c', + 'signal.c', + 'stat.c', + 'unistd.c', + 'xattr.c', +) + +sources += libc_wrapper_sources + +libc_wrapper_static = static_library( + 'c-wrapper', + libc_wrapper_sources, + include_directories : system_includes, + implicit_include_directories : false, + dependencies : [userspace], + c_args : ['-fvisibility=default'], + build_by_default : false) diff --git a/src/libc/mount.c b/src/libc/mount.c new file mode 100644 index 0000000000..1d324ef386 --- /dev/null +++ b/src/libc/mount.c @@ -0,0 +1,47 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#include +#include +#include + +#if !HAVE_FSOPEN +int missing_fsopen(const char *fsname, unsigned flags) { + return syscall(__NR_fsopen, fsname, flags); +} +#endif + +#if !HAVE_FSMOUNT +int missing_fsmount(int fd, unsigned flags, unsigned ms_flags) { + return syscall(__NR_fsmount, fd, flags, ms_flags); +} +#endif + +#if !HAVE_MOVE_MOUNT +int missing_move_mount(int from_dfd, const char *from_pathname, int to_dfd, const char *to_pathname, unsigned flags) { + return syscall(__NR_move_mount, from_dfd, from_pathname, to_dfd, to_pathname, flags); +} +#endif + +#if !HAVE_FSCONFIG +int missing_fsconfig(int fd, unsigned cmd, const char *key, const void *value, int aux) { + return syscall(__NR_fsconfig, fd, cmd, key, value, aux); +} +#endif + +#if !HAVE_OPEN_TREE +int missing_open_tree(int dfd, const char *filename, unsigned flags) { + return syscall(__NR_open_tree, dfd, filename, flags); +} +#endif + +#if !HAVE_MOUNT_SETATTR +int missing_mount_setattr(int dfd, const char *path, unsigned flags, struct mount_attr *attr, size_t size) { + return syscall(__NR_mount_setattr, dfd, path, flags, attr, size); +} +#endif + +#if !HAVE_OPEN_TREE_ATTR +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); +} +#endif diff --git a/src/libc/pidfd.c b/src/libc/pidfd.c new file mode 100644 index 0000000000..a779e3459c --- /dev/null +++ b/src/libc/pidfd.c @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#include +#include +#include + +#if !HAVE_PIDFD_OPEN +int missing_pidfd_open(pid_t pid, unsigned flags) { + return syscall(__NR_pidfd_open, pid, flags); +} +#endif + +#if !HAVE_PIDFD_SEND_SIGNAL +int missing_pidfd_send_signal(int fd, int sig, siginfo_t *info, unsigned flags) { + return syscall(__NR_pidfd_send_signal, fd, sig, info, flags); +} +#endif diff --git a/src/libc/quota.c b/src/libc/quota.c new file mode 100644 index 0000000000..19695df9b3 --- /dev/null +++ b/src/libc/quota.c @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#include +#include +#include + +#if !HAVE_QUOTACTL_FD +int missing_quotactl_fd(int fd, int cmd, int id, void *addr) { + return syscall(__NR_quotactl_fd, fd, cmd, id, addr); +} +#endif diff --git a/src/libc/sched.c b/src/libc/sched.c new file mode 100644 index 0000000000..cf1752651b --- /dev/null +++ b/src/libc/sched.c @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#include +#include +#include + +#if !HAVE_SCHED_SETATTR +int missing_sched_setattr(pid_t pid, struct sched_attr *attr, unsigned flags) { + return syscall(__NR_sched_setattr, pid, attr, flags); +} +#endif diff --git a/src/libc/signal.c b/src/libc/signal.c new file mode 100644 index 0000000000..1908331b1a --- /dev/null +++ b/src/libc/signal.c @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#include +#include +#include + +#if !HAVE_RT_TGSIGQUEUEINFO +int missing_rt_tgsigqueueinfo(pid_t tgid, pid_t tid, int sig, siginfo_t *info) { + return syscall(__NR_rt_tgsigqueueinfo, tgid, tid, sig, info); +} +#endif diff --git a/src/libc/stat.c b/src/libc/stat.c new file mode 100644 index 0000000000..b283005f40 --- /dev/null +++ b/src/libc/stat.c @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#include +#include +#include + +#if !HAVE_FCHMODAT2 +int missing_fchmodat2(int dirfd, const char *path, mode_t mode, int flags) { + return syscall(__NR_fchmodat2, dirfd, path, mode, flags); +} +#endif diff --git a/src/libc/unistd.c b/src/libc/unistd.c new file mode 100644 index 0000000000..99777b3316 --- /dev/null +++ b/src/libc/unistd.c @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#include +#include + +#if !HAVE_CLOSE_RANGE +int missing_close_range(unsigned first_fd, unsigned end_fd, unsigned flags) { + /* Kernel-side the syscall expects fds as unsigned integers (just like close() actually), while + * userspace exclusively uses signed integers for fds. glibc chose to expose it 1:1 however, hence we + * do so here too, even if we end up passing signed fds to it most of the time. */ + return syscall(__NR_close_range, first_fd, end_fd, flags); +} +#endif + +#if !HAVE_EXECVEAT +int missing_execveat(int dirfd, const char *pathname, char * const argv[], char * const envp[], int flags) { + return syscall(__NR_execveat, dirfd, pathname, argv, envp, flags); +} +#endif + +#if !HAVE_PIVOT_ROOT +int missing_pivot_root(const char *new_root, const char *put_old) { + return syscall(__NR_pivot_root, new_root, put_old); +} +#endif diff --git a/src/libc/xattr.c b/src/libc/xattr.c new file mode 100644 index 0000000000..68fa97ab28 --- /dev/null +++ b/src/libc/xattr.c @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#include +#include +#include + +#if !HAVE_SETXATTRAT +int missing_setxattrat(int fd, const char *path, int at_flags, const char *name, const struct xattr_args *args, size_t size) { + return syscall(__NR_setxattrat, fd, path, at_flags, name, args, size); +} +#endif + +#if !HAVE_REMOVEXATTRAT +int missing_removexattrat(int fd, const char *path, int at_flags, const char *name) { + return syscall(__NR_removexattrat, fd, path, at_flags, name); +} +#endif diff --git a/src/libsystemd/meson.build b/src/libsystemd/meson.build index 52c6cea3c5..fa483836fa 100644 --- a/src/libsystemd/meson.build +++ b/src/libsystemd/meson.build @@ -147,7 +147,8 @@ libsystemd_static = static_library( include_directories : libsystemd_includes, implicit_include_directories : false, c_args : libsystemd_c_args, - link_with : [libbasic_static], + link_with : [libc_wrapper_static, + libbasic_static], dependencies : [threads, libm, librt, diff --git a/src/libsystemd/sd-id128/sd-id128.c b/src/libsystemd/sd-id128/sd-id128.c index 54fab9284a..d3838ba245 100644 --- a/src/libsystemd/sd-id128/sd-id128.c +++ b/src/libsystemd/sd-id128/sd-id128.c @@ -13,7 +13,6 @@ #include "hmac.h" #include "id128-util.h" #include "keyring-util.h" -#include "missing_syscall.h" #include "path-util.h" #include "random-util.h" #include "stat-util.h" diff --git a/src/login/pam_systemd_loadkey.c b/src/login/pam_systemd_loadkey.c index b1a9aed234..36b4b22552 100644 --- a/src/login/pam_systemd_loadkey.c +++ b/src/login/pam_systemd_loadkey.c @@ -7,7 +7,6 @@ #include #include "keyring-util.h" -#include "missing_syscall.h" #include "nulstr-util.h" #include "pam-util.h" #include "string-util.h" diff --git a/src/login/user-runtime-dir.c b/src/login/user-runtime-dir.c index 77498081ea..30ff2f47c5 100644 --- a/src/login/user-runtime-dir.c +++ b/src/login/user-runtime-dir.c @@ -16,7 +16,6 @@ #include "log.h" #include "main-func.h" #include "missing_magic.h" -#include "missing_syscall.h" #include "mkdir-label.h" #include "mount-util.h" #include "mountpoint-util.h" diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index dfca74b05e..4ccfab8a88 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -66,8 +67,6 @@ #include "loopback-setup.h" #include "machine-credential.h" #include "main-func.h" -#include "missing_keyctl.h" -#include "missing_syscall.h" #include "mkdir.h" #include "mount-util.h" #include "mountpoint-util.h" diff --git a/src/nsresourced/nsresourcework.c b/src/nsresourced/nsresourcework.c index 236d4d4acd..5f99eae4f9 100644 --- a/src/nsresourced/nsresourcework.c +++ b/src/nsresourced/nsresourcework.c @@ -31,7 +31,6 @@ #include "json-util.h" #include "main-func.h" #include "missing_magic.h" -#include "missing_syscall.h" #include "mountpoint-util.h" #include "namespace-util.h" #include "netlink-util.h" diff --git a/src/repart/meson.build b/src/repart/meson.build index 369410bab8..eda4a0a212 100644 --- a/src/repart/meson.build +++ b/src/repart/meson.build @@ -26,6 +26,7 @@ executables += [ 'sources' : files('repart.c'), 'c_args' : '-DSTANDALONE', 'link_with' : [ + libc_wrapper_static, libbasic_static, libshared_fdisk, libshared_static, diff --git a/src/shared/ask-password-api.c b/src/shared/ask-password-api.c index 256605ac8a..dd6b8abc65 100644 --- a/src/shared/ask-password-api.c +++ b/src/shared/ask-password-api.c @@ -23,7 +23,6 @@ #include "iovec-util.h" #include "keyring-util.h" #include "log.h" -#include "missing_syscall.h" #include "nulstr-util.h" #include "parse-util.h" #include "path-lookup.h" diff --git a/src/shared/bpf-program.c b/src/shared/bpf-program.c index 5c4bea60c6..f920051832 100644 --- a/src/shared/bpf-program.c +++ b/src/shared/bpf-program.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include "alloc-util.h" @@ -14,7 +15,6 @@ #include "fdset.h" #include "log.h" #include "memory-util.h" -#include "missing_syscall.h" #include "parse-util.h" #include "path-util.h" #include "serialize.h" diff --git a/src/shared/ioprio-util.h b/src/shared/ioprio-util.h index 0873d8ef61..468f178cd0 100644 --- a/src/shared/ioprio-util.h +++ b/src/shared/ioprio-util.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include /* IWYU pragma: export */ +#include /* IWYU pragma: export */ #include "forward.h" diff --git a/src/shared/meson.build b/src/shared/meson.build index dc509eeb28..2a49a5e9b8 100644 --- a/src/shared/meson.build +++ b/src/shared/meson.build @@ -360,7 +360,8 @@ libshared = shared_library( link_args : ['-shared', '-Wl,--version-script=' + libshared_sym_path], link_depends : libshared_sym_path, - link_whole : [libshared_static, + link_whole : [libc_wrapper_static, + libshared_static, libbasic_static, libsystemd_static], dependencies : [libshared_deps, diff --git a/src/shared/mount-util.c b/src/shared/mount-util.c index 3d10a05091..830ebe1c87 100644 --- a/src/shared/mount-util.c +++ b/src/shared/mount-util.c @@ -19,7 +19,6 @@ #include "hashmap.h" #include "libmount-util.h" #include "log.h" -#include "missing_syscall.h" #include "mkdir-label.h" #include "mount-util.h" #include "mountpoint-util.h" diff --git a/src/shared/numa-util.c b/src/shared/numa-util.c index 8c18c58227..c011c4381d 100644 --- a/src/shared/numa-util.c +++ b/src/shared/numa-util.c @@ -8,7 +8,6 @@ #include "fd-util.h" #include "fileio.h" #include "log.h" -#include "missing_syscall.h" #include "numa-util.h" #include "parse-util.h" #include "stdio-util.h" diff --git a/src/shared/numa-util.h b/src/shared/numa-util.h index 571d0d1354..1c3482a590 100644 --- a/src/shared/numa-util.h +++ b/src/shared/numa-util.h @@ -1,9 +1,10 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once +#include + #include "cpu-set-util.h" #include "forward.h" -#include "missing_syscall.h" static inline bool mpol_is_valid(int t) { return t >= MPOL_DEFAULT && t <= MPOL_LOCAL; diff --git a/src/shared/quota-util.c b/src/shared/quota-util.c index 06f27e85f2..265d502971 100644 --- a/src/shared/quota-util.c +++ b/src/shared/quota-util.c @@ -8,7 +8,6 @@ #include "chattr-util.h" #include "device-util.h" #include "errno-util.h" -#include "missing_syscall.h" #include "quota-util.h" int quotactl_fd_with_fallback(int fd, int cmd, int id, void *addr) { diff --git a/src/shared/switch-root.c b/src/shared/switch-root.c index 288280c3d1..d5f34c5d37 100644 --- a/src/shared/switch-root.c +++ b/src/shared/switch-root.c @@ -11,7 +11,6 @@ #include "errno-util.h" #include "fd-util.h" #include "log.h" -#include "missing_syscall.h" #include "mkdir-label.h" #include "mount-util.h" #include "mountpoint-util.h" diff --git a/src/shutdown/meson.build b/src/shutdown/meson.build index c67d19abcc..4893ea62e3 100644 --- a/src/shutdown/meson.build +++ b/src/shutdown/meson.build @@ -23,6 +23,7 @@ executables += [ 'sources' : systemd_shutdown_sources + systemd_shutdown_extract_sources, 'c_args' : '-DSTANDALONE', 'link_with' : [ + libc_wrapper_static, libbasic_static, libshared_static, libsystemd_static, diff --git a/src/sysusers/meson.build b/src/sysusers/meson.build index 88494d8cfc..e2e82889e7 100644 --- a/src/sysusers/meson.build +++ b/src/sysusers/meson.build @@ -17,6 +17,7 @@ executables += [ 'sources' : files('sysusers.c'), 'c_args' : '-DSTANDALONE', 'link_with' : [ + libc_wrapper_static, libbasic_static, libshared_static, libsystemd_static, diff --git a/src/test/meson.build b/src/test/meson.build index c0c2a4e905..5284dc1315 100644 --- a/src/test/meson.build +++ b/src/test/meson.build @@ -289,7 +289,10 @@ executables += [ # only static linking apart from libdl, to make sure that the # module is linked to all libraries that it uses. 'sources' : files('test-dlopen.c'), - 'link_with' : libbasic_static, + 'link_with' : [ + libc_wrapper_static, + libbasic_static, + ], 'dependencies' : libdl, 'install' : false, 'type' : 'manual', @@ -426,7 +429,10 @@ executables += [ }, test_template + { 'sources' : files('test-sizeof.c'), - 'link_with' : libbasic_static, + 'link_with' : [ + libc_wrapper_static, + libbasic_static, + ], }, test_template + { 'sources' : files('test-time-util.c'), @@ -594,6 +600,7 @@ executables += [ test_template + { 'sources' : files('../libsystemd/sd-device/test-sd-device-thread.c'), 'link_with' : [ + libc_wrapper_static, libbasic_static, libsystemd, ], @@ -602,6 +609,7 @@ executables += [ test_template + { 'sources' : files('../libudev/test-udev-device-thread.c'), 'link_with' : [ + libc_wrapper_static, libbasic_static, libudev, ], diff --git a/src/test/test-seccomp.c b/src/test/test-seccomp.c index 7199b2fb33..a1230ec27c 100644 --- a/src/test/test-seccomp.c +++ b/src/test/test-seccomp.c @@ -21,7 +21,6 @@ #include "fileio.h" #include "fs-util.h" #include "memory-util.h" -#include "missing_syscall.h" #include "nsflags.h" #include "nulstr-util.h" #include "process-util.h" diff --git a/src/tmpfiles/meson.build b/src/tmpfiles/meson.build index 404f265f91..a973d16f5c 100644 --- a/src/tmpfiles/meson.build +++ b/src/tmpfiles/meson.build @@ -25,6 +25,7 @@ executables += [ 'sources' : systemd_tmpfiles_sources + systemd_tmpfiles_extract_sources, 'c_args' : '-DSTANDALONE', 'link_with' : [ + libc_wrapper_static, libbasic_static, libshared_static, libsystemd_static,