missing.h revision bd1acc9f2ffa9c2baf1ddd6bb965352aef5c7446
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering This file is part of systemd.
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering Copyright 2010 Lennart Poettering
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering systemd is free software; you can redistribute it and/or modify it
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering under the terms of the GNU Lesser General Public License as published by
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering (at your option) any later version.
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering systemd is distributed in the hope that it will be useful, but
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering Lesser General Public License for more details.
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering You should have received a copy of the GNU Lesser General Public License
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering/* Missing glibc definitions to access certain kernel APIs */
a4152e3fe28b53b8919cc404dd7eca7ead1bf9bdLennart Poettering/* If RLIMIT_RTTIME is not defined, then we cannot use RLIMIT_NLIMITS as is */
a4152e3fe28b53b8919cc404dd7eca7ead1bf9bdLennart Poettering#define _RLIMIT_MAX (RLIMIT_RTTIME+1 > RLIMIT_NLIMITS ? RLIMIT_RTTIME+1 : RLIMIT_NLIMITS)
a4152e3fe28b53b8919cc404dd7eca7ead1bf9bdLennart Poettering#define F_SETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 7)
a4152e3fe28b53b8919cc404dd7eca7ead1bf9bdLennart Poettering#define F_GETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 8)
a4152e3fe28b53b8919cc404dd7eca7ead1bf9bdLennart Poettering#define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9)
a4152e3fe28b53b8919cc404dd7eca7ead1bf9bdLennart Poettering#define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10)
a4152e3fe28b53b8919cc404dd7eca7ead1bf9bdLennart Poettering#define F_SEAL_SEAL 0x0001 /* prevent further seals from being set */
a4152e3fe28b53b8919cc404dd7eca7ead1bf9bdLennart Poettering#define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */
a4152e3fe28b53b8919cc404dd7eca7ead1bf9bdLennart Poettering#define F_SEAL_GROW 0x0004 /* prevent file from growing */
a4152e3fe28b53b8919cc404dd7eca7ead1bf9bdLennart Poettering#define F_SEAL_WRITE 0x0008 /* prevent writes */
a4152e3fe28b53b8919cc404dd7eca7ead1bf9bdLennart Poettering#define AUDIT_SERVICE_START 1130 /* Service (daemon) start */
a4152e3fe28b53b8919cc404dd7eca7ead1bf9bdLennart Poettering#define AUDIT_SERVICE_STOP 1131 /* Service (daemon) stop */
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poetteringstatic inline int pivot_root(const char *new_root, const char *put_old) {
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering return syscall(SYS_pivot_root, new_root, put_old);
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering# warning "__NR_memfd_create unknown for your architecture"
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poetteringstatic inline int memfd_create(const char *name, unsigned int flags) {
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering return syscall(__NR_memfd_create, name, flags);
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering# warning "__NR_getrandom unknown for your architecture"
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poetteringstatic inline int getrandom(void *buffer, size_t count, unsigned flags) {
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering return syscall(__NR_getrandom, buffer, count, flags);
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering#define BTRFS_SEARCH_ARGS_BUFSIZE (4096 - sizeof(struct btrfs_ioctl_search_key))
a4152e3fe28b53b8919cc404dd7eca7ead1bf9bdLennart Poettering struct btrfs_qgroup_inherit *qgroup_inherit;
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering uint8_t uuid[BTRFS_UUID_SIZE]; /* in/out */
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering char path[BTRFS_DEVICE_PATH_NAME_MAX]; /* out */
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering /* which root are we searching. 0 is the tree of tree roots */
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering /* keys returned will be >= min and <= max */
a4152e3fe28b53b8919cc404dd7eca7ead1bf9bdLennart Poettering /* keys returned will be >= min and <= max */
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering /* max and min transids to search for */
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering /* keys returned will be >= min and <= max */
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering * how many items did userland ask for, and how many are we
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering /* align to 64 bits */
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering /* some extra for later */
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering#define BTRFS_IOC_DEFRAG _IOW(BTRFS_IOCTL_MAGIC, 2, \
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering#define BTRFS_IOC_CLONE _IOW(BTRFS_IOCTL_MAGIC, 9, int)
a4152e3fe28b53b8919cc404dd7eca7ead1bf9bdLennart Poettering#define BTRFS_IOC_CLONE_RANGE _IOW(BTRFS_IOCTL_MAGIC, 13, \
a4152e3fe28b53b8919cc404dd7eca7ead1bf9bdLennart Poettering#define BTRFS_IOC_SUBVOL_CREATE _IOW(BTRFS_IOCTL_MAGIC, 14, \
a4152e3fe28b53b8919cc404dd7eca7ead1bf9bdLennart Poettering#define BTRFS_IOC_SNAP_DESTROY _IOW(BTRFS_IOCTL_MAGIC, 15, \
a4152e3fe28b53b8919cc404dd7eca7ead1bf9bdLennart Poettering#define BTRFS_IOC_TREE_SEARCH _IOWR(BTRFS_IOCTL_MAGIC, 17, \
a4152e3fe28b53b8919cc404dd7eca7ead1bf9bdLennart Poettering#define BTRFS_IOC_INO_LOOKUP _IOWR(BTRFS_IOCTL_MAGIC, 18, \
a4152e3fe28b53b8919cc404dd7eca7ead1bf9bdLennart Poettering#define BTRFS_IOC_SNAP_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 23, \
a4152e3fe28b53b8919cc404dd7eca7ead1bf9bdLennart Poettering#define BTRFS_IOC_SUBVOL_GETFLAGS _IOR(BTRFS_IOCTL_MAGIC, 25, __u64)
a4152e3fe28b53b8919cc404dd7eca7ead1bf9bdLennart Poettering#define BTRFS_IOC_SUBVOL_SETFLAGS _IOW(BTRFS_IOCTL_MAGIC, 26, __u64)
a4152e3fe28b53b8919cc404dd7eca7ead1bf9bdLennart Poettering#define BTRFS_IOC_DEV_INFO _IOWR(BTRFS_IOCTL_MAGIC, 30, \
a4152e3fe28b53b8919cc404dd7eca7ead1bf9bdLennart Poettering#define BTRFS_IOC_FS_INFO _IOR(BTRFS_IOCTL_MAGIC, 31, \
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering#define BTRFS_IOC_DEVICES_READY _IOR(BTRFS_IOCTL_MAGIC, 39, \
a4152e3fe28b53b8919cc404dd7eca7ead1bf9bdLennart Poettering# error "__NR_name_to_handle_at is not defined"
a4152e3fe28b53b8919cc404dd7eca7ead1bf9bdLennart Poettering unsigned char f_handle[0];
a4152e3fe28b53b8919cc404dd7eca7ead1bf9bdLennart Poetteringstatic inline int name_to_handle_at(int fd, const char *name, struct file_handle *handle, int *mnt_id, int flags) {
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering return syscall(__NR_name_to_handle_at, fd, name, handle, mnt_id, flags);
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering# error "neither secure_getenv nor __secure_getenv are available"
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering# define DRM_IOCTL_SET_MASTER _IO('d', 0x1e)
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering# define DRM_IOCTL_DROP_MASTER _IO('d', 0x1f)
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering#if defined(__i386__) || defined(__x86_64__)
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering/* The precise definition of __O_TMPFILE is arch specific, so let's
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering * just define this on x86 where we know the value. */
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering/* a horrid kludge trying to make sure that this will fail on old kernels */
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering#define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
a4152e3fe28b53b8919cc404dd7eca7ead1bf9bdLennart Poetteringstatic inline int setns(int fd, int nstype) {
a4152e3fe28b53b8919cc404dd7eca7ead1bf9bdLennart Poettering#define IFLA_INET6_MAX (__IFLA_INET6_MAX - 1)
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering#define IFLA_MACVLAN_MAX (__IFLA_MACVLAN_MAX - 1)
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering#define IFLA_IPVLAN_MAX (__IFLA_IPVLAN_MAX - 1)
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering#define IFLA_BOND_MAX (__IFLA_BOND_MAX - 1)
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering#define IFLA_VLAN_MAX (__IFLA_VLAN_MAX - 1)
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering#define IFLA_VXLAN_MAX (__IFLA_VXLAN_MAX - 1)
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering#if !HAVE_DECL_IFLA_IPTUN_6RD_RELAY_PREFIXLEN
a4152e3fe28b53b8919cc404dd7eca7ead1bf9bdLennart Poettering#define IFLA_IPTUN_MAX (__IFLA_IPTUN_MAX - 1)
a4152e3fe28b53b8919cc404dd7eca7ead1bf9bdLennart Poettering#define IFLA_BRIDGE_MAX (__IFLA_BRIDGE_MAX - 1)
a4152e3fe28b53b8919cc404dd7eca7ead1bf9bdLennart Poettering#define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1)
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering/* Note that LOOPBACK_IFINDEX is currently not exported by the
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering * kernel/glibc, but hardcoded internally by the kernel. However, as
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering * it is exported to userspace indirectly via rtnetlink and the
2f671520ebade4877cbf6aca3572a5f8c4e1871dLennart Poettering * ioctls, and made use of widely we define it here too, in a way that
2f671520ebade4877cbf6aca3572a5f8c4e1871dLennart Poettering * is compatible with the kernel's internal definition. */
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poetteringstatic inline int raw_clone(unsigned long flags, void *child_stack) {
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering#if defined(__s390__) || defined(__CRIS__)
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering /* On s390 and cris the order of the first and second arguments
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering * of the raw clone() system call is reversed. */
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering return (int) syscall(__NR_clone, child_stack, flags);
a4152e3fe28b53b8919cc404dd7eca7ead1bf9bdLennart Poettering return (int) syscall(__NR_clone, flags, child_stack);
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering# warning "__NR_renameat2 unknown for your architecture"
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poetteringstatic inline int renameat2(int oldfd, const char *oldname, int newfd, const char *newname, unsigned flags) {
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poettering return syscall(__NR_renameat2, oldfd, oldname, newfd, newname, flags);
e821075a23fdfa3ca7738fc30bb2d4c430fe10c0Lennart Poetteringstatic inline int kcmp(pid_t pid1, pid_t pid2, int type, unsigned long idx1, unsigned long idx2) {