]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/basic/missing.h
missing: move statx related definitions to missing_stat.h
[thirdparty/systemd.git] / src / basic / missing.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 /* Missing glibc definitions to access certain kernel APIs */
5
6 #include <errno.h>
7 #include <fcntl.h>
8 #include <inttypes.h>
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>
14 #include <stdlib.h>
15 #include <sys/resource.h>
16 #include <sys/socket.h>
17 #include <sys/syscall.h>
18 #include <uchar.h>
19 #include <unistd.h>
20
21 #if HAVE_AUDIT
22 #include <libaudit.h>
23 #endif
24
25 #ifdef ARCH_MIPS
26 #include <asm/sgidefs.h>
27 #endif
28
29 #if HAVE_LINUX_VM_SOCKETS_H
30 #include <linux/vm_sockets.h>
31 #else
32 #define VMADDR_CID_ANY -1U
33 struct 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
46 #ifndef RLIMIT_RTTIME
47 #define RLIMIT_RTTIME 15
48 #endif
49
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
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
65 #ifndef F_ADD_SEALS
66 #define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9)
67 #define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10)
68
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 */
73 #endif
74
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
81 #ifndef MFD_ALLOW_SEALING
82 #define MFD_ALLOW_SEALING 0x0002U
83 #endif
84
85 #ifndef MFD_CLOEXEC
86 #define MFD_CLOEXEC 0x0001U
87 #endif
88
89 #ifndef IP_FREEBIND
90 #define IP_FREEBIND 15
91 #endif
92
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
100
101 #ifndef AUDIT_SERVICE_START
102 #define AUDIT_SERVICE_START 1130 /* Service (daemon) start */
103 #endif
104
105 #ifndef AUDIT_SERVICE_STOP
106 #define AUDIT_SERVICE_STOP 1131 /* Service (daemon) stop */
107 #endif
108
109 #ifndef TIOCVHANGUP
110 #define TIOCVHANGUP 0x5437
111 #endif
112
113 #ifndef IP_TRANSPARENT
114 #define IP_TRANSPARENT 19
115 #endif
116
117 #ifndef SOL_NETLINK
118 #define SOL_NETLINK 270
119 #endif
120
121 #ifndef NETLINK_LIST_MEMBERSHIPS
122 #define NETLINK_LIST_MEMBERSHIPS 9
123 #endif
124
125 #ifndef SOL_SCTP
126 #define SOL_SCTP 132
127 #endif
128
129 #ifndef GRND_NONBLOCK
130 #define GRND_NONBLOCK 0x0001
131 #endif
132
133 #ifndef GRND_RANDOM
134 #define GRND_RANDOM 0x0002
135 #endif
136
137 #ifndef FS_NOCOW_FL
138 #define FS_NOCOW_FL 0x00800000
139 #endif
140
141 #ifndef CLONE_NEWCGROUP
142 #define CLONE_NEWCGROUP 0x02000000
143 #endif
144
145 #ifndef MS_MOVE
146 #define MS_MOVE 8192
147 #endif
148
149 #ifndef MS_REC
150 #define MS_REC 16384
151 #endif
152
153 #ifndef MS_PRIVATE
154 #define MS_PRIVATE (1<<18)
155 #endif
156
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)
175 #endif
176
177 #ifndef MS_STRICTATIME
178 #define MS_STRICTATIME (1<<24)
179 #endif
180
181 #ifndef MS_LAZYTIME
182 #define MS_LAZYTIME (1<<25)
183 #endif
184
185 #ifndef SCM_SECURITY
186 #define SCM_SECURITY 0x03
187 #endif
188
189 #ifndef PR_SET_NO_NEW_PRIVS
190 #define PR_SET_NO_NEW_PRIVS 38
191 #endif
192
193 #ifndef PR_SET_CHILD_SUBREAPER
194 #define PR_SET_CHILD_SUBREAPER 36
195 #endif
196
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
213 #ifndef DM_DEFERRED_REMOVE
214 #define DM_DEFERRED_REMOVE (1 << 17)
215 #endif
216
217 #ifndef MAX_HANDLE_SZ
218 #define MAX_HANDLE_SZ 128
219 #endif
220
221 #if ! HAVE_SECURE_GETENV
222 # if HAVE___SECURE_GETENV
223 # define secure_getenv __secure_getenv
224 # else
225 # error "neither secure_getenv nor __secure_getenv are available"
226 # endif
227 #endif
228
229 #ifndef CIFS_MAGIC_NUMBER
230 # define CIFS_MAGIC_NUMBER 0xFF534D42
231 #endif
232
233 #ifndef TFD_TIMER_CANCEL_ON_SET
234 # define TFD_TIMER_CANCEL_ON_SET (1 << 1)
235 #endif
236
237 #ifndef SO_REUSEPORT
238 # define SO_REUSEPORT 15
239 #endif
240
241 #ifndef SO_PEERGROUPS
242 # define SO_PEERGROUPS 59
243 #endif
244
245 #ifndef DRM_IOCTL_SET_MASTER
246 # define DRM_IOCTL_SET_MASTER _IO('d', 0x1e)
247 #endif
248
249 #ifndef DRM_IOCTL_DROP_MASTER
250 # define DRM_IOCTL_DROP_MASTER _IO('d', 0x1f)
251 #endif
252
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 */
259
260 #ifndef __O_TMPFILE
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
268 #define __O_TMPFILE 020000000
269 #endif
270 #endif
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
277 #ifndef BPF_XOR
278 #define BPF_XOR 0xa0
279 #endif
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
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
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
321
322 #ifndef RENAME_NOREPLACE
323 #define RENAME_NOREPLACE (1 << 0)
324 #endif
325
326 #ifndef KCMP_FILE
327 #define KCMP_FILE 0
328 #endif
329
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
345
346 #if !HAVE_CHAR32_T
347 #define char32_t uint32_t
348 #endif
349
350 #if !HAVE_CHAR16_T
351 #define char16_t uint16_t
352 #endif
353
354 #ifndef ETHERTYPE_LLDP
355 #define ETHERTYPE_LLDP 0x88cc
356 #endif
357
358 #ifndef SOL_ALG
359 #define SOL_ALG 279
360 #endif
361
362 #ifndef AF_VSOCK
363 #define AF_VSOCK 40
364 #endif
365
366 #ifndef EXT4_IOC_RESIZE_FS
367 # define EXT4_IOC_RESIZE_FS _IOW('f', 16, __u64)
368 #endif
369
370 #ifndef NS_GET_NSTYPE
371 #define NS_GET_NSTYPE _IO(0xb7, 0x3)
372 #endif
373
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
382 #ifndef PF_KTHREAD
383 #define PF_KTHREAD 0x00200000
384 #endif
385
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
393 #include "missing_btrfs_tree.h"
394 #include "missing_input.h"
395 #include "missing_magic.h"
396 #include "missing_network.h"
397
398 #include "missing_syscall.h"