]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/basic/missing.h
missing: move statx related definitions to missing_stat.h
[thirdparty/systemd.git] / src / basic / missing.h
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
c2f1db8f 2#pragma once
b9f880f4
LP
3
4/* Missing glibc definitions to access certain kernel APIs */
5
3b794314 6#include <errno.h>
8ae4b6d1 7#include <fcntl.h>
d5dd44b0 8#include <inttypes.h>
875c2e22 9#include <linux/audit.h>
2822da4f 10#include <linux/capability.h>
43767d9d 11#include <linux/falloc.h>
8ae4b6d1 12#include <linux/oom.h>
43a6a52e 13#include <net/ethernet.h>
8ae4b6d1
TG
14#include <stdlib.h>
15#include <sys/resource.h>
4e0399e6 16#include <sys/socket.h>
8ae4b6d1 17#include <sys/syscall.h>
c932fb71 18#include <uchar.h>
8ae4b6d1 19#include <unistd.h>
dd6c17b1 20
349cc4a5 21#if HAVE_AUDIT
dd6c17b1
LP
22#include <libaudit.h>
23#endif
b9f880f4 24
d59d0a2b 25#ifdef ARCH_MIPS
26#include <asm/sgidefs.h>
27#endif
28
349cc4a5 29#if HAVE_LINUX_VM_SOCKETS_H
4e0399e6
SH
30#include <linux/vm_sockets.h>
31#else
32#define VMADDR_CID_ANY -1U
33struct sockaddr_vm {
34 unsigned short svm_family;
35 unsigned short svm_reserved1;
36 unsigned int svm_port;
37 unsigned int svm_cid;
38 unsigned char svm_zero[sizeof(struct sockaddr) -
39 sizeof(unsigned short) -
40 sizeof(unsigned short) -
41 sizeof(unsigned int) -
42 sizeof(unsigned int)];
43};
44#endif /* !HAVE_LINUX_VM_SOCKETS_H */
45
b9f880f4
LP
46#ifndef RLIMIT_RTTIME
47#define RLIMIT_RTTIME 15
48#endif
49
517d56b1
LP
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)
52
4fd5948e
LP
53#ifndef F_LINUX_SPECIFIC_BASE
54#define F_LINUX_SPECIFIC_BASE 1024
55#endif
56
57#ifndef F_SETPIPE_SZ
58#define F_SETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 7)
59#endif
60
61#ifndef F_GETPIPE_SZ
62#define F_GETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 8)
63#endif
64
a6082d77
DM
65#ifndef F_ADD_SEALS
66#define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9)
a6082d77 67#define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10)
a6082d77 68
a6082d77 69#define F_SEAL_SEAL 0x0001 /* prevent further seals from being set */
a6082d77 70#define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */
a6082d77 71#define F_SEAL_GROW 0x0004 /* prevent file from growing */
a6082d77
DM
72#define F_SEAL_WRITE 0x0008 /* prevent writes */
73#endif
74
f4a53250
MM
75#ifndef F_OFD_GETLK
76#define F_OFD_GETLK 36
77#define F_OFD_SETLK 37
78#define F_OFD_SETLKW 38
79#endif
80
a6082d77 81#ifndef MFD_ALLOW_SEALING
45071fca
LP
82#define MFD_ALLOW_SEALING 0x0002U
83#endif
84
85#ifndef MFD_CLOEXEC
86#define MFD_CLOEXEC 0x0001U
a6082d77
DM
87#endif
88
16c42ce1
KS
89#ifndef IP_FREEBIND
90#define IP_FREEBIND 15
91#endif
92
dd6c17b1
LP
93#ifndef OOM_SCORE_ADJ_MIN
94#define OOM_SCORE_ADJ_MIN (-1000)
95#endif
96
97#ifndef OOM_SCORE_ADJ_MAX
98#define OOM_SCORE_ADJ_MAX 1000
99#endif
15ae422b 100
4927fcae 101#ifndef AUDIT_SERVICE_START
dd6c17b1 102#define AUDIT_SERVICE_START 1130 /* Service (daemon) start */
4927fcae
LP
103#endif
104
105#ifndef AUDIT_SERVICE_STOP
dd6c17b1 106#define AUDIT_SERVICE_STOP 1131 /* Service (daemon) stop */
4927fcae
LP
107#endif
108
6ea832a2
LP
109#ifndef TIOCVHANGUP
110#define TIOCVHANGUP 0x5437
111#endif
112
b90865ba
KS
113#ifndef IP_TRANSPARENT
114#define IP_TRANSPARENT 19
115#endif
116
66269b05
TG
117#ifndef SOL_NETLINK
118#define SOL_NETLINK 270
119#endif
120
9c5a882b
TG
121#ifndef NETLINK_LIST_MEMBERSHIPS
122#define NETLINK_LIST_MEMBERSHIPS 9
123#endif
124
62bc4efc
SS
125#ifndef SOL_SCTP
126#define SOL_SCTP 132
127#endif
128
97768fc5
LP
129#ifndef GRND_NONBLOCK
130#define GRND_NONBLOCK 0x0001
131#endif
132
133#ifndef GRND_RANDOM
134#define GRND_RANDOM 0x0002
135#endif
136
0f3be6ca
LP
137#ifndef FS_NOCOW_FL
138#define FS_NOCOW_FL 0x00800000
139#endif
140
3228995c
CB
141#ifndef CLONE_NEWCGROUP
142#define CLONE_NEWCGROUP 0x02000000
143#endif
144
94d82985
LP
145#ifndef MS_MOVE
146#define MS_MOVE 8192
147#endif
148
7ef71470
ZJS
149#ifndef MS_REC
150#define MS_REC 16384
151#endif
152
7cb1094a 153#ifndef MS_PRIVATE
7ef71470 154#define MS_PRIVATE (1<<18)
7cb1094a
HH
155#endif
156
7ef71470
ZJS
157#ifndef MS_REC
158#define MS_REC (1<<19)
159#endif
160
161#ifndef MS_SHARED
162#define MS_SHARED (1<<20)
163#endif
164
165#ifndef MS_RELATIME
166#define MS_RELATIME (1<<21)
167#endif
168
169#ifndef MS_KERNMOUNT
170#define MS_KERNMOUNT (1<<22)
171#endif
172
173#ifndef MS_I_VERSION
174#define MS_I_VERSION (1<<23)
54ecda32
LP
175#endif
176
48ac500b 177#ifndef MS_STRICTATIME
7ef71470 178#define MS_STRICTATIME (1<<24)
48ac500b
LP
179#endif
180
7ef71470
ZJS
181#ifndef MS_LAZYTIME
182#define MS_LAZYTIME (1<<25)
a9621528
AM
183#endif
184
7ef71470
ZJS
185#ifndef SCM_SECURITY
186#define SCM_SECURITY 0x03
a9621528
AM
187#endif
188
8351ceae
LP
189#ifndef PR_SET_NO_NEW_PRIVS
190#define PR_SET_NO_NEW_PRIVS 38
191#endif
d4447f4d
AK
192
193#ifndef PR_SET_CHILD_SUBREAPER
194#define PR_SET_CHILD_SUBREAPER 36
195#endif
a8348796 196
80ebe5c2
HGB
197#ifndef PR_SET_MM_ARG_START
198#define PR_SET_MM_ARG_START 8
199#endif
200
201#ifndef PR_SET_MM_ARG_END
202#define PR_SET_MM_ARG_END 9
203#endif
204
205#ifndef PR_SET_MM_ENV_START
206#define PR_SET_MM_ENV_START 10
207#endif
208
209#ifndef PR_SET_MM_ENV_END
210#define PR_SET_MM_ENV_END 11
211#endif
212
ffc01f06
HGB
213#ifndef DM_DEFERRED_REMOVE
214#define DM_DEFERRED_REMOVE (1 << 17)
215#endif
216
56766f99
HGB
217#ifndef MAX_HANDLE_SZ
218#define MAX_HANDLE_SZ 128
219#endif
220
349cc4a5
ZJS
221#if ! HAVE_SECURE_GETENV
222# if HAVE___SECURE_GETENV
4db17f29
ZJS
223# define secure_getenv __secure_getenv
224# else
66330455 225# error "neither secure_getenv nor __secure_getenv are available"
4db17f29
ZJS
226# endif
227#endif
85210bff
LP
228
229#ifndef CIFS_MAGIC_NUMBER
65b3903f 230# define CIFS_MAGIC_NUMBER 0xFF534D42
85210bff 231#endif
8742514c
LP
232
233#ifndef TFD_TIMER_CANCEL_ON_SET
65b3903f 234# define TFD_TIMER_CANCEL_ON_SET (1 << 1)
8742514c 235#endif
f7db7a69
SL
236
237#ifndef SO_REUSEPORT
65b3903f 238# define SO_REUSEPORT 15
f7db7a69 239#endif
118ecf32 240
43f2c88d
LP
241#ifndef SO_PEERGROUPS
242# define SO_PEERGROUPS 59
243#endif
244
118ecf32 245#ifndef DRM_IOCTL_SET_MASTER
65b3903f 246# define DRM_IOCTL_SET_MASTER _IO('d', 0x1e)
118ecf32
DH
247#endif
248
249#ifndef DRM_IOCTL_DROP_MASTER
65b3903f
ZJS
250# define DRM_IOCTL_DROP_MASTER _IO('d', 0x1f)
251#endif
252
daad709a
YM
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.
258 */
c09918f9
LP
259
260#ifndef __O_TMPFILE
daad709a
YM
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
267#else
c09918f9
LP
268#define __O_TMPFILE 020000000
269#endif
d5df18e4 270#endif
c09918f9
LP
271
272/* a horrid kludge trying to make sure that this will fail on old kernels */
273#ifndef O_TMPFILE
274#define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
275#endif
276
7965435e 277#ifndef BPF_XOR
9714c020 278#define BPF_XOR 0xa0
7965435e 279#endif
a5f03596
LP
280
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
288#endif
875c2e22
LP
289
290#ifndef MAX_AUDIT_MESSAGE_LENGTH
291#define MAX_AUDIT_MESSAGE_LENGTH 8970
292#endif
293
294#ifndef AUDIT_NLGRP_MAX
295#define AUDIT_NLGRP_READLOG 1
296#endif
2822da4f
LP
297
298#ifndef CAP_MAC_OVERRIDE
299#define CAP_MAC_OVERRIDE 32
300#endif
301
302#ifndef CAP_MAC_ADMIN
303#define CAP_MAC_ADMIN 33
304#endif
305
306#ifndef CAP_SYSLOG
307#define CAP_SYSLOG 34
308#endif
309
310#ifndef CAP_WAKE_ALARM
311#define CAP_WAKE_ALARM 35
312#endif
313
314#ifndef CAP_BLOCK_SUSPEND
315#define CAP_BLOCK_SUSPEND 36
316#endif
317
318#ifndef CAP_AUDIT_READ
319#define CAP_AUDIT_READ 37
320#endif
60e1651a 321
ebd93cb6
LP
322#ifndef RENAME_NOREPLACE
323#define RENAME_NOREPLACE (1 << 0)
324#endif
f7ad54a3 325
f7ad54a3
LP
326#ifndef KCMP_FILE
327#define KCMP_FILE 0
328#endif
606df97b 329
755d4b67
IP
330#ifndef PR_CAP_AMBIENT
331#define PR_CAP_AMBIENT 47
332#endif
333
334#ifndef PR_CAP_AMBIENT_IS_SET
335#define PR_CAP_AMBIENT_IS_SET 1
336#endif
337
338#ifndef PR_CAP_AMBIENT_RAISE
339#define PR_CAP_AMBIENT_RAISE 2
340#endif
341
342#ifndef PR_CAP_AMBIENT_CLEAR_ALL
343#define PR_CAP_AMBIENT_CLEAR_ALL 4
344#endif
6955a3ba 345
9714c020 346#if !HAVE_CHAR32_T
c932fb71
SL
347#define char32_t uint32_t
348#endif
349
9714c020 350#if !HAVE_CHAR16_T
c932fb71
SL
351#define char16_t uint16_t
352#endif
353
43a6a52e
LP
354#ifndef ETHERTYPE_LLDP
355#define ETHERTYPE_LLDP 0x88cc
356#endif
357
0fe5f3c5
LP
358#ifndef SOL_ALG
359#define SOL_ALG 279
360#endif
361
4e0399e6
SH
362#ifndef AF_VSOCK
363#define AF_VSOCK 40
364#endif
365
80750adb
ZJS
366#ifndef EXT4_IOC_RESIZE_FS
367# define EXT4_IOC_RESIZE_FS _IOW('f', 16, __u64)
368#endif
369
d7bea6b6
DP
370#ifndef NS_GET_NSTYPE
371#define NS_GET_NSTYPE _IO(0xb7, 0x3)
372#endif
373
43767d9d
LP
374#ifndef FALLOC_FL_KEEP_SIZE
375#define FALLOC_FL_KEEP_SIZE 0x01
376#endif
377
378#ifndef FALLOC_FL_PUNCH_HOLE
379#define FALLOC_FL_PUNCH_HOLE 0x02
380#endif
381
36b5119a
LP
382#ifndef PF_KTHREAD
383#define PF_KTHREAD 0x00200000
384#endif
385
92f14395
LP
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
391#endif
392
b9683baf 393#include "missing_btrfs_tree.h"
31c2ddab 394#include "missing_input.h"
1e54f0ab 395#include "missing_magic.h"
9714c020 396#include "missing_network.h"
e01819f8 397
2f368e4a 398#include "missing_syscall.h"