Cleanups for missing_xyz.h headers (#37904)

Continuation of #37960.

The same concern as expalined in #37960 exists also in
missing_syscall.h. If we use enough new glibc, a function we want to use
may be already provided by glibc, but our baseline glibc may not. And it
is hard to detect in our daily development.

This moves all prototypes of syscalls to relevant headers, and missing
syscall functions are defined in relevant .c files of libc wrapper. This
way, we can use usual header as is, e.g. when we want to write code with
`move_mount()`, we can simply use sys/mount.h without checking if it is
supported by our baseline glibc.
This commit is contained in:
Yu Watanabe
2025-07-11 15:20:10 +09:00
committed by GitHub
250 changed files with 987 additions and 753 deletions

View File

@@ -41,7 +41,7 @@ jobs:
- uses: systemd/mkosi@184472f0f1f831ca29953546ec01fd941ff763a6
- name: Check that tabs are not used in Python code
run: sh -c '! git grep -P "\\t" -- src/basic/generate-bpf-delegate-configs.py src/boot/generate-hwids-section.py src/ukify/ukify.py test/integration-tests/integration-test-wrapper.py'
run: sh -c '! git grep -P "\\t" -- src/core/generate-bpf-delegate-configs.py src/boot/generate-hwids-section.py src/ukify/ukify.py test/integration-tests/integration-test-wrapper.py'
- name: Build tools tree
run: |
@@ -56,20 +56,20 @@ jobs:
- name: Run mypy
run: |
mkosi box -- mypy --version
mkosi box -- mypy src/basic/generate-bpf-delegate-configs.py src/boot/generate-hwids-section.py src/test/generate-sym-test.py src/ukify/ukify.py test/integration-tests/integration-test-wrapper.py
mkosi box -- mypy src/core/generate-bpf-delegate-configs.py src/boot/generate-hwids-section.py src/test/generate-sym-test.py src/ukify/ukify.py test/integration-tests/integration-test-wrapper.py
- name: Run ruff check
run: |
mkosi box -- ruff --version
mkosi box -- ruff check src/basic/generate-bpf-delegate-configs.py src/boot/generate-hwids-section.py src/test/generate-sym-test.py src/ukify/ukify.py test/integration-tests/integration-test-wrapper.py
mkosi box -- ruff check src/core/generate-bpf-delegate-configs.py src/boot/generate-hwids-section.py src/test/generate-sym-test.py src/ukify/ukify.py test/integration-tests/integration-test-wrapper.py
- name: Run ruff format
run: |
mkosi box -- ruff --version
if ! mkosi box -- ruff format --check src/basic/generate-bpf-delegate-configs.py src/boot/generate-hwids-section.py src/test/generate-sym-test.py src/ukify/ukify.py test/integration-tests/integration-test-wrapper.py
if ! mkosi box -- ruff format --check src/core/generate-bpf-delegate-configs.py src/boot/generate-hwids-section.py src/test/generate-sym-test.py src/ukify/ukify.py test/integration-tests/integration-test-wrapper.py
then
echo "Please run 'ruff format' on the above files or apply the diffs below manually"
mkosi box -- ruff format --check --quiet --diff src/basic/generate-bpf-delegate-configs.py src/boot/generate-hwids-section.py src/test/generate-sym-test.py src/ukify/ukify.py test/integration-tests/integration-test-wrapper.py
mkosi box -- ruff format --check --quiet --diff src/core/generate-bpf-delegate-configs.py src/boot/generate-hwids-section.py src/test/generate-sym-test.py src/ukify/ukify.py test/integration-tests/integration-test-wrapper.py
fi
- name: Configure meson

View File

@@ -20,6 +20,9 @@ There are many, and more are constantly added, so we will not enumerate them all
The code that is shared between components is split into a few directories, each with a different purpose:
- 'src/include/uapi/' contains copy of kernel headers we use.
'src/include/override/' contains wrappers for libc and kernel headers, to provide several missing symbols.
- `src/basic/` and `src/fundamental/` — those directories contain code primitives that are used by all other code.
`src/fundamental/` is stricter, because it used for EFI and user-space code, while `src/basic/` is only used for user-space code.
The code in `src/fundamental/` cannot depend on any other code in the tree, and `src/basic/` can depend only on itself and `src/fundamental/`.
@@ -43,6 +46,12 @@ Any code that is used only for EFI goes under `src/boot/efi/`, and `src/fundamen
To summarize:
`src/include/uapi/`
- copy of kernel headers
`src/include/override/`
- wrappers for libc and kernel headers
`src/fundamental/`
- may be used by all code in the tree
- may not use any code outside of `src/fundamental/`

View File

@@ -20,9 +20,10 @@ xsltproc_flags = [
'--stringparam', 'man.copyright.section.enabled', '0',
'--stringparam', 'systemd.version', '@0@'.format(meson.project_version()),
'--path',
'@0@:@1@:@2@'.format(meson.current_build_dir(),
'@0@:@1@:@2@:@3@'.format(meson.current_build_dir(),
meson.current_source_dir(),
libshared_build_dir)]
libshared_build_dir,
libcore_build_dir)]
custom_man_xsl = files('custom-man.xsl')
custom_html_xsl = files('custom-html.xsl')
@@ -35,17 +36,6 @@ custom_entities_ent = custom_target(
man_page_depends += custom_entities_ent
generate_bpf_delegate_configs = find_program('../src/basic/generate-bpf-delegate-configs.py')
bpf_delegate_xml = custom_target(
input : files('../src/basic/include/linux/bpf.h'),
output : 'bpf-delegate.xml',
command : [generate_bpf_delegate_configs,
'doc',
'@INPUT@'],
capture : true)
man_page_depends += bpf_delegate_xml
man_pages = []
html_pages = []
source_xml_files = []

View File

@@ -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')
@@ -2008,16 +2009,33 @@ dbus_programs = []
# A list of boot stubs. Required for testing of ukify.
boot_stubs = []
# This is similar to system_includes below, but for passing custom_target().
system_include_args = [
'-isystem', meson.project_build_root() / 'src/include/override',
'-isystem', meson.project_source_root() / 'src/include/override',
'-isystem', meson.project_build_root() / 'src/include/uapi',
'-isystem', meson.project_source_root() / 'src/include/uapi',
]
system_includes = [
include_directories(
# gcc(1) says
# "Directories specified with -isystem options are scanned in left-to-right order",
# and meson puts the directories in the reversed order. Hence, a directory with a lower
# priority must be listed earlier.
'src/include/uapi',
'src/include/override',
is_system : true,
),
]
basic_includes = [
include_directories(
'src/basic',
'src/fundamental',
'src/systemd',
),
include_directories(
'src/basic/include',
is_system : true,
),
system_includes,
version_include,
]
@@ -2039,6 +2057,8 @@ 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')
@@ -2054,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,
@@ -2067,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,
@@ -2112,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,
@@ -2216,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,

View File

@@ -1,5 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <linux/fs.h>
#include <linux/magic.h>
#include <signal.h>
#include <stdlib.h>
#include <sys/xattr.h>
@@ -18,8 +20,6 @@
#include "fs-util.h"
#include "log.h"
#include "login-util.h"
#include "missing_fs.h"
#include "missing_magic.h"
#include "parse-util.h"
#include "path-util.h"
#include "pidref.h"

View File

@@ -3,19 +3,14 @@
set -eu
set -o pipefail
cpp="$1"
filesystems_gperf="$2"
cpp="${1:?}"
filesystems_gperf="${2:?}"
shift 2
includes=""
for i in "$@"; do
includes="$includes -include $i"
done
error=false
# shellcheck disable=SC2086
for fs in $($cpp -dM $includes - </dev/null | \
for fs in $($cpp -dM -include linux/magic.h "$@" - </dev/null | \
grep -E '_MAGIC' | \
grep -vE 'LINUX_MAGIC' | \
awk '/^#define[ \t]+[A-Z0-9_]+MAGIC[ \t]+/ { print $2; }'); do

View File

@@ -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"

View File

@@ -6,7 +6,6 @@ _Pragma("GCC diagnostic ignored \"-Wzero-as-null-pointer-constant\"")
#include <linux/magic.h>
#include "filesystems.h"
#include "missing_magic.h"
#include "stat-util.h"
struct FilesystemMagic {

View File

@@ -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"

View File

@@ -3,6 +3,9 @@
set -eu
set -o pipefail
${1:?} -E -dM -include sys/socket.h -include "${2:?}" - </dev/null | \
CC=${1:?}
shift
$CC -E -dM -include sys/socket.h "$@" - </dev/null | \
grep -Ev 'AF_UNSPEC|AF_MAX' | \
awk '/^#define[ \t]+AF_[^ \t]+[ \t]+[AP]F_[^ \t]/ { print $2; }'

View File

@@ -3,6 +3,9 @@
set -eu
set -o pipefail
${1:?} -dM -include "${2:?}" - </dev/null | \
CC=${1:?}
shift
$CC -dM -include linux/if_arp.h "$@" - </dev/null | \
awk '/^#define[ \t]+ARPHRD_[^ \t]+[ \t]+[^ \t]/ { print $2; }' | \
sed -e 's/ARPHRD_//'

View File

@@ -3,6 +3,9 @@
set -eu
set -o pipefail
${1:?} -dM -include "${2:?}" - </dev/null | \
CC=${1:?}
shift
$CC -dM -include linux/capability.h "$@" - </dev/null | \
awk '/^#define[ \t]+CAP_[A-Z_]+[ \t]+/ { print $2; }' | \
grep -v CAP_LAST_CAP

View File

@@ -6,6 +6,9 @@ set -o pipefail
# In kernel's arch/parisc/include/uapi/asm/errno.h, ECANCELLED and EREFUSED are defined as aliases of
# ECANCELED and ECONNREFUSED, respectively. Let's drop them.
${1:?} -dM -include errno.h - </dev/null | \
CC=${1:?}
shift
$CC -dM -include errno.h "$@" - </dev/null | \
grep -Ev '^#define[[:space:]]+(ECANCELLED|EREFUSED)' | \
awk '/^#define[ \t]+E[^ _]+[ \t]+/ { print $2; }'

View File

@@ -1,8 +0,0 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
/* To make struct xattr_args defined, which is used by setxattrat(). Note, the kernel header must be
* included before the glibc header, otherwise the struct will not be defined. */
#include <linux/xattr.h>
#include_next <sys/xattr.h>

View File

@@ -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;

View File

@@ -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)

View File

@@ -84,6 +84,7 @@ basic_sources = files(
'psi-util.c',
'random-util.c',
'ratelimit.c',
'raw-clone.c',
'recurse-dir.c',
'replace-var.c',
'rlimit-util.c',
@@ -119,44 +120,26 @@ basic_sources = files(
sources += basic_sources
missing_audit_h = files('missing_audit.h')
missing_syscall_def_h = files('missing_syscall_def.h')
basic_sources += missing_syscall_def_h
generate_af_list = find_program('generate-af-list.sh')
af_list_txt = custom_target(
output : 'af-list.txt',
command : [generate_af_list, cpp, files('include/sys/socket.h')],
capture : true)
generate_arphrd_list = find_program('generate-arphrd-list.sh')
arphrd_list_txt = custom_target(
output : 'arphrd-list.txt',
command : [generate_arphrd_list, cpp, files('include/linux/if_arp.h')],
capture : true)
generate_cap_list = find_program('generate-cap-list.sh')
cap_list_txt = custom_target(
output : 'cap-list.txt',
command : [generate_cap_list, cpp, files('include/linux/capability.h')],
capture : true)
generate_errno_list = find_program('generate-errno-list.sh')
errno_list_txt = custom_target(
output : 'errno-list.txt',
command : [generate_errno_list, cpp],
capture : true)
generated_gperf_headers = []
foreach item : [['af', af_list_txt, 'af', '', ['<sys/socket.h>']],
['arphrd', arphrd_list_txt, 'arphrd', 'ARPHRD_', []],
['cap', cap_list_txt, 'capability', '', []],
['errno', errno_list_txt, 'errno', '', []]]
foreach item : [
# name, source, struct name, prefix, headers
['af', af_sources, 'af', '', ['<sys/socket.h>'], ],
['arphrd', arphrd_sources, 'arphrd', 'ARPHRD_', ['<linux/if_arp.h>'], ],
['cap', cap_sources, 'capability', '', ['<linux/capability.h>'], ],
['errno', [], 'errno', '', ['<errno.h>'], ],
]
fname = '@0@-list.txt'.format(item[0])
generate_list = files('generate-@0@-list.sh'.format(item[0]))
list_txt = custom_target(
input : [generate_list, item[1]],
output : fname,
command : [env, 'bash', generate_list, cpp, system_include_args],
capture : true)
fname = '@0@-from-name.gperf'.format(item[0])
gperf_file = custom_target(
input : item[1],
input : list_txt,
output : fname,
command : [generate_gperfs, item[2], item[3], '@INPUT@'] + item[4],
capture : true)
@@ -176,7 +159,7 @@ foreach item : [['af', af_list_txt, 'af', '', ['<sys/sock
fname = '@0@-to-name.inc'.format(item[0])
awkscript = '@0@-to-name.awk'.format(item[0])
target2 = custom_target(
input : [awkscript, item[1]],
input : [awkscript, list_txt],
output : fname,
command : [awk, '-f', '@INPUT0@', '@INPUT1@'],
capture : true)
@@ -189,61 +172,13 @@ basic_sources += generated_gperf_headers
############################################################
arch_list = [
'alpha',
'arc',
'arm',
'arm64',
'i386',
'ia64',
'loongarch64',
'm68k',
'mips64',
'mips64n32',
'mipso32',
'parisc',
'powerpc',
'powerpc64',
'riscv32',
'riscv64',
's390',
's390x',
'sparc',
'x86_64'
]
run_target(
'update-syscall-tables',
command : [update_syscall_tables_sh, meson.current_source_dir()] + arch_list)
syscall_list_txt = files('syscall-list.txt')
syscall_lists = []
foreach arch: arch_list
syscall_lists += files('syscalls-@0@.txt'.format(arch))
endforeach
missing_syscalls_py = find_program('missing_syscalls.py')
run_target(
'update-syscall-header',
command : [missing_syscalls_py,
missing_syscall_def_h,
syscall_lists])
############################################################
filesystem_includes = files(
'include/linux/magic.h',
'missing_magic.h',
)
check_filesystems = find_program('check-filesystems.sh')
r = run_command(
[
'env', '--chdir', meson.project_build_root(),
check_filesystems, cpp, files('filesystems-gperf.gperf')
] + filesystem_includes,
check_filesystems, cpp, files('filesystems-gperf.gperf'),
system_include_args,
],
check: false,
)
if r.returncode() != 0
@@ -273,17 +208,8 @@ filesystem_switch_case_inc = custom_target(
'@INPUT@'],
capture : true)
generate_bpf_delegate_configs = find_program('generate-bpf-delegate-configs.py')
bpf_delegate_configs_inc = custom_target(
input : files('include/linux/bpf.h'),
output : 'bpf-delegate-configs.inc',
command : [generate_bpf_delegate_configs,
'code',
'@INPUT@'],
capture : true)
generated_sources += [filesystem_list_inc, filesystem_switch_case_inc, filesystems_gperf_h, bpf_delegate_configs_inc]
basic_sources += [filesystem_list_inc, filesystem_switch_case_inc, filesystems_gperf_h, bpf_delegate_configs_inc]
generated_sources += [filesystem_list_inc, filesystem_switch_case_inc, filesystems_gperf_h]
basic_sources += [filesystem_list_inc, filesystem_switch_case_inc, filesystems_gperf_h]
libbasic_static = static_library(
'basic',

View File

@@ -1,249 +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>
#ifdef ARCH_MIPS
#include <asm/sgidefs.h>
#endif
#include "forward.h"
#include "missing_keyctl.h"
#include "missing_syscall_def.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

View File

@@ -1,6 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <fcntl.h>
#include <linux/magic.h>
#include <linux/nsfs.h>
#include <sched.h>
#include <sys/ioctl.h>
#include <sys/mount.h>
@@ -10,8 +12,6 @@
#include "fd-util.h"
#include "fileio.h"
#include "log.h"
#include "missing_magic.h"
#include "missing_namespace.h"
#include "mountpoint-util.h"
#include "namespace-util.h"
#include "parse-util.h"

View File

@@ -1,5 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <linux/fs.h>
#include <linux/magic.h>
#include <sys/ioctl.h>
#include <threads.h>
#include <unistd.h>
@@ -7,8 +9,6 @@
#include "errno-util.h"
#include "fd-util.h"
#include "fileio.h"
#include "missing_fs.h"
#include "missing_magic.h"
#include "mountpoint-util.h"
#include "parse-util.h"
#include "pidfd-util.h"

View File

@@ -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);

View File

@@ -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"

84
src/basic/raw-clone.c Normal file
View File

@@ -0,0 +1,84 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/***
Copyright © 2016 Michael Karcher
***/
#include <errno.h>
#include <sched.h>
#include <sys/syscall.h>
#include <unistd.h>
#include "process-util.h"
#include "raw-clone.h"
/**
* raw_clone() - uses clone to create a new process with clone flags
* @flags: Flags to pass to the clone system call
*
* Uses the clone system call to create a new process with the cloning flags and termination signal passed in the flags
* parameter. Opposed to glibc's clone function, using this function does not set up a separate stack for the child, but
* relies on copy-on-write semantics on the one stack at a common virtual address, just as fork does.
*
* To obtain copy-on-write semantics, flags must not contain CLONE_VM, and thus CLONE_THREAD and CLONE_SIGHAND
* (which require CLONE_VM) are not usable.
*
* Additionally, as this function does not pass the ptid (pidfd in the case of CLONE_PIDFD), newtls and ctid
* parameters to the kernel, flags must not contain CLONE_PARENT_SETTID, CLONE_CHILD_SETTID, CLONE_CHILD_CLEARTID,
* CLONE_SETTLS, or CLONE_PIDFD.
*
* WARNING: 💣 this call (just like glibc's own clone() wrapper) will not synchronize on glibc's malloc
* locks, which means they will be in an undefined state in the child if the parent is
* threaded. This means: the parent must either never use threads, or the child cannot use memory
* allocation itself. This is a major pitfall, hence be careful! 💣
*
* Returns: 0 in the child process and the child process id in the parent.
*/
pid_t raw_clone(unsigned long flags) {
pid_t ret;
assert((flags & (CLONE_VM|CLONE_PARENT_SETTID|CLONE_CHILD_SETTID|CLONE_CHILD_CLEARTID|CLONE_SETTLS|CLONE_PIDFD)) == 0);
#if defined(__s390x__) || defined(__s390__) || defined(__CRIS__)
/* On s390/s390x and cris the order of the first and second arguments
* of the raw clone() system call is reversed. */
ret = (pid_t) syscall(__NR_clone, NULL, flags);
#elif defined(__sparc__)
{
/**
* sparc always returns the other process id in %o0, and
* a boolean flag whether this is the child or the parent in
* %o1. Inline assembly is needed to get the flag returned
* in %o1.
*/
int in_child, child_pid, error;
asm volatile("mov %3, %%g1\n\t"
"mov %4, %%o0\n\t"
"mov 0 , %%o1\n\t"
#if defined(__arch64__)
"t 0x6d\n\t"
#else
"t 0x10\n\t"
#endif
"addx %%g0, 0, %2\n\t"
"mov %%o1, %0\n\t"
"mov %%o0, %1" :
"=r"(in_child), "=r"(child_pid), "=r"(error) :
"i"(__NR_clone), "r"(flags) :
"%o1", "%o0", "%g1", "cc" );
if (error) {
errno = child_pid;
ret = -1;
} else
ret = in_child ? 0 : child_pid;
}
#else
ret = (pid_t) syscall(__NR_clone, flags, NULL);
#endif
if (ret == 0)
reset_cached_pid();
return ret;
}

View File

@@ -1,85 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
/***
Copyright © 2016 Michael Karcher
***/
#include <sched.h> /* IWYU pragma: export */
#include <errno.h>
#include <sched.h>
#include <sys/syscall.h>
#include "forward.h"
#include "log.h"
#include "macro.h"
#include "process-util.h"
/**
* raw_clone() - uses clone to create a new process with clone flags
* @flags: Flags to pass to the clone system call
*
* Uses the clone system call to create a new process with the cloning flags and termination signal passed in the flags
* parameter. Opposed to glibc's clone function, using this function does not set up a separate stack for the child, but
* relies on copy-on-write semantics on the one stack at a common virtual address, just as fork does.
*
* To obtain copy-on-write semantics, flags must not contain CLONE_VM, and thus CLONE_THREAD and CLONE_SIGHAND
* (which require CLONE_VM) are not usable.
*
* Additionally, as this function does not pass the ptid (pidfd in the case of CLONE_PIDFD), newtls and ctid
* parameters to the kernel, flags must not contain CLONE_PARENT_SETTID, CLONE_CHILD_SETTID, CLONE_CHILD_CLEARTID,
* CLONE_SETTLS, or CLONE_PIDFD.
*
* WARNING: 💣 this call (just like glibc's own clone() wrapper) will not synchronize on glibc's malloc
* locks, which means they will be in an undefined state in the child if the parent is
* threaded. This means: the parent must either never use threads, or the child cannot use memory
* allocation itself. This is a major pitfall, hence be careful! 💣
*
* Returns: 0 in the child process and the child process id in the parent.
*/
static inline pid_t raw_clone(unsigned long flags) {
pid_t ret;
assert((flags & (CLONE_VM|CLONE_PARENT_SETTID|CLONE_CHILD_SETTID|CLONE_CHILD_CLEARTID|CLONE_SETTLS|CLONE_PIDFD)) == 0);
#if defined(__s390x__) || defined(__s390__) || defined(__CRIS__)
/* On s390/s390x and cris the order of the first and second arguments
* of the raw clone() system call is reversed. */
ret = (pid_t) syscall(__NR_clone, NULL, flags);
#elif defined(__sparc__)
{
/**
* sparc always returns the other process id in %o0, and
* a boolean flag whether this is the child or the parent in
* %o1. Inline assembly is needed to get the flag returned
* in %o1.
*/
int in_child, child_pid, error;
asm volatile("mov %3, %%g1\n\t"
"mov %4, %%o0\n\t"
"mov 0 , %%o1\n\t"
#if defined(__arch64__)
"t 0x6d\n\t"
#else
"t 0x10\n\t"
#endif
"addx %%g0, 0, %2\n\t"
"mov %%o1, %0\n\t"
"mov %%o0, %1" :
"=r"(in_child), "=r"(child_pid), "=r"(error) :
"i"(__NR_clone), "r"(flags) :
"%o1", "%o0", "%g1", "cc" );
if (error) {
errno = child_pid;
ret = -1;
} else
ret = in_child ? 0 : child_pid;
}
#else
ret = (pid_t) syscall(__NR_clone, flags, NULL);
#endif
if (ret == 0)
reset_cached_pid();
return ret;
}
pid_t raw_clone(unsigned long flags);

View File

@@ -1,15 +0,0 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <linux/reboot.h>
#include <sys/reboot.h>
#include <sys/syscall.h>
#include <unistd.h>
/* glibc defines the reboot() API call, which is a wrapper around the system call of the same name, but without the
* extra "arg" parameter. Since we need that parameter for some calls, let's add a "raw" wrapper that is defined the
* same way, except it takes the additional argument. */
static inline int raw_reboot(int cmd, const void *arg) {
return (int) syscall(SYS_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, cmd, arg);
}

View File

@@ -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"

View File

@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <fcntl.h>
#include <linux/magic.h>
#include <sys/statvfs.h>
#include <unistd.h>
@@ -13,7 +14,6 @@
#include "fs-util.h"
#include "hash-funcs.h"
#include "log.h"
#include "missing_magic.h"
#include "mountpoint-util.h"
#include "path-util.h"
#include "siphash24.h"

View File

@@ -2,6 +2,7 @@
#include <fcntl.h>
#include <linux/kd.h>
#include <linux/magic.h>
#include <linux/tiocl.h>
#include <linux/vt.h>
#include <poll.h>
@@ -27,7 +28,6 @@
#include "inotify-util.h"
#include "io-util.h"
#include "log.h"
#include "missing_magic.h"
#include "namespace-util.h"
#include "parse-util.h"
#include "path-util.h"

View File

@@ -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"

View File

@@ -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"

View File

@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <linux/bpf.h>
#include <linux/magic.h>
#include "alloc-util.h"
#include "bpf-foreign.h"
@@ -8,7 +9,6 @@
#include "cgroup.h"
#include "hash-funcs.h"
#include "hashmap.h"
#include "missing_magic.h"
#include "siphash24.h"
#include "stat-util.h"
#include "unit.h"

View File

@@ -1,12 +1,10 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <sys/reboot.h>
#include <unistd.h>
#include "ansi-color.h"
#include "emergency-action.h"
#include "manager.h"
#include "raw-reboot.h"
#include "reboot-util.h"
#include "special.h"
#include "string-table.h"

View File

@@ -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"

View File

@@ -100,15 +100,34 @@ load_fragment_gperf_nulstr_c = custom_target(
command : [awk, '-f', '@INPUT0@', '@INPUT1@'],
capture : true)
generated_sources += [load_fragment_gperf_c, load_fragment_gperf_nulstr_c]
generate_bpf_delegate_configs = files('generate-bpf-delegate-configs.py')
bpf_delegate_configs_inc = custom_target(
input : [generate_bpf_delegate_configs, bpf_delegate_sources],
output : 'bpf-delegate-configs.inc',
command : [python,
generate_bpf_delegate_configs,
'code',
bpf_delegate_sources],
capture : true)
bpf_delegate_xml = custom_target(
input : [generate_bpf_delegate_configs, bpf_delegate_sources],
output : 'bpf-delegate.xml',
command : [python,
generate_bpf_delegate_configs,
'doc',
bpf_delegate_sources],
capture : true)
man_page_depends += bpf_delegate_xml
generated_sources += [load_fragment_gperf_c, load_fragment_gperf_nulstr_c, bpf_delegate_configs_inc]
libcore_sources += [load_fragment_gperf_c, load_fragment_gperf_nulstr_c, bpf_delegate_configs_inc]
libcore_build_dir = meson.current_build_dir()
libcore_name = 'systemd-core-@0@'.format(shared_lib_tag)
libcore_static = static_library(
libcore_name,
libcore_sources,
load_fragment_gperf_c,
load_fragment_gperf_nulstr_c,
include_directories : [includes, include_directories('.')],
implicit_include_directories : false,
c_args : ['-fvisibility=default'],
@@ -162,6 +181,7 @@ executor_libs = get_option('link-executor-shared') ? \
libcore,
libshared,
] : [
libc_wrapper_static,
libcore_static,
libshared_static,
libbasic_static,

View File

@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <linux/loop.h>
#include <linux/magic.h>
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
@@ -29,7 +30,6 @@
#include "log.h"
#include "loop-util.h"
#include "loopback-setup.h"
#include "missing_magic.h"
#include "mkdir-label.h"
#include "mount-util.h"
#include "mountpoint-util.h"

View File

@@ -1,5 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <linux/audit.h>
#include <math.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -31,7 +32,6 @@
#include "image-policy.h"
#include "log.h"
#include "manager.h"
#include "missing_audit.h"
#include "mount-util.h"
#include "namespace.h"
#include "open-file.h"

View File

@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <getopt.h>
#include <linux/magic.h>
#include <unistd.h>
#include "sd-json.h"
@@ -23,7 +24,6 @@
#include "log.h"
#include "main-func.h"
#include "memory-util.h"
#include "missing_magic.h"
#include "pager.h"
#include "parse-argument.h"
#include "parse-util.h"

View File

@@ -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"

View File

@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <linux/loop.h>
#include <linux/magic.h>
#include <poll.h>
#include <sys/file.h>
#include <sys/ioctl.h>
@@ -45,8 +46,6 @@
#include "keyring-util.h"
#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"

View File

@@ -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"

View File

@@ -1,5 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <linux/magic.h>
#include "btrfs-util.h"
#include "errno-util.h"
#include "fd-util.h"
@@ -7,7 +9,6 @@
#include "homework-quota.h"
#include "log.h"
#include "memory-util.h"
#include "missing_magic.h"
#include "quota-util.h"
#include "stat-util.h"
#include "user-record.h"

View File

@@ -1,5 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <linux/magic.h>
#include <stdlib.h>
#include <sys/mount.h>
#include <unistd.h>
@@ -35,8 +36,6 @@
#include "loop-util.h"
#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"

View File

@@ -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 {

45
src/include/meson.build Normal file
View File

@@ -0,0 +1,45 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
subdir('override/sys')
# Source files that provides AF_XYZ
af_sources = files(
'override/sys/socket.h',
)
# Source files that provides ARPHRD_XYZ
arphrd_sources = files(
'uapi/linux/if_arp.h',
)
# Source files that provides CAP_XYZ
cap_sources = files(
'uapi/linux/capability.h',
)
# Source files that provides BPF delegate options
bpf_delegate_sources = files(
'uapi/linux/bpf.h',
)
# Source files that provides ETHTOOL_LINK_MODE_XYZ
ethtool_link_mode_sources = files(
'uapi/linux/ethtool.h',
)
# Source files that provides IPPROTO_XYZ
ipproto_sources = files(
'override/netinet/in.h',
'uapi/linux/in.h',
)
# Source files that provides AUDIT_XYZ
audit_sources = files(
'override/linux/audit.h',
)
# Source files that provides KEY_XYZ
keyboard_sources = files(
'uapi/linux/input.h',
'uapi/linux/input-event-codes.h',
)

View File

@@ -1,13 +1,15 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <linux/audit.h> /* IWYU pragma: export */
#include_next <linux/audit.h> /* IWYU pragma: export */
#if HAVE_AUDIT
# include <libaudit.h> /* IWYU pragma: export */
#endif
/* We use _Static_assert() directly here instead of assert_cc()
#include <assert.h>
/* We use static_assert() directly here instead of assert_cc()
* because if we include macro.h in this header, the invocation
* of generate-audit_type-list.sh becomes more complex.
*/
@@ -15,17 +17,17 @@
#ifndef AUDIT_SERVICE_START
# define AUDIT_SERVICE_START 1130 /* Service (daemon) start */
#else
_Static_assert(AUDIT_SERVICE_START == 1130, "");
static_assert(AUDIT_SERVICE_START == 1130, "");
#endif
#ifndef AUDIT_SERVICE_STOP
# define AUDIT_SERVICE_STOP 1131 /* Service (daemon) stop */
#else
_Static_assert(AUDIT_SERVICE_STOP == 1131, "");
static_assert(AUDIT_SERVICE_STOP == 1131, "");
#endif
#ifndef MAX_AUDIT_MESSAGE_LENGTH
# define MAX_AUDIT_MESSAGE_LENGTH 8970
#else
_Static_assert(MAX_AUDIT_MESSAGE_LENGTH == 8970, "");
static_assert(MAX_AUDIT_MESSAGE_LENGTH == 8970, "");
#endif

View File

@@ -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 */

View File

@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <linux/fs.h> /* IWYU pragma: export */
#include_next <linux/fs.h> /* IWYU pragma: export */
/* Not exposed yet. Defined at fs/ext4/ext4.h */
#ifndef EXT4_IOC_RESIZE_FS

View File

@@ -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

View File

@@ -1,102 +1,104 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <linux/magic.h> /* IWYU pragma: export */
#include_next <linux/magic.h> /* IWYU pragma: export */
#include <assert.h>
/* Not exposed yet (4.20). Defined at ipc/mqueue.c */
#ifndef MQUEUE_MAGIC
# define MQUEUE_MAGIC 0x19800202
#else
assert_cc(MQUEUE_MAGIC == 0x19800202);
static_assert(MQUEUE_MAGIC == 0x19800202, "");
#endif
/* b1123ea6d3b3da25af5c8a9d843bd07ab63213f4 (4.8), dropped by 68f2736a858324c3ec852f6c2cddd9d1c777357d (v6.0) */
#ifndef BALLOON_KVM_MAGIC
# define BALLOON_KVM_MAGIC 0x13661366
#else
assert_cc(BALLOON_KVM_MAGIC == 0x13661366);
static_assert(BALLOON_KVM_MAGIC == 0x13661366, "");
#endif
/* 48b4800a1c6af2cdda344ea4e2c843dcc1f6afc9 (4.8), dropped by 68f2736a858324c3ec852f6c2cddd9d1c777357d (v6.0) */
#ifndef ZSMALLOC_MAGIC
# define ZSMALLOC_MAGIC 0x58295829
#else
assert_cc(ZSMALLOC_MAGIC == 0x58295829);
static_assert(ZSMALLOC_MAGIC == 0x58295829, "");
#endif
/* ea8157ab2ae5e914dd427e5cfab533b6da3819cd (5.3), dropped by 68f2736a858324c3ec852f6c2cddd9d1c777357d (v6.0) */
#ifndef Z3FOLD_MAGIC
# define Z3FOLD_MAGIC 0x33
#else
assert_cc(Z3FOLD_MAGIC == 0x33);
static_assert(Z3FOLD_MAGIC == 0x33, "");
#endif
/* fe030c9b85e6783bc52fe86449c0a4b8aa16c753 (5.5), dropped by 68f2736a858324c3ec852f6c2cddd9d1c777357d (v6.0) */
#ifndef PPC_CMM_MAGIC
# define PPC_CMM_MAGIC 0xc7571590
#else
assert_cc(PPC_CMM_MAGIC == 0xc7571590);
static_assert(PPC_CMM_MAGIC == 0xc7571590, "");
#endif
/* Not in mainline but included in Ubuntu */
#ifndef SHIFTFS_MAGIC
# define SHIFTFS_MAGIC 0x6a656a62
#else
assert_cc(SHIFTFS_MAGIC == 0x6a656a62);
static_assert(SHIFTFS_MAGIC == 0x6a656a62, "");
#endif
/* Not exposed yet. Defined at fs/fuse/control.c */
#ifndef FUSE_CTL_SUPER_MAGIC
# define FUSE_CTL_SUPER_MAGIC 0x65735543
#else
assert_cc(FUSE_CTL_SUPER_MAGIC == 0x65735543);
static_assert(FUSE_CTL_SUPER_MAGIC == 0x65735543, "");
#endif
/* Not exposed yet. Defined at fs/orangefs/orangefs-kernel.h */
#ifndef ORANGEFS_DEVREQ_MAGIC
# define ORANGEFS_DEVREQ_MAGIC 0x20030529
#else
assert_cc(ORANGEFS_DEVREQ_MAGIC == 0x20030529);
static_assert(ORANGEFS_DEVREQ_MAGIC == 0x20030529, "");
#endif
/* linux/gfs2_ondisk.h */
#ifndef GFS2_MAGIC
# define GFS2_MAGIC 0x01161970
#else
assert_cc(GFS2_MAGIC == 0x01161970);
static_assert(GFS2_MAGIC == 0x01161970, "");
#endif
/* Not exposed yet. Defined at fs/configfs/mount.c */
#ifndef CONFIGFS_MAGIC
# define CONFIGFS_MAGIC 0x62656570
#else
assert_cc(CONFIGFS_MAGIC == 0x62656570);
static_assert(CONFIGFS_MAGIC == 0x62656570, "");
#endif
/* Not exposed yet. Defined at fs/vboxsf/super.c */
#ifndef VBOXSF_SUPER_MAGIC
# define VBOXSF_SUPER_MAGIC 0x786f4256
#else
assert_cc(VBOXSF_SUPER_MAGIC == 0x786f4256);
static_assert(VBOXSF_SUPER_MAGIC == 0x786f4256, "");
#endif
/* Not exposed yet, internally actually called RPCAUTH_GSSMAGIC. Defined in net/sunrpc/rpc_pipe.c */
#ifndef RPC_PIPEFS_SUPER_MAGIC
# define RPC_PIPEFS_SUPER_MAGIC 0x67596969
#else
assert_cc(RPC_PIPEFS_SUPER_MAGIC == 0x67596969);
static_assert(RPC_PIPEFS_SUPER_MAGIC == 0x67596969, "");
#endif
/* Not exposed yet, defined at fs/ntfs/ntfs.h */
#ifndef NTFS_SB_MAGIC
# define NTFS_SB_MAGIC 0x5346544e
#else
assert_cc(NTFS_SB_MAGIC == 0x5346544e);
static_assert(NTFS_SB_MAGIC == 0x5346544e, "");
#endif
/* Not exposed yet, encoded literally in fs/ntfs3/super.c. */
#ifndef NTFS3_SUPER_MAGIC
# define NTFS3_SUPER_MAGIC 0x7366746e
#else
assert_cc(NTFS3_SUPER_MAGIC == 0x7366746e);
static_assert(NTFS3_SUPER_MAGIC == 0x7366746e, "");
#endif

View File

@@ -1,8 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <linux/nsfs.h> /* IWYU pragma: export */
#include <linux/types.h>
#include_next <linux/nsfs.h> /* IWYU pragma: export */
/* Root namespace inode numbers, as per include/linux/proc_ns.h in the kernel source tree, since v3.8:
* https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=98f842e675f96ffac96e6c50315790912b2812be */

View File

@@ -1,7 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "forward.h"
#include <linux/ioctl.h>
#include <stdint.h>
/* This is currently not exported in the public kernel headers, but the libxfs library code part of xfsprogs
* defines it as public header */
@@ -22,10 +23,10 @@ typedef struct xfs_fsop_geom {
uint64_t rtblocks;
uint64_t rtextents;
uint64_t logstart;
unsigned char uuid[16];
uint8_t uuid[16];
uint32_t sunit;
uint32_t swidth;
int32_t version;
int32_t version;
uint32_t flags;
uint32_t logsectsize;
uint32_t rtsectsize;

View File

@@ -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

View 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

View 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

View File

@@ -33,6 +33,20 @@ def parse_syscall_tables(filenames):
return {filename.split('-')[-1][:-4]: parse_syscall_table(filename)
for filename in filenames}
HEADER = '''\
/* SPDX-License-Identifier: LGPL-2.1-or-later
* This file is generated by src/include/override/sys/generate-syscall.py. Do not edit!
*
* Use 'ninja -C build update-syscall-tables' to download new syscall tables,
* and 'ninja -C build update-syscall-header' to regenerate this file.
*/
#pragma once
#include_next <sys/syscall.h>
#include <assert.h>
'''
DEF_TEMPLATE_A = '''\
#ifndef __IGNORE_{syscall}
@@ -97,7 +111,7 @@ DEF_TEMPLATE_C = '''\
/* may be an (invalid) negative number due to libseccomp, see PR 13319 */
# if defined __NR_{syscall} && __NR_{syscall} >= 0
# if defined systemd_NR_{syscall}
_Static_assert(__NR_{syscall} == systemd_NR_{syscall}, "");
static_assert(__NR_{syscall} == systemd_NR_{syscall}, "");
# endif
# else
# if defined __NR_{syscall}
@@ -128,16 +142,7 @@ def print_syscall_def(syscall, tables, out):
file=out)
def print_syscall_defs(syscalls, tables, out):
print('''\
/* SPDX-License-Identifier: LGPL-2.1-or-later
* This file is generated by src/basic/missing_syscalls.py. Do not edit!
*
* Use 'ninja -C build update-syscall-tables' to download new syscall tables,
* and 'ninja -C build update-syscall-header' to regenerate this file.
*/
#pragma once
''',
file=out)
print(HEADER, file=out)
print(ARCH_CHECK, file=out)
for syscall in syscalls:
print_syscall_def(syscall, tables, out)

View 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

View 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

View 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

View 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

View File

@@ -0,0 +1,41 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
arch_list = [
'alpha',
'arc',
'arm',
'arm64',
'i386',
'ia64',
'loongarch64',
'm68k',
'mips64',
'mips64n32',
'mipso32',
'parisc',
'powerpc',
'powerpc64',
'riscv32',
'riscv64',
's390',
's390x',
'sparc',
'x86_64'
]
run_target(
'update-syscall-tables',
command : [update_syscall_tables_sh, meson.current_source_dir()] + arch_list)
syscall_list_txt = files('syscall-list.txt')
syscall_lists = []
foreach arch: arch_list
syscall_lists += files('syscalls-@0@.txt'.format(arch))
endforeach
generate_syscall_py = find_program('generate-syscall.py')
run_target(
'update-syscall-header',
command : [generate_syscall_py, files('syscall.h')] + syscall_lists)

View File

@@ -8,10 +8,6 @@
#include <stddef.h>
#include <stdint.h>
#include <sys/ioctl.h>
#include <sys/syscall.h>
#include <unistd.h>
#include "missing_syscall_def.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.
@@ -43,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
@@ -112,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

View File

@@ -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

View 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

View 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

View File

@@ -1,11 +1,15 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later
* This file is generated by src/basic/missing_syscalls.py. Do not edit!
* This file is generated by src/include/override/sys/generate-syscall.py. Do not edit!
*
* Use 'ninja -C build update-syscall-tables' to download new syscall tables,
* and 'ninja -C build update-syscall-header' to regenerate this file.
*/
#pragma once
#include_next <sys/syscall.h>
#include <assert.h>
/* Note: if this code looks strange, this is because it is derived from the same
* template as the per-syscall blocks below. */
# if defined(__aarch64__)
@@ -98,7 +102,7 @@
/* may be an (invalid) negative number due to libseccomp, see PR 13319 */
# if defined __NR_close_range && __NR_close_range >= 0
# if defined systemd_NR_close_range
_Static_assert(__NR_close_range == systemd_NR_close_range, "");
static_assert(__NR_close_range == systemd_NR_close_range, "");
# endif
# else
# if defined __NR_close_range
@@ -166,7 +170,7 @@ _Static_assert(__NR_close_range == systemd_NR_close_range, "");
/* may be an (invalid) negative number due to libseccomp, see PR 13319 */
# if defined __NR_fchmodat2 && __NR_fchmodat2 >= 0
# if defined systemd_NR_fchmodat2
_Static_assert(__NR_fchmodat2 == systemd_NR_fchmodat2, "");
static_assert(__NR_fchmodat2 == systemd_NR_fchmodat2, "");
# endif
# else
# if defined __NR_fchmodat2
@@ -234,7 +238,7 @@ _Static_assert(__NR_fchmodat2 == systemd_NR_fchmodat2, "");
/* may be an (invalid) negative number due to libseccomp, see PR 13319 */
# if defined __NR_mount_setattr && __NR_mount_setattr >= 0
# if defined systemd_NR_mount_setattr
_Static_assert(__NR_mount_setattr == systemd_NR_mount_setattr, "");
static_assert(__NR_mount_setattr == systemd_NR_mount_setattr, "");
# endif
# else
# if defined __NR_mount_setattr
@@ -246,6 +250,74 @@ _Static_assert(__NR_mount_setattr == systemd_NR_mount_setattr, "");
# endif
#endif
#ifndef __IGNORE_open_tree_attr
# if defined(__aarch64__)
# define systemd_NR_open_tree_attr 467
# elif defined(__alpha__)
# define systemd_NR_open_tree_attr 577
# elif defined(__arc__) || defined(__tilegx__)
# define systemd_NR_open_tree_attr 467
# elif defined(__arm__)
# define systemd_NR_open_tree_attr 467
# elif defined(__i386__)
# define systemd_NR_open_tree_attr 467
# elif defined(__ia64__)
# define systemd_NR_open_tree_attr -1
# elif defined(__loongarch_lp64)
# define systemd_NR_open_tree_attr 467
# elif defined(__m68k__)
# define systemd_NR_open_tree_attr 467
# elif defined(_MIPS_SIM)
# if _MIPS_SIM == _MIPS_SIM_ABI32
# define systemd_NR_open_tree_attr 4467
# elif _MIPS_SIM == _MIPS_SIM_NABI32
# define systemd_NR_open_tree_attr 6467
# elif _MIPS_SIM == _MIPS_SIM_ABI64
# define systemd_NR_open_tree_attr 5467
# else
# error "Unknown MIPS ABI"
# endif
# elif defined(__hppa__)
# define systemd_NR_open_tree_attr 467
# elif defined(__powerpc__)
# define systemd_NR_open_tree_attr 467
# elif defined(__riscv)
# if __riscv_xlen == 32
# define systemd_NR_open_tree_attr 467
# elif __riscv_xlen == 64
# define systemd_NR_open_tree_attr 467
# else
# error "Unknown RISC-V ABI"
# endif
# elif defined(__s390__)
# define systemd_NR_open_tree_attr 467
# elif defined(__sparc__)
# define systemd_NR_open_tree_attr 467
# elif defined(__x86_64__)
# if defined(__ILP32__)
# define systemd_NR_open_tree_attr (467 | /* __X32_SYSCALL_BIT */ 0x40000000)
# else
# define systemd_NR_open_tree_attr 467
# endif
# elif !defined(missing_arch_template)
# warning "open_tree_attr() syscall number is unknown for your architecture"
# endif
/* may be an (invalid) negative number due to libseccomp, see PR 13319 */
# if defined __NR_open_tree_attr && __NR_open_tree_attr >= 0
# if defined systemd_NR_open_tree_attr
static_assert(__NR_open_tree_attr == systemd_NR_open_tree_attr, "");
# endif
# else
# if defined __NR_open_tree_attr
# undef __NR_open_tree_attr
# endif
# if defined systemd_NR_open_tree_attr && systemd_NR_open_tree_attr >= 0
# define __NR_open_tree_attr systemd_NR_open_tree_attr
# endif
# endif
#endif
#ifndef __IGNORE_openat2
# if defined(__aarch64__)
# define systemd_NR_openat2 437
@@ -302,7 +374,7 @@ _Static_assert(__NR_mount_setattr == systemd_NR_mount_setattr, "");
/* may be an (invalid) negative number due to libseccomp, see PR 13319 */
# if defined __NR_openat2 && __NR_openat2 >= 0
# if defined systemd_NR_openat2
_Static_assert(__NR_openat2 == systemd_NR_openat2, "");
static_assert(__NR_openat2 == systemd_NR_openat2, "");
# endif
# else
# if defined __NR_openat2
@@ -370,7 +442,7 @@ _Static_assert(__NR_openat2 == systemd_NR_openat2, "");
/* may be an (invalid) negative number due to libseccomp, see PR 13319 */
# if defined __NR_quotactl_fd && __NR_quotactl_fd >= 0
# if defined systemd_NR_quotactl_fd
_Static_assert(__NR_quotactl_fd == systemd_NR_quotactl_fd, "");
static_assert(__NR_quotactl_fd == systemd_NR_quotactl_fd, "");
# endif
# else
# if defined __NR_quotactl_fd
@@ -438,7 +510,7 @@ _Static_assert(__NR_quotactl_fd == systemd_NR_quotactl_fd, "");
/* may be an (invalid) negative number due to libseccomp, see PR 13319 */
# if defined __NR_removexattrat && __NR_removexattrat >= 0
# if defined systemd_NR_removexattrat
_Static_assert(__NR_removexattrat == systemd_NR_removexattrat, "");
static_assert(__NR_removexattrat == systemd_NR_removexattrat, "");
# endif
# else
# if defined __NR_removexattrat
@@ -506,7 +578,7 @@ _Static_assert(__NR_removexattrat == systemd_NR_removexattrat, "");
/* may be an (invalid) negative number due to libseccomp, see PR 13319 */
# if defined __NR_setxattrat && __NR_setxattrat >= 0
# if defined systemd_NR_setxattrat
_Static_assert(__NR_setxattrat == systemd_NR_setxattrat, "");
static_assert(__NR_setxattrat == systemd_NR_setxattrat, "");
# endif
# else
# if defined __NR_setxattrat
@@ -517,71 +589,3 @@ _Static_assert(__NR_setxattrat == systemd_NR_setxattrat, "");
# endif
# endif
#endif
#ifndef __IGNORE_open_tree_attr
# if defined(__aarch64__)
# define systemd_NR_open_tree_attr 467
# elif defined(__alpha__)
# define systemd_NR_open_tree_attr 577
# elif defined(__arc__) || defined(__tilegx__)
# define systemd_NR_open_tree_attr 467
# elif defined(__arm__)
# define systemd_NR_open_tree_attr 467
# elif defined(__i386__)
# define systemd_NR_open_tree_attr 467
# elif defined(__ia64__)
# define systemd_NR_open_tree_attr -1
# elif defined(__loongarch_lp64)
# define systemd_NR_open_tree_attr 467
# elif defined(__m68k__)
# define systemd_NR_open_tree_attr 467
# elif defined(_MIPS_SIM)
# if _MIPS_SIM == _MIPS_SIM_ABI32
# define systemd_NR_open_tree_attr 4467
# elif _MIPS_SIM == _MIPS_SIM_NABI32
# define systemd_NR_open_tree_attr 6467
# elif _MIPS_SIM == _MIPS_SIM_ABI64
# define systemd_NR_open_tree_attr 5467
# else
# error "Unknown MIPS ABI"
# endif
# elif defined(__hppa__)
# define systemd_NR_open_tree_attr 467
# elif defined(__powerpc__)
# define systemd_NR_open_tree_attr 467
# elif defined(__riscv)
# if __riscv_xlen == 32
# define systemd_NR_open_tree_attr 467
# elif __riscv_xlen == 64
# define systemd_NR_open_tree_attr 467
# else
# error "Unknown RISC-V ABI"
# endif
# elif defined(__s390__)
# define systemd_NR_open_tree_attr 467
# elif defined(__sparc__)
# define systemd_NR_open_tree_attr 467
# elif defined(__x86_64__)
# if defined(__ILP32__)
# define systemd_NR_open_tree_attr (467 | /* __X32_SYSCALL_BIT */ 0x40000000)
# else
# define systemd_NR_open_tree_attr 467
# endif
# elif !defined(missing_arch_template)
# warning "open_tree_attr() syscall number is unknown for your architecture"
# endif
/* may be an (invalid) negative number due to libseccomp, see PR 13319 */
# if defined __NR_open_tree_attr && __NR_open_tree_attr >= 0
# if defined systemd_NR_open_tree_attr
_Static_assert(__NR_open_tree_attr == systemd_NR_open_tree_attr, "");
# endif
# else
# if defined __NR_open_tree_attr
# undef __NR_open_tree_attr
# endif
# if defined systemd_NR_open_tree_attr && systemd_NR_open_tree_attr >= 0
# define __NR_open_tree_attr systemd_NR_open_tree_attr
# endif
# endif
#endif

View File

@@ -0,0 +1,20 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
/* To make struct xattr_args defined, which is used by setxattrat(). Note, the kernel header must be
* included before the glibc header, otherwise the struct will not be defined. */
#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

View 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

Some files were not shown because too many files have changed in this diff Show More