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
-1
View File
@@ -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"
+1 -1
View File
@@ -1,5 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <linux/magic.h>
#include <sys/vfs.h>
#include "binfmt-util.h"
@@ -8,7 +9,6 @@
#include "fileio.h"
#include "fs-util.h"
#include "log.h"
#include "missing_magic.h"
#include "stat-util.h"
int binfmt_mounted_and_writable(void) {
+1 -1
View File
@@ -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 -1
View File
@@ -1,5 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <linux/magic.h>
#include <unistd.h>
#include "cgroup-setup.h"
@@ -10,7 +11,6 @@
#include "format-util.h"
#include "fs-util.h"
#include "log.h"
#include "missing_magic.h"
#include "mkdir.h"
#include "parse-util.h"
#include "path-util.h"
+4 -2
View File
@@ -10,10 +10,12 @@ OVERRIDES = {
'autoneg' : 'autonegotiation',
}
mode, cpp, header = sys.argv[1:]
mode = sys.argv[1]
cpp = sys.argv[2]
include_dirs = sys.argv[3:]
xml = mode == '--xml'
command = [*shlex.split(cpp), '-include', header, '-']
command = [*shlex.split(cpp), '-include', 'linux/ethtool.h'] + include_dirs + ['-']
out = subprocess.check_output(command, stdin=subprocess.DEVNULL, universal_newlines=True)
lines = iter(out.splitlines())
+4 -1
View File
@@ -4,6 +4,9 @@
set -eu
set -o pipefail
${1:?} -dM -include netinet/in.h - </dev/null | \
CC=${1:?}
shift
$CC -dM -include netinet/in.h "$@" - </dev/null | \
awk '/^#define[ \t]+IPPROTO_[^ \t]+[ \t]+[^ \t]/ { print $2; }' | \
sed -e 's/IPPROTO_//'
+1 -1
View File
@@ -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"
+2 -1
View File
@@ -1,12 +1,13 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <linux/magic.h>
#include "sd-bus.h"
#include "btrfs-util.h"
#include "label-util.h"
#include "log.h"
#include "machine-pool.h"
#include "missing_magic.h"
#include "stat-util.h"
static int check_btrfs(void) {
+10 -7
View File
@@ -258,10 +258,11 @@ if conf.get('HAVE_PAM') == 1
shared_sources += files('pam-util.c')
endif
generate_ip_protocol_list = find_program('generate-ip-protocol-list.sh')
generate_ip_protocol_list = files('generate-ip-protocol-list.sh')
ip_protocol_list_txt = custom_target(
input : [generate_ip_protocol_list, ipproto_sources],
output : 'ip-protocol-list.txt',
command : [generate_ip_protocol_list, cpp],
command : [env, 'bash', generate_ip_protocol_list, cpp, system_include_args],
capture : true)
fname = 'ip-protocol-from-name.gperf'
@@ -294,11 +295,12 @@ target2 = custom_target(
generated_sources += [target1, target2]
shared_sources += [target1, target2]
ethtool_link_mode_py = files('ethtool-link-mode.py')
fname = 'ethtool-link-mode.inc'
ethtool_link_mode_inc = custom_target(
input : ['ethtool-link-mode.py', '../basic/include/linux/ethtool.h'],
input : [ethtool_link_mode_py, ethtool_link_mode_sources],
output : fname,
command : [python, '@INPUT0@', '--header', cpp, '@INPUT1@'],
command : [python, ethtool_link_mode_py, '--header', cpp, system_include_args],
capture : true)
generated_sources += ethtool_link_mode_inc
@@ -307,9 +309,9 @@ sources += shared_sources
fname = 'ethtool-link-mode.xml'
ethtool_link_mode_xml = custom_target(
input : ['ethtool-link-mode.py', '../basic/include/linux/ethtool.h'],
input : [ethtool_link_mode_py, ethtool_link_mode_sources],
output : fname,
command : [python, '@INPUT0@', '--xml', cpp, '@INPUT1@'],
command : [python, ethtool_link_mode_py, '--xml', cpp, system_include_args],
capture : true)
man_page_depends += ethtool_link_mode_xml
@@ -358,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,
-1
View File
@@ -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"
-1
View File
@@ -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"
+2 -1
View File
@@ -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;
-1
View File
@@ -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) {
+5 -3
View File
@@ -1,10 +1,9 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <linux/reboot.h>
#include <stdint.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/reboot.h>
#include <sys/syscall.h>
#include <unistd.h>
#if HAVE_XENCTRL
@@ -20,13 +19,16 @@
#include "fileio.h"
#include "log.h"
#include "proc-cmdline.h"
#include "raw-reboot.h"
#include "reboot-util.h"
#include "string-util.h"
#include "umask-util.h"
#include "utf8.h"
#include "virt.h"
int raw_reboot(int cmd, const void *arg) {
return syscall(SYS_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, cmd, arg);
}
bool reboot_parameter_is_valid(const char *parameter) {
assert(parameter);
+8
View File
@@ -1,8 +1,16 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <linux/reboot.h> /* IWYU pragma: export */
#include <sys/reboot.h> /* IWYU pragma: export */
#include "forward.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. */
int raw_reboot(int cmd, const void *arg);
bool reboot_parameter_is_valid(const char *parameter);
int update_reboot_parameter_and_warn(const char *parameter, bool keep);
+2 -3
View File
@@ -1,13 +1,12 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <linux/btrfs.h>
#include <linux/fs.h>
#include <linux/magic.h>
#include <linux/xfs.h>
#include <sys/ioctl.h>
#include <sys/vfs.h>
#include "missing_fs.h"
#include "missing_magic.h"
#include "missing_xfs.h"
#include "resize-fs.h"
#include "stat-util.h"
#include "stdio-util.h"
+1 -1
View File
@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <fcntl.h>
#include <linux/magic.h>
#include <unistd.h>
#include "alloc-util.h"
@@ -10,7 +11,6 @@
#include "fd-util.h"
#include "fs-util.h"
#include "log.h"
#include "missing_magic.h"
#include "mountpoint-util.h"
#include "path-util.h"
#include "rm-rf.h"
+1 -1
View File
@@ -1,5 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <linux/magic.h>
#include <sys/statvfs.h>
#include <unistd.h>
@@ -10,7 +11,6 @@
#include "fileio.h"
#include "fs-util.h"
#include "log.h"
#include "missing_magic.h"
#include "shift-uid.h"
#include "stat-util.h"
#include "string-util.h"
-1
View File
@@ -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"