#pragma once
/***
This file is part of systemd.
Copyright 2010 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
/* Missing glibc definitions to access certain kernel APIs */
#include <errno.h>
#include <fcntl.h>
#include <linux/capability.h>
#include <linux/neighbour.h>
#include <linux/rtnetlink.h>
#include <stdlib.h>
#include <sys/resource.h>
#include <uchar.h>
#include <unistd.h>
#ifdef HAVE_AUDIT
#include <libaudit.h>
#endif
#ifdef ARCH_MIPS
#endif
#ifdef HAVE_LINUX_BTRFS_H
#endif
#include "macro.h"
#ifndef RLIMIT_RTTIME
#endif
/* If RLIMIT_RTTIME is not defined, then we cannot use RLIMIT_NLIMITS as is */
#ifndef F_LINUX_SPECIFIC_BASE
#endif
#ifndef F_SETPIPE_SZ
#endif
#ifndef F_GETPIPE_SZ
#endif
#ifndef F_ADD_SEALS
#endif
#ifndef F_OFD_GETLK
#endif
#ifndef MFD_ALLOW_SEALING
#endif
#ifndef MFD_CLOEXEC
#endif
#ifndef IP_FREEBIND
#endif
#ifndef OOM_SCORE_ADJ_MIN
#endif
#ifndef OOM_SCORE_ADJ_MAX
#endif
#ifndef AUDIT_SERVICE_START
#endif
#ifndef AUDIT_SERVICE_STOP
#endif
#ifndef TIOCVHANGUP
#endif
#ifndef IP_TRANSPARENT
#endif
#ifndef SOL_NETLINK
#endif
#ifndef NETLINK_LIST_MEMBERSHIPS
#endif
#ifndef SOL_SCTP
#endif
#if !HAVE_DECL_PIVOT_ROOT
}
#endif
#ifndef __NR_memfd_create
# if defined __x86_64__
# elif defined __aarch64__
# if _MIPS_SIM == _MIPS_SIM_ABI32
# endif
# if _MIPS_SIM == _MIPS_SIM_NABI32
# endif
# if _MIPS_SIM == _MIPS_SIM_ABI64
# endif
# else
# warning "__NR_memfd_create unknown for your architecture"
# endif
#endif
#ifndef HAVE_MEMFD_CREATE
}
#endif
#ifndef __NR_getrandom
# if defined __x86_64__
# elif defined(__aarch64__)
# elif defined(__powerpc__)
# if _MIPS_SIM == _MIPS_SIM_ABI32
# endif
# if _MIPS_SIM == _MIPS_SIM_NABI32
# endif
# if _MIPS_SIM == _MIPS_SIM_ABI64
# endif
# else
# warning "__NR_getrandom unknown for your architecture"
# endif
#endif
#if !HAVE_DECL_GETRANDOM
}
#endif
#ifndef GRND_NONBLOCK
#endif
#ifndef GRND_RANDOM
#endif
#ifndef BTRFS_IOCTL_MAGIC
#endif
#ifndef BTRFS_PATH_NAME_MAX
#endif
#ifndef BTRFS_DEVICE_PATH_NAME_MAX
#endif
#ifndef BTRFS_FSID_SIZE
#endif
#ifndef BTRFS_UUID_SIZE
#endif
#ifndef BTRFS_SUBVOL_RDONLY
#endif
#ifndef BTRFS_SUBVOL_NAME_MAX
#endif
#ifndef BTRFS_INO_LOOKUP_PATH_MAX
#endif
#ifndef BTRFS_SEARCH_ARGS_BUFSIZE
#endif
#ifndef BTRFS_QGROUP_LEVEL_SHIFT
#endif
#ifndef HAVE_LINUX_BTRFS_H
struct btrfs_ioctl_vol_args {
};
struct btrfs_qgroup_limit {
};
struct btrfs_qgroup_inherit {
};
struct btrfs_ioctl_qgroup_limit_args {
};
struct btrfs_ioctl_vol_args_v2 {
union {
struct {
};
};
};
struct btrfs_ioctl_dev_info_args {
};
struct btrfs_ioctl_fs_info_args {
};
struct btrfs_ioctl_ino_lookup_args {
};
struct btrfs_ioctl_search_key {
/* which root are we searching. 0 is the tree of tree roots */
/* keys returned will be >= min and <= max */
/* keys returned will be >= min and <= max */
/* max and min transids to search for */
/* keys returned will be >= min and <= max */
/*
* how many items did userland ask for, and how many are we
* returning
*/
/* align to 64 bits */
/* some extra for later */
};
struct btrfs_ioctl_search_header {
};
struct btrfs_ioctl_search_args {
};
struct btrfs_ioctl_clone_range_args {
};
struct btrfs_ioctl_quota_ctl_args {
};
#endif
#ifndef BTRFS_IOC_DEFRAG
struct btrfs_ioctl_vol_args)
#endif
#ifndef BTRFS_IOC_RESIZE
struct btrfs_ioctl_vol_args)
#endif
#ifndef BTRFS_IOC_CLONE
#endif
#ifndef BTRFS_IOC_CLONE_RANGE
struct btrfs_ioctl_clone_range_args)
#endif
#ifndef BTRFS_IOC_SUBVOL_CREATE
struct btrfs_ioctl_vol_args)
#endif
#ifndef BTRFS_IOC_SNAP_DESTROY
struct btrfs_ioctl_vol_args)
#endif
#ifndef BTRFS_IOC_TREE_SEARCH
struct btrfs_ioctl_search_args)
#endif
#ifndef BTRFS_IOC_INO_LOOKUP
struct btrfs_ioctl_ino_lookup_args)
#endif
#ifndef BTRFS_IOC_SNAP_CREATE_V2
struct btrfs_ioctl_vol_args_v2)
#endif
#ifndef BTRFS_IOC_SUBVOL_GETFLAGS
#endif
#ifndef BTRFS_IOC_SUBVOL_SETFLAGS
#endif
#ifndef BTRFS_IOC_DEV_INFO
struct btrfs_ioctl_dev_info_args)
#endif
#ifndef BTRFS_IOC_FS_INFO
struct btrfs_ioctl_fs_info_args)
#endif
#ifndef BTRFS_IOC_DEVICES_READY
struct btrfs_ioctl_vol_args)
#endif
#ifndef BTRFS_IOC_QUOTA_CTL
struct btrfs_ioctl_quota_ctl_args)
#endif
#ifndef BTRFS_IOC_QGROUP_LIMIT
struct btrfs_ioctl_qgroup_limit_args)
#endif
#ifndef BTRFS_FIRST_FREE_OBJECTID
#endif
#ifndef BTRFS_LAST_FREE_OBJECTID
#endif
#ifndef BTRFS_ROOT_TREE_OBJECTID
#endif
#ifndef BTRFS_QUOTA_TREE_OBJECTID
#endif
#ifndef BTRFS_ROOT_ITEM_KEY
#endif
#ifndef BTRFS_QGROUP_STATUS_KEY
#endif
#ifndef BTRFS_QGROUP_INFO_KEY
#endif
#ifndef BTRFS_QGROUP_LIMIT_KEY
#endif
#ifndef BTRFS_QGROUP_RELATION_KEY
#endif
#ifndef BTRFS_ROOT_BACKREF_KEY
#endif
#ifndef BTRFS_SUPER_MAGIC
#endif
#ifndef CGROUP_SUPER_MAGIC
#endif
#ifndef TMPFS_MAGIC
#endif
#ifndef MS_MOVE
#endif
#ifndef MS_PRIVATE
#endif
#if !HAVE_DECL_GETTID
}
#endif
#ifndef SCM_SECURITY
#endif
#ifndef MS_STRICTATIME
#endif
#ifndef MS_REC
#endif
#ifndef MS_SHARED
#endif
#ifndef PR_SET_NO_NEW_PRIVS
#endif
#ifndef PR_SET_CHILD_SUBREAPER
#endif
#ifndef MAX_HANDLE_SZ
#endif
#ifndef __NR_name_to_handle_at
# if defined(__x86_64__)
# elif defined(__powerpc__)
# else
# error "__NR_name_to_handle_at is not defined"
# endif
#endif
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) {
}
#endif
#ifndef HAVE_SECURE_GETENV
# ifdef HAVE___SECURE_GETENV
# else
# error "neither secure_getenv nor __secure_getenv are available"
# endif
#endif
#ifndef CIFS_MAGIC_NUMBER
#endif
#ifndef TFD_TIMER_CANCEL_ON_SET
#endif
#ifndef SO_REUSEPORT
#endif
#ifndef EVIOCREVOKE
#endif
#ifndef DRM_IOCTL_SET_MASTER
#endif
#ifndef DRM_IOCTL_DROP_MASTER
#endif
#if defined(__i386__) || defined(__x86_64__)
/* The precise definition of __O_TMPFILE is arch specific, so let's
* just define this on x86 where we know the value. */
#ifndef __O_TMPFILE
#endif
/* a horrid kludge trying to make sure that this will fail on old kernels */
#ifndef O_TMPFILE
#endif
#endif
#ifndef __NR_setns
# if defined(__x86_64__)
# else
# error "__NR_setns is not defined"
# endif
#endif
#if !HAVE_DECL_SETNS
}
#endif
#endif
#ifndef LOOP_CTL_REMOVE
#endif
#ifndef LOOP_CTL_GET_FREE
#endif
#define IFLA_INET6_UNSPEC 0
#define IN6_ADDR_GEN_MODE_EUI64 0
#endif
#define IFLA_MACVLAN_UNSPEC 0
#endif
#define IFLA_IPVLAN_UNSPEC 0
#define IPVLAN_MODE_L2 0
#endif
#define IFLA_VTI_UNSPEC 0
#endif
#endif
#define IFLA_BOND_UNSPEC 0
#endif
#define IFLA_VLAN_UNSPEC 0
#endif
#define IFLA_VXLAN_UNSPEC 0
#endif
#define IFLA_IPTUN_UNSPEC 0
#endif
#define IFLA_GRE_UNSPEC 0
#endif
#define IFLA_BRIDGE_FLAGS 0
#endif
#define IFLA_BR_UNSPEC 0
#endif
#define IFLA_BRPORT_UNSPEC 0
#endif
#define NDA_UNSPEC 0
#endif
#ifndef RTA_PREF
#endif
#ifndef IPV6_UNICAST_IF
#endif
#ifndef IFF_MULTI_QUEUE
#endif
#ifndef IFF_LOWER_UP
#endif
#ifndef IFF_DORMANT
#endif
#ifndef BOND_XMIT_POLICY_ENCAP23
#endif
#ifndef BOND_XMIT_POLICY_ENCAP34
#endif
#ifndef NET_ADDR_RANDOM
#endif
#ifndef NET_NAME_UNKNOWN
# define NET_NAME_UNKNOWN 0
#endif
#ifndef NET_NAME_ENUM
#endif
#ifndef NET_NAME_PREDICTABLE
#endif
#ifndef NET_NAME_USER
#endif
#ifndef NET_NAME_RENAMED
#endif
#ifndef BPF_XOR
#endif
/* Note that LOOPBACK_IFINDEX is currently not exported by the
* it is exported to userspace indirectly via rtnetlink and the
* ioctls, and made use of widely we define it here too, in a way that
* is compatible with the kernel's internal definition. */
#ifndef LOOPBACK_IFINDEX
#endif
#if !HAVE_DECL_IFA_FLAGS
#endif
#ifndef IFA_F_MANAGETEMPADDR
#endif
#ifndef IFA_F_NOPREFIXROUTE
#endif
#ifndef MAX_AUDIT_MESSAGE_LENGTH
#endif
#ifndef AUDIT_NLGRP_MAX
#endif
#ifndef CAP_MAC_OVERRIDE
#endif
#ifndef CAP_MAC_ADMIN
#endif
#ifndef CAP_SYSLOG
#endif
#ifndef CAP_WAKE_ALARM
#endif
#ifndef CAP_BLOCK_SUSPEND
#endif
#ifndef CAP_AUDIT_READ
#endif
/* On s390 and cris the order of the first and second arguments
* of the raw clone() system call is reversed. */
#else
#endif
}
#if defined(__alpha__)
#else
#endif
}
#if !HAVE_DECL_RENAMEAT2
#ifndef __NR_renameat2
# if defined __x86_64__
# if _MIPS_SIM == _MIPS_SIM_ABI32
# endif
# if _MIPS_SIM == _MIPS_SIM_NABI32
# endif
# if _MIPS_SIM == _MIPS_SIM_ABI64
# endif
# else
# warning "__NR_renameat2 unknown for your architecture"
# endif
#endif
static inline int renameat2(int oldfd, const char *oldname, int newfd, const char *newname, unsigned flags) {
}
#endif
#ifndef RENAME_NOREPLACE
#endif
#if !HAVE_DECL_KCMP
#if defined(__NR_kcmp)
#else
return -1;
#endif
}
#endif
#ifndef KCMP_FILE
#define KCMP_FILE 0
#endif
#ifndef INPUT_PROP_POINTING_STICK
#endif
#ifndef INPUT_PROP_ACCELEROMETER
#endif
#endif
#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)
#else
return -1;
#endif
}
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)
#else
return -1;
#endif
}
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)
#else
return -1;
#endif
}
#endif
#ifndef KEYCTL_READ
#endif
#ifndef KEYCTL_SET_TIMEOUT
#endif
#ifndef KEY_SPEC_USER_KEYRING
#endif
#ifndef PR_CAP_AMBIENT
#endif
#ifndef PR_CAP_AMBIENT_IS_SET
#endif
#ifndef PR_CAP_AMBIENT_RAISE
#endif
#ifndef PR_CAP_AMBIENT_CLEAR_ALL
#endif
/* The following two defines are actually available in the kernel headers for longer, but we define them here anyway,
* since that makes it easier to use them in conjunction with the glibc net/if.h header which conflicts with
#ifndef IF_OPER_UNKNOWN
#define IF_OPER_UNKNOWN 0
#endif
#ifndef IF_OPER_UP
#ifndef HAVE_DECL_CHAR32_T
#endif
#ifndef HAVE_DECL_CHAR16_T
#endif
#endif