]>
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 PR_SET_NO_NEW_PRIVS
190 #define PR_SET_NO_NEW_PRIVS 38
193 #ifndef PR_SET_CHILD_SUBREAPER
194 #define PR_SET_CHILD_SUBREAPER 36
197 #ifndef PR_SET_MM_ARG_START
198 #define PR_SET_MM_ARG_START 8
201 #ifndef PR_SET_MM_ARG_END
202 #define PR_SET_MM_ARG_END 9
205 #ifndef PR_SET_MM_ENV_START
206 #define PR_SET_MM_ENV_START 10
209 #ifndef PR_SET_MM_ENV_END
210 #define PR_SET_MM_ENV_END 11
213 #ifndef DM_DEFERRED_REMOVE
214 #define DM_DEFERRED_REMOVE (1 << 17)
217 #ifndef MAX_HANDLE_SZ
218 #define MAX_HANDLE_SZ 128
221 #if ! HAVE_SECURE_GETENV
222 # if HAVE___SECURE_GETENV
223 # define secure_getenv __secure_getenv
225 # error "neither secure_getenv nor __secure_getenv are available"
229 #ifndef CIFS_MAGIC_NUMBER
230 # define CIFS_MAGIC_NUMBER 0xFF534D42
233 #ifndef TFD_TIMER_CANCEL_ON_SET
234 # define TFD_TIMER_CANCEL_ON_SET (1 << 1)
238 # define SO_REUSEPORT 15
241 #ifndef SO_PEERGROUPS
242 # define SO_PEERGROUPS 59
245 #ifndef DRM_IOCTL_SET_MASTER
246 # define DRM_IOCTL_SET_MASTER _IO('d', 0x1e)
249 #ifndef DRM_IOCTL_DROP_MASTER
250 # define DRM_IOCTL_DROP_MASTER _IO('d', 0x1f)
253 /* The precise definition of __O_TMPFILE is arch specific; use the
254 * values defined by the kernel (note: some are hexa, some are octal,
255 * duplicated as-is from the kernel definitions):
256 * - alpha, parisc, sparc: each has a specific value;
257 * - others: they use the "generic" value.
261 #if defined(__alpha__)
262 #define __O_TMPFILE 0100000000
263 #elif defined(__parisc__) || defined(__hppa__)
264 #define __O_TMPFILE 0400000000
265 #elif defined(__sparc__) || defined(__sparc64__)
266 #define __O_TMPFILE 0x2000000
268 #define __O_TMPFILE 020000000
272 /* a horrid kludge trying to make sure that this will fail on old kernels */
274 #define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
281 /* Note that LOOPBACK_IFINDEX is currently not exported by the
282 * kernel/glibc, but hardcoded internally by the kernel. However, as
283 * it is exported to userspace indirectly via rtnetlink and the
284 * ioctls, and made use of widely we define it here too, in a way that
285 * is compatible with the kernel's internal definition. */
286 #ifndef LOOPBACK_IFINDEX
287 #define LOOPBACK_IFINDEX 1
290 #ifndef MAX_AUDIT_MESSAGE_LENGTH
291 #define MAX_AUDIT_MESSAGE_LENGTH 8970
294 #ifndef AUDIT_NLGRP_MAX
295 #define AUDIT_NLGRP_READLOG 1
298 #ifndef CAP_MAC_OVERRIDE
299 #define CAP_MAC_OVERRIDE 32
302 #ifndef CAP_MAC_ADMIN
303 #define CAP_MAC_ADMIN 33
307 #define CAP_SYSLOG 34
310 #ifndef CAP_WAKE_ALARM
311 #define CAP_WAKE_ALARM 35
314 #ifndef CAP_BLOCK_SUSPEND
315 #define CAP_BLOCK_SUSPEND 36
318 #ifndef CAP_AUDIT_READ
319 #define CAP_AUDIT_READ 37
322 #ifndef RENAME_NOREPLACE
323 #define RENAME_NOREPLACE (1 << 0)
330 #ifndef PR_CAP_AMBIENT
331 #define PR_CAP_AMBIENT 47
334 #ifndef PR_CAP_AMBIENT_IS_SET
335 #define PR_CAP_AMBIENT_IS_SET 1
338 #ifndef PR_CAP_AMBIENT_RAISE
339 #define PR_CAP_AMBIENT_RAISE 2
342 #ifndef PR_CAP_AMBIENT_CLEAR_ALL
343 #define PR_CAP_AMBIENT_CLEAR_ALL 4
347 #define char32_t uint32_t
351 #define char16_t uint16_t
354 #ifndef ETHERTYPE_LLDP
355 #define ETHERTYPE_LLDP 0x88cc
366 #ifndef EXT4_IOC_RESIZE_FS
367 # define EXT4_IOC_RESIZE_FS _IOW('f', 16, __u64)
370 #ifndef NS_GET_NSTYPE
371 #define NS_GET_NSTYPE _IO(0xb7, 0x3)
374 #ifndef FALLOC_FL_KEEP_SIZE
375 #define FALLOC_FL_KEEP_SIZE 0x01
378 #ifndef FALLOC_FL_PUNCH_HOLE
379 #define FALLOC_FL_PUNCH_HOLE 0x02
383 #define PF_KTHREAD 0x00200000
386 /* The maximum thread/process name length including trailing NUL byte. This mimics the kernel definition of the same
387 * name, which we need in userspace at various places but is not defined in userspace currently, neither under this
388 * name nor any other. */
389 #ifndef TASK_COMM_LEN
390 #define TASK_COMM_LEN 16
393 #include "missing_btrfs_tree.h"
394 #include "missing_input.h"
395 #include "missing_magic.h"
396 #include "missing_network.h"
398 #include "missing_syscall.h"