]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/basic/missing.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
4 /* Missing glibc definitions to access certain kernel APIs */
9 #include <linux/audit.h>
10 #include <linux/capability.h>
11 #include <linux/falloc.h>
12 #include <linux/oom.h>
13 #include <net/ethernet.h>
15 #include <sys/resource.h>
16 #include <sys/socket.h>
17 #include <sys/syscall.h>
26 #include <asm/sgidefs.h>
29 #if HAVE_LINUX_VM_SOCKETS_H
30 #include <linux/vm_sockets.h>
32 #define VMADDR_CID_ANY -1U
34 unsigned short svm_family
;
35 unsigned short svm_reserved1
;
36 unsigned int svm_port
;
38 unsigned char svm_zero
[sizeof(struct sockaddr
) -
39 sizeof(unsigned short) -
40 sizeof(unsigned short) -
41 sizeof(unsigned int) -
42 sizeof(unsigned int)];
44 #endif /* !HAVE_LINUX_VM_SOCKETS_H */
47 #define RLIMIT_RTTIME 15
50 /* If RLIMIT_RTTIME is not defined, then we cannot use RLIMIT_NLIMITS as is */
51 #define _RLIMIT_MAX (RLIMIT_RTTIME+1 > RLIMIT_NLIMITS ? RLIMIT_RTTIME+1 : RLIMIT_NLIMITS)
53 #ifndef F_LINUX_SPECIFIC_BASE
54 #define F_LINUX_SPECIFIC_BASE 1024
58 #define F_SETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 7)
62 #define F_GETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 8)
66 #define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9)
67 #define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10)
69 #define F_SEAL_SEAL 0x0001 /* prevent further seals from being set */
70 #define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */
71 #define F_SEAL_GROW 0x0004 /* prevent file from growing */
72 #define F_SEAL_WRITE 0x0008 /* prevent writes */
76 #define F_OFD_GETLK 36
77 #define F_OFD_SETLK 37
78 #define F_OFD_SETLKW 38
81 #ifndef MFD_ALLOW_SEALING
82 #define MFD_ALLOW_SEALING 0x0002U
86 #define MFD_CLOEXEC 0x0001U
90 #define IP_FREEBIND 15
93 #ifndef OOM_SCORE_ADJ_MIN
94 #define OOM_SCORE_ADJ_MIN (-1000)
97 #ifndef OOM_SCORE_ADJ_MAX
98 #define OOM_SCORE_ADJ_MAX 1000
101 #ifndef AUDIT_SERVICE_START
102 #define AUDIT_SERVICE_START 1130 /* Service (daemon) start */
105 #ifndef AUDIT_SERVICE_STOP
106 #define AUDIT_SERVICE_STOP 1131 /* Service (daemon) stop */
110 #define TIOCVHANGUP 0x5437
113 #ifndef IP_TRANSPARENT
114 #define IP_TRANSPARENT 19
118 #define SOL_NETLINK 270
121 #ifndef NETLINK_LIST_MEMBERSHIPS
122 #define NETLINK_LIST_MEMBERSHIPS 9
129 #ifndef GRND_NONBLOCK
130 #define GRND_NONBLOCK 0x0001
134 #define GRND_RANDOM 0x0002
138 #define FS_NOCOW_FL 0x00800000
141 #ifndef CLONE_NEWCGROUP
142 #define CLONE_NEWCGROUP 0x02000000
154 #define MS_PRIVATE (1<<18)
158 #define MS_REC (1<<19)
162 #define MS_SHARED (1<<20)
166 #define MS_RELATIME (1<<21)
170 #define MS_KERNMOUNT (1<<22)
174 #define MS_I_VERSION (1<<23)
177 #ifndef MS_STRICTATIME
178 #define MS_STRICTATIME (1<<24)
182 #define MS_LAZYTIME (1<<25)
186 #define SCM_SECURITY 0x03
189 #ifndef DM_DEFERRED_REMOVE
190 #define DM_DEFERRED_REMOVE (1 << 17)
193 #ifndef MAX_HANDLE_SZ
194 #define MAX_HANDLE_SZ 128
197 #if ! HAVE_SECURE_GETENV
198 # if HAVE___SECURE_GETENV
199 # define secure_getenv __secure_getenv
201 # error "neither secure_getenv nor __secure_getenv are available"
205 #ifndef CIFS_MAGIC_NUMBER
206 # define CIFS_MAGIC_NUMBER 0xFF534D42
209 #ifndef TFD_TIMER_CANCEL_ON_SET
210 # define TFD_TIMER_CANCEL_ON_SET (1 << 1)
214 # define SO_REUSEPORT 15
217 #ifndef SO_PEERGROUPS
218 # define SO_PEERGROUPS 59
221 #ifndef DRM_IOCTL_SET_MASTER
222 # define DRM_IOCTL_SET_MASTER _IO('d', 0x1e)
225 #ifndef DRM_IOCTL_DROP_MASTER
226 # define DRM_IOCTL_DROP_MASTER _IO('d', 0x1f)
229 /* The precise definition of __O_TMPFILE is arch specific; use the
230 * values defined by the kernel (note: some are hexa, some are octal,
231 * duplicated as-is from the kernel definitions):
232 * - alpha, parisc, sparc: each has a specific value;
233 * - others: they use the "generic" value.
237 #if defined(__alpha__)
238 #define __O_TMPFILE 0100000000
239 #elif defined(__parisc__) || defined(__hppa__)
240 #define __O_TMPFILE 0400000000
241 #elif defined(__sparc__) || defined(__sparc64__)
242 #define __O_TMPFILE 0x2000000
244 #define __O_TMPFILE 020000000
248 /* a horrid kludge trying to make sure that this will fail on old kernels */
250 #define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
257 /* Note that LOOPBACK_IFINDEX is currently not exported by the
258 * kernel/glibc, but hardcoded internally by the kernel. However, as
259 * it is exported to userspace indirectly via rtnetlink and the
260 * ioctls, and made use of widely we define it here too, in a way that
261 * is compatible with the kernel's internal definition. */
262 #ifndef LOOPBACK_IFINDEX
263 #define LOOPBACK_IFINDEX 1
266 #ifndef MAX_AUDIT_MESSAGE_LENGTH
267 #define MAX_AUDIT_MESSAGE_LENGTH 8970
270 #ifndef AUDIT_NLGRP_MAX
271 #define AUDIT_NLGRP_READLOG 1
274 #ifndef CAP_MAC_OVERRIDE
275 #define CAP_MAC_OVERRIDE 32
278 #ifndef CAP_MAC_ADMIN
279 #define CAP_MAC_ADMIN 33
283 #define CAP_SYSLOG 34
286 #ifndef CAP_WAKE_ALARM
287 #define CAP_WAKE_ALARM 35
290 #ifndef CAP_BLOCK_SUSPEND
291 #define CAP_BLOCK_SUSPEND 36
294 #ifndef CAP_AUDIT_READ
295 #define CAP_AUDIT_READ 37
298 #ifndef RENAME_NOREPLACE
299 #define RENAME_NOREPLACE (1 << 0)
307 #define char32_t uint32_t
311 #define char16_t uint16_t
314 #ifndef ETHERTYPE_LLDP
315 #define ETHERTYPE_LLDP 0x88cc
326 #ifndef EXT4_IOC_RESIZE_FS
327 # define EXT4_IOC_RESIZE_FS _IOW('f', 16, __u64)
330 #ifndef NS_GET_NSTYPE
331 #define NS_GET_NSTYPE _IO(0xb7, 0x3)
334 #ifndef FALLOC_FL_KEEP_SIZE
335 #define FALLOC_FL_KEEP_SIZE 0x01
338 #ifndef FALLOC_FL_PUNCH_HOLE
339 #define FALLOC_FL_PUNCH_HOLE 0x02
343 #define PF_KTHREAD 0x00200000
346 /* The maximum thread/process name length including trailing NUL byte. This mimics the kernel definition of the same
347 * name, which we need in userspace at various places but is not defined in userspace currently, neither under this
348 * name nor any other. */
349 #ifndef TASK_COMM_LEN
350 #define TASK_COMM_LEN 16
353 #include "missing_btrfs_tree.h"
354 #include "missing_input.h"
355 #include "missing_magic.h"
356 #include "missing_network.h"
357 #include "missing_prctl.h"
359 #include "missing_syscall.h"