missing.h revision 606df97b6a2438a8844c828ecdef1e9b25e2e838
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen This file is part of systemd.
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen Copyright 2010 Lennart Poettering
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen systemd is free software; you can redistribute it and/or modify it
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen under the terms of the GNU Lesser General Public License as published by
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen the Free Software Foundation; either version 2.1 of the License, or
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen (at your option) any later version.
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen systemd is distributed in the hope that it will be useful, but
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen WITHOUT ANY WARRANTY; without even the implied warranty of
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen Lesser General Public License for more details.
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen You should have received a copy of the GNU Lesser General Public License
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen along with systemd; If not, see <http://www.gnu.org/licenses/>.
43b3a5ef61859f06cdbaf26765cab8e1adac4296Tom Gundersen/* Missing glibc definitions to access certain kernel APIs */
2ad8416dd057e7e3185169609ca3006e7649f576Zbigniew Jędrzejewski-Szmek/* If RLIMIT_RTTIME is not defined, then we cannot use RLIMIT_NLIMITS as is */
2ad8416dd057e7e3185169609ca3006e7649f576Zbigniew Jędrzejewski-Szmek#define _RLIMIT_MAX (RLIMIT_RTTIME+1 > RLIMIT_NLIMITS ? RLIMIT_RTTIME+1 : RLIMIT_NLIMITS)
2ad8416dd057e7e3185169609ca3006e7649f576Zbigniew Jędrzejewski-Szmek#define F_LINUX_SPECIFIC_BASE 1024
5b9d4dc05560ddda89e48b6b39365824b15e1300Tom Gundersen#define F_SETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 7)
5b9d4dc05560ddda89e48b6b39365824b15e1300Tom Gundersen#define F_GETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 8)
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen#define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9)
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen#define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10)
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen#define F_SEAL_SEAL 0x0001 /* prevent further seals from being set */
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen#define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen#define F_SEAL_GROW 0x0004 /* prevent file from growing */
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen#define F_SEAL_WRITE 0x0008 /* prevent writes */
847a8a5fed4d265dfa659917515c6f9bd1b8d5c4Tom Gundersen#define AUDIT_SERVICE_START 1130 /* Service (daemon) start */
977085794d2996320e345433403de75f662b0622Tom Gundersen#define AUDIT_SERVICE_STOP 1131 /* Service (daemon) stop */
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersenstatic inline int pivot_root(const char *new_root, const char *put_old) {
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen return syscall(SYS_pivot_root, new_root, put_old);
187dc6e554f2d5b4b5a3bee72c73ff5df6418aa6Thomas Hindoe Paaboel Andersen# warning "__NR_memfd_create unknown for your architecture"
187dc6e554f2d5b4b5a3bee72c73ff5df6418aa6Thomas Hindoe Paaboel Andersen# define __NR_memfd_create 0xffffffff
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersenstatic inline int memfd_create(const char *name, unsigned int flags) {
ecb08ec6a5c52f2d940f3b8147e2a480affd46e1Zbigniew Jędrzejewski-Szmek return syscall(__NR_memfd_create, name, flags);
36f822c4bd077f9121757e24b6516e5c7ada63b5Zbigniew Jędrzejewski-Szmek# if _MIPS_SIM == _MIPS_SIM_ABI32
ecb08ec6a5c52f2d940f3b8147e2a480affd46e1Zbigniew Jędrzejewski-Szmek# if _MIPS_SIM == _MIPS_SIM_ABI64
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen# warning "__NR_getrandom unknown for your architecture"
f61942250a43a123580d7bbe5d7873dc5118ed97Tom Gundersenstatic inline int getrandom(void *buffer, size_t count, unsigned flags) {
74df0fca09b3c31ed19e14ba80f996fdff772417Lennart Poettering return syscall(__NR_getrandom, buffer, count, flags);
2ad8416dd057e7e3185169609ca3006e7649f576Zbigniew Jędrzejewski-Szmek#define BTRFS_SEARCH_ARGS_BUFSIZE (4096 - sizeof(struct btrfs_ioctl_search_key))
04b67d49254d956d31bcfe80340fb9df7ed332d3Tom Gundersen char path[BTRFS_DEVICE_PATH_NAME_MAX]; /* out */
04b67d49254d956d31bcfe80340fb9df7ed332d3Tom Gundersen /* which root are we searching. 0 is the tree of tree roots */
04b67d49254d956d31bcfe80340fb9df7ed332d3Tom Gundersen /* keys returned will be >= min and <= max */
16b9b87aeee9353b5b8dae6089a69752422a5b09Tom Gundersen /* keys returned will be >= min and <= max */
9bf3b53533cdc9b95c921b71da755401f223f765Lennart Poettering /* max and min transids to search for */
16b9b87aeee9353b5b8dae6089a69752422a5b09Tom Gundersen /* keys returned will be >= min and <= max */
55428d84f31b52da1c50b7469f14e15740547f20Tom Gundersen * how many items did userland ask for, and how many are we
16b9b87aeee9353b5b8dae6089a69752422a5b09Tom Gundersen /* align to 64 bits */
16b9b87aeee9353b5b8dae6089a69752422a5b09Tom Gundersen /* some extra for later */
5fde13d748749f0e06e2e6cdd15f0980a79ea82cTom Gundersen#define BTRFS_IOC_DEFRAG _IOW(BTRFS_IOCTL_MAGIC, 2, \
3e137a1b9a0eac2bf43d493d3302c3c959b6ccdbTom Gundersen#define BTRFS_IOC_CLONE _IOW(BTRFS_IOCTL_MAGIC, 9, int)
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen#define BTRFS_IOC_CLONE_RANGE _IOW(BTRFS_IOCTL_MAGIC, 13, \
43b3a5ef61859f06cdbaf26765cab8e1adac4296Tom Gundersen#define BTRFS_IOC_SUBVOL_CREATE _IOW(BTRFS_IOCTL_MAGIC, 14, \
04b67d49254d956d31bcfe80340fb9df7ed332d3Tom Gundersen#define BTRFS_IOC_SNAP_DESTROY _IOW(BTRFS_IOCTL_MAGIC, 15, \
04b67d49254d956d31bcfe80340fb9df7ed332d3Tom Gundersen#define BTRFS_IOC_TREE_SEARCH _IOWR(BTRFS_IOCTL_MAGIC, 17, \
5fde13d748749f0e06e2e6cdd15f0980a79ea82cTom Gundersen#define BTRFS_IOC_INO_LOOKUP _IOWR(BTRFS_IOCTL_MAGIC, 18, \
5fde13d748749f0e06e2e6cdd15f0980a79ea82cTom Gundersen#define BTRFS_IOC_SNAP_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 23, \
daeb71a36a98834664e4d95773a3629b746f4db8Tom Gundersen#define BTRFS_IOC_SUBVOL_GETFLAGS _IOR(BTRFS_IOCTL_MAGIC, 25, __u64)
daeb71a36a98834664e4d95773a3629b746f4db8Tom Gundersen#define BTRFS_IOC_SUBVOL_SETFLAGS _IOW(BTRFS_IOCTL_MAGIC, 26, __u64)
04b67d49254d956d31bcfe80340fb9df7ed332d3Tom Gundersen#define BTRFS_IOC_DEV_INFO _IOWR(BTRFS_IOCTL_MAGIC, 30, \
04b67d49254d956d31bcfe80340fb9df7ed332d3Tom Gundersen#define BTRFS_IOC_FS_INFO _IOR(BTRFS_IOCTL_MAGIC, 31, \
92d927f850d4b668b44f3e5f41e266d934d03726Tom Gundersen#define BTRFS_IOC_DEVICES_READY _IOR(BTRFS_IOCTL_MAGIC, 39, \
#ifndef PR_SET_CHILD_SUBREAPER
#ifndef MAX_HANDLE_SZ
#ifndef __NR_name_to_handle_at
# if defined(__x86_64__)
struct file_handle {
unsigned int handle_bytes;
int handle_type;
unsigned char f_handle[0];
static inline int name_to_handle_at(int fd, const char *name, struct file_handle *handle, int *mnt_id, int flags) {
#ifndef HAVE_SECURE_GETENV
# ifdef HAVE___SECURE_GETENV
#ifndef CIFS_MAGIC_NUMBER
#ifndef TFD_TIMER_CANCEL_ON_SET
#ifndef SO_REUSEPORT
#ifndef EVIOCREVOKE
#ifndef DRM_IOCTL_SET_MASTER
#ifndef DRM_IOCTL_DROP_MASTER
#ifndef __O_TMPFILE
#ifndef O_TMPFILE
#ifndef __NR_setns
# if defined(__x86_64__)
#if !HAVE_DECL_SETNS
#ifndef LOOP_CTL_REMOVE
#ifndef LOOP_CTL_GET_FREE
#define IFLA_INET6_UNSPEC 0
#define IN6_ADDR_GEN_MODE_EUI64 0
#define IFLA_MACVLAN_UNSPEC 0
#define IFLA_IPVLAN_UNSPEC 0
#define IPVLAN_MODE_L2 0
#define IFLA_VTI_UNSPEC 0
#define IFLA_BOND_UNSPEC 0
#define IFLA_VLAN_UNSPEC 0
#define IFLA_VXLAN_UNSPEC 0
#define IFLA_IPTUN_UNSPEC 0
#define IFLA_BRIDGE_FLAGS 0
#define IFLA_BRPORT_UNSPEC 0
#define NDA_UNSPEC 0
#ifndef IPV6_UNICAST_IF
#ifndef IFF_MULTI_QUEUE
#ifndef IFF_LOWER_UP
#ifndef IFF_DORMANT
#ifndef BOND_XMIT_POLICY_ENCAP23
#ifndef BOND_XMIT_POLICY_ENCAP34
#ifndef NET_ADDR_RANDOM
#ifndef NET_NAME_UNKNOWN
# define NET_NAME_UNKNOWN 0
#ifndef NET_NAME_ENUM
#ifndef NET_NAME_PREDICTABLE
#ifndef NET_NAME_USER
#ifndef NET_NAME_RENAMED
#ifndef BPF_XOR
#ifndef LOOPBACK_IFINDEX
#ifndef MAX_AUDIT_MESSAGE_LENGTH
#ifndef AUDIT_NLGRP_MAX
#ifndef CAP_MAC_OVERRIDE
#ifndef CAP_MAC_ADMIN
#ifndef CAP_SYSLOG
#ifndef CAP_WAKE_ALARM
#ifndef CAP_BLOCK_SUSPEND
#ifndef CAP_AUDIT_READ
#if !HAVE_DECL_RENAMEAT2
#ifndef __NR_renameat2
# if defined __x86_64__
static inline int renameat2(int oldfd, const char *oldname, int newfd, const char *newname, unsigned flags) {
#ifndef RENAME_NOREPLACE
#if !HAVE_DECL_KCMP
#ifndef KCMP_FILE
#define KCMP_FILE 0
#ifndef INPUT_PROP_POINTING_STICK