missing.h revision b69015efd2752fd2719beec85496221304130b0b
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)
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom 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 */
977085794d2996320e345433403de75f662b0622Tom Gundersen#define F_SEAL_GROW 0x0004 /* prevent file from growing */
977085794d2996320e345433403de75f662b0622Tom Gundersen#define F_SEAL_WRITE 0x0008 /* prevent writes */
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen#define AUDIT_SERVICE_START 1130 /* Service (daemon) start */
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom 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# define __NR_memfd_create 279
187dc6e554f2d5b4b5a3bee72c73ff5df6418aa6Thomas Hindoe Paaboel Andersen# define __NR_memfd_create 350
5fde13d748749f0e06e2e6cdd15f0980a79ea82cTom Gundersen# warning "__NR_memfd_create unknown for your architecture"
489124365d1d391864898b9869dd668eea5b2e28Dave Reisnerstatic inline int memfd_create(const char *name, unsigned int flags) {
ecb08ec6a5c52f2d940f3b8147e2a480affd46e1Zbigniew Jędrzejewski-Szmek return syscall(__NR_memfd_create, name, flags);
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen# warning "__NR_getrandom unknown for your architecture"
f61942250a43a123580d7bbe5d7873dc5118ed97Tom Gundersenstatic inline int getrandom(void *buffer, size_t count, unsigned flags) {
f61942250a43a123580d7bbe5d7873dc5118ed97Tom Gundersen return syscall(__NR_getrandom, buffer, count, flags);
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen#define BTRFS_SEARCH_ARGS_BUFSIZE (4096 - sizeof(struct btrfs_ioctl_search_key))
9bf3b53533cdc9b95c921b71da755401f223f765Lennart Poettering uint8_t uuid[BTRFS_UUID_SIZE]; /* in/out */
16b9b87aeee9353b5b8dae6089a69752422a5b09Tom Gundersen char path[BTRFS_DEVICE_PATH_NAME_MAX]; /* out */
3e137a1b9a0eac2bf43d493d3302c3c959b6ccdbTom Gundersen /* which root are we searching. 0 is the tree of tree roots */
977085794d2996320e345433403de75f662b0622Tom Gundersen /* keys returned will be >= min and <= max */
3e137a1b9a0eac2bf43d493d3302c3c959b6ccdbTom Gundersen /* keys returned will be >= min and <= max */
5fde13d748749f0e06e2e6cdd15f0980a79ea82cTom Gundersen /* max and min transids to search for */
a501033335ed402c8f7e86fe41a15531ba69abd7Tom Gundersen /* keys returned will be >= min and <= max */
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen * how many items did userland ask for, and how many are we
43b3a5ef61859f06cdbaf26765cab8e1adac4296Tom Gundersen /* align to 64 bits */
5fde13d748749f0e06e2e6cdd15f0980a79ea82cTom Gundersen /* some extra for later */
16b9b87aeee9353b5b8dae6089a69752422a5b09Tom Gundersen#define BTRFS_IOC_DEFRAG _IOW(BTRFS_IOCTL_MAGIC, 2, \
16b9b87aeee9353b5b8dae6089a69752422a5b09Tom Gundersen#define BTRFS_IOC_RESIZE _IOW(BTRFS_IOCTL_MAGIC, 3, \
16b9b87aeee9353b5b8dae6089a69752422a5b09Tom Gundersen#define BTRFS_IOC_CLONE _IOW(BTRFS_IOCTL_MAGIC, 9, int)
16b9b87aeee9353b5b8dae6089a69752422a5b09Tom Gundersen#define BTRFS_IOC_CLONE_RANGE _IOW(BTRFS_IOCTL_MAGIC, 13, \
5fde13d748749f0e06e2e6cdd15f0980a79ea82cTom Gundersen#define BTRFS_IOC_SUBVOL_CREATE _IOW(BTRFS_IOCTL_MAGIC, 14, \
be32eb9b7fbcb22e4b648086d644135e38279633Tom Gundersen#define BTRFS_IOC_SNAP_DESTROY _IOW(BTRFS_IOCTL_MAGIC, 15, \
847a8a5fed4d265dfa659917515c6f9bd1b8d5c4Tom Gundersen#define BTRFS_IOC_TREE_SEARCH _IOWR(BTRFS_IOCTL_MAGIC, 17, \
847a8a5fed4d265dfa659917515c6f9bd1b8d5c4Tom Gundersen#define BTRFS_IOC_INO_LOOKUP _IOWR(BTRFS_IOCTL_MAGIC, 18, \
847a8a5fed4d265dfa659917515c6f9bd1b8d5c4Tom Gundersen#define BTRFS_IOC_SNAP_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 23, \
847a8a5fed4d265dfa659917515c6f9bd1b8d5c4Tom Gundersen#define BTRFS_IOC_SUBVOL_GETFLAGS _IOR(BTRFS_IOCTL_MAGIC, 25, __u64)
be32eb9b7fbcb22e4b648086d644135e38279633Tom Gundersen#define BTRFS_IOC_SUBVOL_SETFLAGS _IOW(BTRFS_IOCTL_MAGIC, 26, __u64)
be32eb9b7fbcb22e4b648086d644135e38279633Tom Gundersen#define BTRFS_IOC_DEV_INFO _IOWR(BTRFS_IOCTL_MAGIC, 30, \
be32eb9b7fbcb22e4b648086d644135e38279633Tom Gundersen#define BTRFS_IOC_FS_INFO _IOR(BTRFS_IOCTL_MAGIC, 31, \
be32eb9b7fbcb22e4b648086d644135e38279633Tom Gundersen#define BTRFS_IOC_DEVICES_READY _IOR(BTRFS_IOCTL_MAGIC, 39, \
#ifndef BTRFS_IOC_QUOTA_CTL
struct btrfs_ioctl_quota_ctl_args)
#ifndef BTRFS_IOC_QGROUP_LIMIT
struct btrfs_ioctl_qgroup_limit_args)
#ifndef BTRFS_FIRST_FREE_OBJECTID
#ifndef BTRFS_LAST_FREE_OBJECTID
#ifndef BTRFS_ROOT_TREE_OBJECTID
#ifndef BTRFS_QUOTA_TREE_OBJECTID
#ifndef BTRFS_ROOT_ITEM_KEY
#ifndef BTRFS_QGROUP_STATUS_KEY
#ifndef BTRFS_QGROUP_INFO_KEY
#ifndef BTRFS_QGROUP_LIMIT_KEY
#ifndef BTRFS_QGROUP_RELATION_KEY
#ifndef BTRFS_ROOT_BACKREF_KEY
#ifndef BTRFS_SUPER_MAGIC
#ifndef CGROUP_SUPER_MAGIC
#ifndef TMPFS_MAGIC
#ifndef MS_MOVE
#ifndef MS_PRIVATE
#if !HAVE_DECL_GETTID
#ifndef SCM_SECURITY
#ifndef MS_STRICTATIME
#ifndef MS_REC
#ifndef MS_SHARED
#ifndef PR_SET_NO_NEW_PRIVS
#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_GRE_UNSPEC 0
#define IFLA_BRIDGE_FLAGS 0
#define IFLA_BR_UNSPEC 0
#define IFLA_BRPORT_UNSPEC 0
#define NDA_UNSPEC 0
#ifndef RTA_PREF
#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
#if !HAVE_DECL_IFA_FLAGS
#ifndef IFA_F_NOPREFIXROUTE
#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 defined(__alpha__)
#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
#if defined(__NR_kcmp)
#ifndef KCMP_FILE
#define KCMP_FILE 0
#ifndef INPUT_PROP_POINTING_STICK
#ifndef INPUT_PROP_ACCELEROMETER
#if !HAVE_DECL_KEYCTL
static inline long keyctl(int cmd, unsigned long arg2, unsigned long arg3, unsigned long arg4,unsigned long arg5) {
#if defined(__NR_keyctl)
static inline key_serial_t add_key(const char *type, const char *description, const void *payload, size_t plen, key_serial_t ringid) {
#if defined (__NR_add_key)
static inline key_serial_t request_key(const char *type, const char *description, const char * callout_info, key_serial_t destringid) {
#if defined (__NR_request_key)
#ifndef KEYCTL_READ
#ifndef KEYCTL_SET_TIMEOUT
#ifndef KEY_SPEC_USER_KEYRING