mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 00:14:32 +09:00
libc-wrapper: introduce a tiny libc wrapper
Then, move syscall definitions to the wrapper, and prototypes are moved to relevant headers. This also adds checks for add_key() and request_key(), as one day glibc may be going to add some of them separatedly. The check for fspick in meson.build is dropped, as it is currently unused in our code. This also moves - basic/missing_bpf.h -> include/override/linux/bpf.h, - basic/missing_keyctl.h -> include/override/linux/keyctl.h.
This commit is contained in:
14
meson.build
14
meson.build
@@ -580,7 +580,6 @@ foreach ident : [
|
||||
['fsconfig', '''#include <sys/mount.h>'''], # since glibc-2.36
|
||||
['fsmount', '''#include <sys/mount.h>'''], # since glibc-2.36
|
||||
['fsopen', '''#include <sys/mount.h>'''], # since glibc-2.36
|
||||
['fspick', '''#include <sys/mount.h>'''], # since glibc-2.36
|
||||
['mount_setattr', '''#include <sys/mount.h>'''], # since glibc-2.36
|
||||
['move_mount', '''#include <sys/mount.h>'''], # since glibc-2.36
|
||||
['open_tree', '''#include <sys/mount.h>'''], # since glibc-2.36
|
||||
@@ -591,15 +590,17 @@ foreach ident : [
|
||||
['ioprio_get', '''#include <sched.h>'''], # no known header declares ioprio_get
|
||||
['ioprio_set', '''#include <sched.h>'''], # no known header declares ioprio_set
|
||||
['rt_tgsigqueueinfo', '''#include <signal.h>'''], # no known header declares rt_tgsigqueueinfo
|
||||
['open_tree_attr', '''#include <sys/mount.h>'''], # no known header declares open_tree_attr
|
||||
['quotactl_fd', '''#include <sys/quota.h>'''], # no known header declares quotactl_fd
|
||||
['fchmodat2', '''#include <sys/stat.h>'''], # no known header declares fchmodat2
|
||||
['bpf', '''#include <sys/syscall.h>'''], # no known header declares bpf
|
||||
['kcmp', '''#include <sys/syscall.h>'''], # no known header declares kcmp
|
||||
['keyctl', '''#include <sys/syscall.h>'''], # no known header declares keyctl
|
||||
['pivot_root', '''#include <sys/syscall.h>'''], # no known header declares pivot_root
|
||||
['add_key', '''#include <sys/syscall.h>'''], # no known header declares add_key
|
||||
['request_key', '''#include <sys/syscall.h>'''], # no known header declares request_key
|
||||
['setxattrat', '''#include <sys/xattr.h>'''], # no known header declares setxattrat
|
||||
['removexattrat', '''#include <sys/xattr.h>'''], # no known header declares removexattrat
|
||||
['open_tree_attr', '''#include <sys/mount.h>'''], # no known header declares open_tree_attr
|
||||
['pivot_root', '''#include <unistd.h>'''], # 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,
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/kcmp.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/kcmp.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include <sys/keyctl.h> /* 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)
|
||||
|
||||
@@ -1,244 +0,0 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
/* Missing glibc definitions to access certain kernel APIs */
|
||||
|
||||
#include <linux/mempolicy.h>
|
||||
#include <sched.h>
|
||||
#include <signal.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/xattr.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#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
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <sys/pidfd.h> /* IWYU pragma: export */
|
||||
|
||||
#include "forward.h"
|
||||
#include "missing_syscall.h" /* IWYU pragma: export */
|
||||
|
||||
int pidfd_get_namespace(int fd, unsigned long ns_type_cmd);
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "errno-util.h"
|
||||
#include "missing_syscall.h"
|
||||
#include "parse-util.h"
|
||||
#include "signal-util.h"
|
||||
#include "stdio-util.h"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include <fnmatch.h>
|
||||
#include <linux/bpf.h>
|
||||
#include <linux/bpf_insn.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include <grp.h>
|
||||
#include <linux/ioprio.h>
|
||||
#include <linux/prctl.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/securebits.h>
|
||||
#include <poll.h>
|
||||
#include <sys/eventfd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/ioprio.h>
|
||||
#include <sys/keyctl.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/prctl.h>
|
||||
#include <sys/statvfs.h>
|
||||
@@ -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"
|
||||
|
||||
@@ -181,6 +181,7 @@ executor_libs = get_option('link-executor-shared') ? \
|
||||
libcore,
|
||||
libshared,
|
||||
] : [
|
||||
libc_wrapper_static,
|
||||
libcore_static,
|
||||
libshared_static,
|
||||
libbasic_static,
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <linux/fscrypt.h>
|
||||
#include <sys/keyctl.h>
|
||||
|
||||
#include "sd-id128.h"
|
||||
|
||||
#include "homework-forward.h"
|
||||
#include "missing_keyctl.h"
|
||||
#include "user-record-util.h"
|
||||
|
||||
typedef struct HomeSetup {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include <linux/bpf.h> /* IWYU pragma: export */
|
||||
#include_next <linux/bpf.h> /* IWYU pragma: export */
|
||||
|
||||
/* defined in linux/filter.h */
|
||||
/* Unconditional jumps, goto pc + off16 */
|
||||
@@ -1,9 +1,9 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include <linux/keyctl.h> /* IWYU pragma: export */
|
||||
#include_next <linux/keyctl.h> /* IWYU pragma: export */
|
||||
|
||||
#include "forward.h"
|
||||
#include <stdint.h>
|
||||
|
||||
/* 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
|
||||
@@ -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
|
||||
|
||||
9
src/include/override/signal.h
Normal file
9
src/include/override/signal.h
Normal file
@@ -0,0 +1,9 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include_next <signal.h>
|
||||
|
||||
#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
|
||||
11
src/include/override/sys/bpf.h
Normal file
11
src/include/override/sys/bpf.h
Normal file
@@ -0,0 +1,11 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include <linux/bpf.h> /* IWYU pragma: export */
|
||||
#include <stddef.h>
|
||||
|
||||
/* 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
|
||||
14
src/include/override/sys/ioprio.h
Normal file
14
src/include/override/sys/ioprio.h
Normal file
@@ -0,0 +1,14 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include <linux/ioprio.h> /* 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
|
||||
11
src/include/override/sys/kcmp.h
Normal file
11
src/include/override/sys/kcmp.h
Normal file
@@ -0,0 +1,11 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include <linux/kcmp.h> /* IWYU pragma: export */
|
||||
#include <sys/types.h>
|
||||
|
||||
/* 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
|
||||
20
src/include/override/sys/keyctl.h
Normal file
20
src/include/override/sys/keyctl.h
Normal file
@@ -0,0 +1,20 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include <linux/keyctl.h> /* IWYU pragma: export */
|
||||
#include <stddef.h>
|
||||
|
||||
#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
|
||||
14
src/include/override/sys/mempolicy.h
Normal file
14
src/include/override/sys/mempolicy.h
Normal file
@@ -0,0 +1,14 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include <linux/mempolicy.h> /* 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
|
||||
@@ -8,8 +8,6 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* 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
|
||||
|
||||
@@ -1,14 +1,29 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
/* since glibc-2.36 */
|
||||
#if HAVE_PIDFD_OPEN
|
||||
#include_next <sys/pidfd.h>
|
||||
#endif
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <signal.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
/* 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
|
||||
|
||||
10
src/include/override/sys/quota.h
Normal file
10
src/include/override/sys/quota.h
Normal file
@@ -0,0 +1,10 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include_next <sys/quota.h>
|
||||
|
||||
/* 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
|
||||
10
src/include/override/sys/stat.h
Normal file
10
src/include/override/sys/stat.h
Normal file
@@ -0,0 +1,10 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include_next <sys/stat.h>
|
||||
|
||||
/* 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
|
||||
@@ -6,3 +6,15 @@
|
||||
#include <linux/xattr.h>
|
||||
|
||||
#include_next <sys/xattr.h>
|
||||
|
||||
/* 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
|
||||
|
||||
23
src/include/override/unistd.h
Normal file
23
src/include/override/unistd.h
Normal file
@@ -0,0 +1,23 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include_next <unistd.h>
|
||||
|
||||
/* 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
|
||||
11
src/libc/bpf.c
Normal file
11
src/libc/bpf.c
Normal file
@@ -0,0 +1,11 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include <sys/bpf.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#if !HAVE_BPF
|
||||
int missing_bpf(int cmd, union bpf_attr *attr, size_t size) {
|
||||
return syscall(__NR_bpf, cmd, attr, size);
|
||||
}
|
||||
#endif
|
||||
17
src/libc/ioprio.c
Normal file
17
src/libc/ioprio.c
Normal file
@@ -0,0 +1,17 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include <sys/ioprio.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#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
|
||||
11
src/libc/kcmp.c
Normal file
11
src/libc/kcmp.c
Normal file
@@ -0,0 +1,11 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include <sys/kcmp.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#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
|
||||
23
src/libc/keyctl.c
Normal file
23
src/libc/keyctl.c
Normal file
@@ -0,0 +1,23 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include <sys/keyctl.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#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
|
||||
17
src/libc/mempolicy.c
Normal file
17
src/libc/mempolicy.c
Normal file
@@ -0,0 +1,17 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include <sys/mempolicy.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#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
|
||||
28
src/libc/meson.build
Normal file
28
src/libc/meson.build
Normal file
@@ -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)
|
||||
47
src/libc/mount.c
Normal file
47
src/libc/mount.c
Normal file
@@ -0,0 +1,47 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include <sys/mount.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#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
|
||||
17
src/libc/pidfd.c
Normal file
17
src/libc/pidfd.c
Normal file
@@ -0,0 +1,17 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include <sys/pidfd.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#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
|
||||
11
src/libc/quota.c
Normal file
11
src/libc/quota.c
Normal file
@@ -0,0 +1,11 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include <sys/quota.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#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
|
||||
11
src/libc/sched.c
Normal file
11
src/libc/sched.c
Normal file
@@ -0,0 +1,11 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include <sched.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#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
|
||||
11
src/libc/signal.c
Normal file
11
src/libc/signal.c
Normal file
@@ -0,0 +1,11 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include <signal.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#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
|
||||
11
src/libc/stat.c
Normal file
11
src/libc/stat.c
Normal file
@@ -0,0 +1,11 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#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
|
||||
25
src/libc/unistd.c
Normal file
25
src/libc/unistd.c
Normal file
@@ -0,0 +1,25 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#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
|
||||
17
src/libc/xattr.c
Normal file
17
src/libc/xattr.c
Normal file
@@ -0,0 +1,17 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/xattr.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#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
|
||||
@@ -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,
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <security/pam_modutil.h>
|
||||
|
||||
#include "keyring-util.h"
|
||||
#include "missing_syscall.h"
|
||||
#include "nulstr-util.h"
|
||||
#include "pam-util.h"
|
||||
#include "string-util.h"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/keyctl.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/personality.h>
|
||||
#include <sys/prctl.h>
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -26,6 +26,7 @@ executables += [
|
||||
'sources' : files('repart.c'),
|
||||
'c_args' : '-DSTANDALONE',
|
||||
'link_with' : [
|
||||
libc_wrapper_static,
|
||||
libbasic_static,
|
||||
libshared_fdisk,
|
||||
libshared_static,
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <linux/bpf.h>
|
||||
#include <linux/bpf_insn.h>
|
||||
#include <sys/bpf.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#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"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include <linux/ioprio.h> /* IWYU pragma: export */
|
||||
#include <sys/ioprio.h> /* IWYU pragma: export */
|
||||
|
||||
#include "forward.h"
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include <sys/mempolicy.h>
|
||||
|
||||
#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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -17,6 +17,7 @@ executables += [
|
||||
'sources' : files('sysusers.c'),
|
||||
'c_args' : '-DSTANDALONE',
|
||||
'link_with' : [
|
||||
libc_wrapper_static,
|
||||
libbasic_static,
|
||||
libshared_static,
|
||||
libsystemd_static,
|
||||
|
||||
@@ -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,
|
||||
],
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user