]>
Commit | Line | Data |
---|---|---|
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/input.h> |
8ae4b6d1 | 13 | #include <linux/oom.h> |
43a6a52e | 14 | #include <net/ethernet.h> |
8ae4b6d1 TG |
15 | #include <stdlib.h> |
16 | #include <sys/resource.h> | |
4e0399e6 | 17 | #include <sys/socket.h> |
4c2e1b39 | 18 | #include <sys/stat.h> |
8ae4b6d1 | 19 | #include <sys/syscall.h> |
c932fb71 | 20 | #include <uchar.h> |
8ae4b6d1 | 21 | #include <unistd.h> |
dd6c17b1 | 22 | |
9c869d08 | 23 | #if WANT_LINUX_STAT_H |
75720bff FB |
24 | #include <linux/stat.h> |
25 | #endif | |
26 | ||
349cc4a5 | 27 | #if HAVE_AUDIT |
dd6c17b1 LP |
28 | #include <libaudit.h> |
29 | #endif | |
b9f880f4 | 30 | |
d59d0a2b | 31 | #ifdef ARCH_MIPS |
32 | #include <asm/sgidefs.h> | |
33 | #endif | |
34 | ||
349cc4a5 | 35 | #if HAVE_LINUX_BTRFS_H |
700c6087 LP |
36 | #include <linux/btrfs.h> |
37 | #endif | |
38 | ||
349cc4a5 | 39 | #if HAVE_LINUX_VM_SOCKETS_H |
4e0399e6 SH |
40 | #include <linux/vm_sockets.h> |
41 | #else | |
42 | #define VMADDR_CID_ANY -1U | |
43 | struct sockaddr_vm { | |
44 | unsigned short svm_family; | |
45 | unsigned short svm_reserved1; | |
46 | unsigned int svm_port; | |
47 | unsigned int svm_cid; | |
48 | unsigned char svm_zero[sizeof(struct sockaddr) - | |
49 | sizeof(unsigned short) - | |
50 | sizeof(unsigned short) - | |
51 | sizeof(unsigned int) - | |
52 | sizeof(unsigned int)]; | |
53 | }; | |
54 | #endif /* !HAVE_LINUX_VM_SOCKETS_H */ | |
55 | ||
b9f880f4 LP |
56 | #ifndef RLIMIT_RTTIME |
57 | #define RLIMIT_RTTIME 15 | |
58 | #endif | |
59 | ||
517d56b1 LP |
60 | /* If RLIMIT_RTTIME is not defined, then we cannot use RLIMIT_NLIMITS as is */ |
61 | #define _RLIMIT_MAX (RLIMIT_RTTIME+1 > RLIMIT_NLIMITS ? RLIMIT_RTTIME+1 : RLIMIT_NLIMITS) | |
62 | ||
4fd5948e LP |
63 | #ifndef F_LINUX_SPECIFIC_BASE |
64 | #define F_LINUX_SPECIFIC_BASE 1024 | |
65 | #endif | |
66 | ||
67 | #ifndef F_SETPIPE_SZ | |
68 | #define F_SETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 7) | |
69 | #endif | |
70 | ||
71 | #ifndef F_GETPIPE_SZ | |
72 | #define F_GETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 8) | |
73 | #endif | |
74 | ||
a6082d77 DM |
75 | #ifndef F_ADD_SEALS |
76 | #define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9) | |
a6082d77 | 77 | #define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10) |
a6082d77 | 78 | |
a6082d77 | 79 | #define F_SEAL_SEAL 0x0001 /* prevent further seals from being set */ |
a6082d77 | 80 | #define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */ |
a6082d77 | 81 | #define F_SEAL_GROW 0x0004 /* prevent file from growing */ |
a6082d77 DM |
82 | #define F_SEAL_WRITE 0x0008 /* prevent writes */ |
83 | #endif | |
84 | ||
f4a53250 MM |
85 | #ifndef F_OFD_GETLK |
86 | #define F_OFD_GETLK 36 | |
87 | #define F_OFD_SETLK 37 | |
88 | #define F_OFD_SETLKW 38 | |
89 | #endif | |
90 | ||
a6082d77 | 91 | #ifndef MFD_ALLOW_SEALING |
45071fca LP |
92 | #define MFD_ALLOW_SEALING 0x0002U |
93 | #endif | |
94 | ||
95 | #ifndef MFD_CLOEXEC | |
96 | #define MFD_CLOEXEC 0x0001U | |
a6082d77 DM |
97 | #endif |
98 | ||
16c42ce1 KS |
99 | #ifndef IP_FREEBIND |
100 | #define IP_FREEBIND 15 | |
101 | #endif | |
102 | ||
dd6c17b1 LP |
103 | #ifndef OOM_SCORE_ADJ_MIN |
104 | #define OOM_SCORE_ADJ_MIN (-1000) | |
105 | #endif | |
106 | ||
107 | #ifndef OOM_SCORE_ADJ_MAX | |
108 | #define OOM_SCORE_ADJ_MAX 1000 | |
109 | #endif | |
15ae422b | 110 | |
4927fcae | 111 | #ifndef AUDIT_SERVICE_START |
dd6c17b1 | 112 | #define AUDIT_SERVICE_START 1130 /* Service (daemon) start */ |
4927fcae LP |
113 | #endif |
114 | ||
115 | #ifndef AUDIT_SERVICE_STOP | |
dd6c17b1 | 116 | #define AUDIT_SERVICE_STOP 1131 /* Service (daemon) stop */ |
4927fcae LP |
117 | #endif |
118 | ||
6ea832a2 LP |
119 | #ifndef TIOCVHANGUP |
120 | #define TIOCVHANGUP 0x5437 | |
121 | #endif | |
122 | ||
b90865ba KS |
123 | #ifndef IP_TRANSPARENT |
124 | #define IP_TRANSPARENT 19 | |
125 | #endif | |
126 | ||
66269b05 TG |
127 | #ifndef SOL_NETLINK |
128 | #define SOL_NETLINK 270 | |
129 | #endif | |
130 | ||
9c5a882b TG |
131 | #ifndef NETLINK_LIST_MEMBERSHIPS |
132 | #define NETLINK_LIST_MEMBERSHIPS 9 | |
133 | #endif | |
134 | ||
62bc4efc SS |
135 | #ifndef SOL_SCTP |
136 | #define SOL_SCTP 132 | |
137 | #endif | |
138 | ||
97768fc5 LP |
139 | #ifndef GRND_NONBLOCK |
140 | #define GRND_NONBLOCK 0x0001 | |
141 | #endif | |
142 | ||
143 | #ifndef GRND_RANDOM | |
144 | #define GRND_RANDOM 0x0002 | |
145 | #endif | |
146 | ||
0f3be6ca LP |
147 | #ifndef FS_NOCOW_FL |
148 | #define FS_NOCOW_FL 0x00800000 | |
149 | #endif | |
150 | ||
4b357e15 MM |
151 | #ifndef BTRFS_IOCTL_MAGIC |
152 | #define BTRFS_IOCTL_MAGIC 0x94 | |
153 | #endif | |
154 | ||
155 | #ifndef BTRFS_PATH_NAME_MAX | |
156 | #define BTRFS_PATH_NAME_MAX 4087 | |
157 | #endif | |
158 | ||
159 | #ifndef BTRFS_DEVICE_PATH_NAME_MAX | |
160 | #define BTRFS_DEVICE_PATH_NAME_MAX 1024 | |
161 | #endif | |
162 | ||
163 | #ifndef BTRFS_FSID_SIZE | |
164 | #define BTRFS_FSID_SIZE 16 | |
165 | #endif | |
166 | ||
167 | #ifndef BTRFS_UUID_SIZE | |
168 | #define BTRFS_UUID_SIZE 16 | |
169 | #endif | |
170 | ||
8e8ba792 MO |
171 | #ifndef BTRFS_SUBVOL_RDONLY |
172 | #define BTRFS_SUBVOL_RDONLY (1ULL << 1) | |
173 | #endif | |
174 | ||
175 | #ifndef BTRFS_SUBVOL_NAME_MAX | |
176 | #define BTRFS_SUBVOL_NAME_MAX 4039 | |
177 | #endif | |
178 | ||
179 | #ifndef BTRFS_INO_LOOKUP_PATH_MAX | |
180 | #define BTRFS_INO_LOOKUP_PATH_MAX 4080 | |
181 | #endif | |
182 | ||
183 | #ifndef BTRFS_SEARCH_ARGS_BUFSIZE | |
184 | #define BTRFS_SEARCH_ARGS_BUFSIZE (4096 - sizeof(struct btrfs_ioctl_search_key)) | |
185 | #endif | |
186 | ||
3f952f92 LP |
187 | #ifndef BTRFS_QGROUP_LEVEL_SHIFT |
188 | #define BTRFS_QGROUP_LEVEL_SHIFT 48 | |
189 | #endif | |
190 | ||
9714c020 | 191 | #if !HAVE_LINUX_BTRFS_H |
122b7907 HGB |
192 | #define BTRFS_IOC_QGROUP_ASSIGN _IOW(BTRFS_IOCTL_MAGIC, 41, \ |
193 | struct btrfs_ioctl_qgroup_assign_args) | |
194 | #define BTRFS_IOC_QGROUP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 42, \ | |
195 | struct btrfs_ioctl_qgroup_create_args) | |
196 | #define BTRFS_IOC_QUOTA_RESCAN _IOW(BTRFS_IOCTL_MAGIC, 44, \ | |
197 | struct btrfs_ioctl_quota_rescan_args) | |
198 | #define BTRFS_IOC_QUOTA_RESCAN_STATUS _IOR(BTRFS_IOCTL_MAGIC, 45, \ | |
199 | struct btrfs_ioctl_quota_rescan_args) | |
200 | ||
201 | struct btrfs_ioctl_quota_rescan_args { | |
202 | __u64 flags; | |
203 | __u64 progress; | |
204 | __u64 reserved[6]; | |
205 | }; | |
206 | ||
207 | struct btrfs_ioctl_qgroup_assign_args { | |
208 | __u64 assign; | |
209 | __u64 src; | |
210 | __u64 dst; | |
211 | }; | |
212 | ||
213 | struct btrfs_ioctl_qgroup_create_args { | |
214 | __u64 create; | |
215 | __u64 qgroupid; | |
216 | }; | |
217 | ||
4b357e15 MM |
218 | struct btrfs_ioctl_vol_args { |
219 | int64_t fd; | |
220 | char name[BTRFS_PATH_NAME_MAX + 1]; | |
221 | }; | |
222 | ||
8e8ba792 MO |
223 | struct btrfs_qgroup_limit { |
224 | __u64 flags; | |
225 | __u64 max_rfer; | |
226 | __u64 max_excl; | |
227 | __u64 rsv_rfer; | |
228 | __u64 rsv_excl; | |
229 | }; | |
230 | ||
231 | struct btrfs_qgroup_inherit { | |
232 | __u64 flags; | |
233 | __u64 num_qgroups; | |
234 | __u64 num_ref_copies; | |
235 | __u64 num_excl_copies; | |
236 | struct btrfs_qgroup_limit lim; | |
237 | __u64 qgroups[0]; | |
238 | }; | |
239 | ||
d97fb408 MO |
240 | struct btrfs_ioctl_qgroup_limit_args { |
241 | __u64 qgroupid; | |
242 | struct btrfs_qgroup_limit lim; | |
243 | }; | |
244 | ||
8e8ba792 MO |
245 | struct btrfs_ioctl_vol_args_v2 { |
246 | __s64 fd; | |
247 | __u64 transid; | |
248 | __u64 flags; | |
249 | union { | |
250 | struct { | |
251 | __u64 size; | |
252 | struct btrfs_qgroup_inherit *qgroup_inherit; | |
253 | }; | |
254 | __u64 unused[4]; | |
255 | }; | |
256 | char name[BTRFS_SUBVOL_NAME_MAX + 1]; | |
257 | }; | |
258 | ||
4b357e15 MM |
259 | struct btrfs_ioctl_dev_info_args { |
260 | uint64_t devid; /* in/out */ | |
261 | uint8_t uuid[BTRFS_UUID_SIZE]; /* in/out */ | |
262 | uint64_t bytes_used; /* out */ | |
263 | uint64_t total_bytes; /* out */ | |
264 | uint64_t unused[379]; /* pad to 4k */ | |
265 | char path[BTRFS_DEVICE_PATH_NAME_MAX]; /* out */ | |
266 | }; | |
267 | ||
268 | struct btrfs_ioctl_fs_info_args { | |
269 | uint64_t max_id; /* out */ | |
270 | uint64_t num_devices; /* out */ | |
271 | uint8_t fsid[BTRFS_FSID_SIZE]; /* out */ | |
272 | uint64_t reserved[124]; /* pad to 1k */ | |
273 | }; | |
8e8ba792 MO |
274 | |
275 | struct btrfs_ioctl_ino_lookup_args { | |
276 | __u64 treeid; | |
277 | __u64 objectid; | |
278 | char name[BTRFS_INO_LOOKUP_PATH_MAX]; | |
279 | }; | |
280 | ||
281 | struct btrfs_ioctl_search_key { | |
282 | /* which root are we searching. 0 is the tree of tree roots */ | |
283 | __u64 tree_id; | |
284 | ||
285 | /* keys returned will be >= min and <= max */ | |
286 | __u64 min_objectid; | |
287 | __u64 max_objectid; | |
288 | ||
289 | /* keys returned will be >= min and <= max */ | |
290 | __u64 min_offset; | |
291 | __u64 max_offset; | |
292 | ||
293 | /* max and min transids to search for */ | |
294 | __u64 min_transid; | |
295 | __u64 max_transid; | |
296 | ||
297 | /* keys returned will be >= min and <= max */ | |
298 | __u32 min_type; | |
299 | __u32 max_type; | |
300 | ||
301 | /* | |
302 | * how many items did userland ask for, and how many are we | |
303 | * returning | |
304 | */ | |
305 | __u32 nr_items; | |
306 | ||
307 | /* align to 64 bits */ | |
308 | __u32 unused; | |
309 | ||
310 | /* some extra for later */ | |
311 | __u64 unused1; | |
312 | __u64 unused2; | |
313 | __u64 unused3; | |
314 | __u64 unused4; | |
315 | }; | |
316 | ||
317 | struct btrfs_ioctl_search_header { | |
318 | __u64 transid; | |
319 | __u64 objectid; | |
320 | __u64 offset; | |
321 | __u32 type; | |
322 | __u32 len; | |
323 | }; | |
324 | ||
8e8ba792 MO |
325 | struct btrfs_ioctl_search_args { |
326 | struct btrfs_ioctl_search_key key; | |
327 | char buf[BTRFS_SEARCH_ARGS_BUFSIZE]; | |
328 | }; | |
329 | ||
330 | struct btrfs_ioctl_clone_range_args { | |
331 | __s64 src_fd; | |
332 | __u64 src_offset, src_length; | |
333 | __u64 dest_offset; | |
334 | }; | |
d97fb408 MO |
335 | |
336 | #define BTRFS_QUOTA_CTL_ENABLE 1 | |
337 | #define BTRFS_QUOTA_CTL_DISABLE 2 | |
338 | #define BTRFS_QUOTA_CTL_RESCAN__NOTUSED 3 | |
339 | struct btrfs_ioctl_quota_ctl_args { | |
340 | __u64 cmd; | |
341 | __u64 status; | |
342 | }; | |
9714c020 | 343 | #endif /* !HAVE_LINUX_BTRFS_H */ |
4b357e15 MM |
344 | |
345 | #ifndef BTRFS_IOC_DEFRAG | |
7bed7f0e ZJS |
346 | #define BTRFS_IOC_DEFRAG _IOW(BTRFS_IOCTL_MAGIC, 2, \ |
347 | struct btrfs_ioctl_vol_args) | |
4b357e15 MM |
348 | #endif |
349 | ||
d97fb408 MO |
350 | #ifndef BTRFS_IOC_RESIZE |
351 | #define BTRFS_IOC_RESIZE _IOW(BTRFS_IOCTL_MAGIC, 3, \ | |
352 | struct btrfs_ioctl_vol_args) | |
353 | #endif | |
354 | ||
8e8ba792 MO |
355 | #ifndef BTRFS_IOC_CLONE |
356 | #define BTRFS_IOC_CLONE _IOW(BTRFS_IOCTL_MAGIC, 9, int) | |
357 | #endif | |
358 | ||
359 | #ifndef BTRFS_IOC_CLONE_RANGE | |
360 | #define BTRFS_IOC_CLONE_RANGE _IOW(BTRFS_IOCTL_MAGIC, 13, \ | |
361 | struct btrfs_ioctl_clone_range_args) | |
362 | #endif | |
363 | ||
364 | #ifndef BTRFS_IOC_SUBVOL_CREATE | |
365 | #define BTRFS_IOC_SUBVOL_CREATE _IOW(BTRFS_IOCTL_MAGIC, 14, \ | |
366 | struct btrfs_ioctl_vol_args) | |
367 | #endif | |
368 | ||
369 | #ifndef BTRFS_IOC_SNAP_DESTROY | |
370 | #define BTRFS_IOC_SNAP_DESTROY _IOW(BTRFS_IOCTL_MAGIC, 15, \ | |
371 | struct btrfs_ioctl_vol_args) | |
372 | #endif | |
373 | ||
374 | #ifndef BTRFS_IOC_TREE_SEARCH | |
375 | #define BTRFS_IOC_TREE_SEARCH _IOWR(BTRFS_IOCTL_MAGIC, 17, \ | |
376 | struct btrfs_ioctl_search_args) | |
377 | #endif | |
378 | ||
379 | #ifndef BTRFS_IOC_INO_LOOKUP | |
380 | #define BTRFS_IOC_INO_LOOKUP _IOWR(BTRFS_IOCTL_MAGIC, 18, \ | |
381 | struct btrfs_ioctl_ino_lookup_args) | |
382 | #endif | |
383 | ||
384 | #ifndef BTRFS_IOC_SNAP_CREATE_V2 | |
385 | #define BTRFS_IOC_SNAP_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 23, \ | |
386 | struct btrfs_ioctl_vol_args_v2) | |
387 | #endif | |
388 | ||
389 | #ifndef BTRFS_IOC_SUBVOL_GETFLAGS | |
390 | #define BTRFS_IOC_SUBVOL_GETFLAGS _IOR(BTRFS_IOCTL_MAGIC, 25, __u64) | |
391 | #endif | |
392 | ||
393 | #ifndef BTRFS_IOC_SUBVOL_SETFLAGS | |
394 | #define BTRFS_IOC_SUBVOL_SETFLAGS _IOW(BTRFS_IOCTL_MAGIC, 26, __u64) | |
395 | #endif | |
396 | ||
4b357e15 MM |
397 | #ifndef BTRFS_IOC_DEV_INFO |
398 | #define BTRFS_IOC_DEV_INFO _IOWR(BTRFS_IOCTL_MAGIC, 30, \ | |
399 | struct btrfs_ioctl_dev_info_args) | |
400 | #endif | |
401 | ||
402 | #ifndef BTRFS_IOC_FS_INFO | |
403 | #define BTRFS_IOC_FS_INFO _IOR(BTRFS_IOCTL_MAGIC, 31, \ | |
7bed7f0e ZJS |
404 | struct btrfs_ioctl_fs_info_args) |
405 | #endif | |
406 | ||
407 | #ifndef BTRFS_IOC_DEVICES_READY | |
408 | #define BTRFS_IOC_DEVICES_READY _IOR(BTRFS_IOCTL_MAGIC, 39, \ | |
409 | struct btrfs_ioctl_vol_args) | |
4b357e15 MM |
410 | #endif |
411 | ||
d97fb408 MO |
412 | #ifndef BTRFS_IOC_QUOTA_CTL |
413 | #define BTRFS_IOC_QUOTA_CTL _IOWR(BTRFS_IOCTL_MAGIC, 40, \ | |
414 | struct btrfs_ioctl_quota_ctl_args) | |
415 | #endif | |
416 | ||
417 | #ifndef BTRFS_IOC_QGROUP_LIMIT | |
418 | #define BTRFS_IOC_QGROUP_LIMIT _IOR(BTRFS_IOCTL_MAGIC, 43, \ | |
419 | struct btrfs_ioctl_qgroup_limit_args) | |
420 | #endif | |
421 | ||
306578e5 SS |
422 | #ifndef BTRFS_IOC_QUOTA_RESCAN_WAIT |
423 | #define BTRFS_IOC_QUOTA_RESCAN_WAIT _IO(BTRFS_IOCTL_MAGIC, 46) | |
424 | #endif | |
425 | ||
10f9c755 LP |
426 | #ifndef BTRFS_FIRST_FREE_OBJECTID |
427 | #define BTRFS_FIRST_FREE_OBJECTID 256 | |
428 | #endif | |
429 | ||
d9e2daaf LP |
430 | #ifndef BTRFS_LAST_FREE_OBJECTID |
431 | #define BTRFS_LAST_FREE_OBJECTID -256ULL | |
432 | #endif | |
433 | ||
b6b18498 LP |
434 | #ifndef BTRFS_ROOT_TREE_OBJECTID |
435 | #define BTRFS_ROOT_TREE_OBJECTID 1 | |
436 | #endif | |
437 | ||
438 | #ifndef BTRFS_QUOTA_TREE_OBJECTID | |
439 | #define BTRFS_QUOTA_TREE_OBJECTID 8ULL | |
440 | #endif | |
441 | ||
10f9c755 LP |
442 | #ifndef BTRFS_ROOT_ITEM_KEY |
443 | #define BTRFS_ROOT_ITEM_KEY 132 | |
444 | #endif | |
445 | ||
b6b18498 LP |
446 | #ifndef BTRFS_QGROUP_STATUS_KEY |
447 | #define BTRFS_QGROUP_STATUS_KEY 240 | |
448 | #endif | |
449 | ||
450 | #ifndef BTRFS_QGROUP_INFO_KEY | |
451 | #define BTRFS_QGROUP_INFO_KEY 242 | |
452 | #endif | |
453 | ||
454 | #ifndef BTRFS_QGROUP_LIMIT_KEY | |
455 | #define BTRFS_QGROUP_LIMIT_KEY 244 | |
456 | #endif | |
457 | ||
5bcd08db LP |
458 | #ifndef BTRFS_QGROUP_RELATION_KEY |
459 | #define BTRFS_QGROUP_RELATION_KEY 246 | |
460 | #endif | |
461 | ||
d9e2daaf LP |
462 | #ifndef BTRFS_ROOT_BACKREF_KEY |
463 | #define BTRFS_ROOT_BACKREF_KEY 144 | |
464 | #endif | |
465 | ||
746f8906 LP |
466 | #ifndef BTRFS_SUPER_MAGIC |
467 | #define BTRFS_SUPER_MAGIC 0x9123683E | |
468 | #endif | |
469 | ||
efdb0237 LP |
470 | #ifndef CGROUP_SUPER_MAGIC |
471 | #define CGROUP_SUPER_MAGIC 0x27e0eb | |
472 | #endif | |
473 | ||
09961995 AC |
474 | #ifndef CGROUP2_SUPER_MAGIC |
475 | #define CGROUP2_SUPER_MAGIC 0x63677270 | |
476 | #endif | |
477 | ||
3228995c CB |
478 | #ifndef CLONE_NEWCGROUP |
479 | #define CLONE_NEWCGROUP 0x02000000 | |
480 | #endif | |
481 | ||
efdb0237 LP |
482 | #ifndef TMPFS_MAGIC |
483 | #define TMPFS_MAGIC 0x01021994 | |
484 | #endif | |
485 | ||
88cd066e LP |
486 | #ifndef MQUEUE_MAGIC |
487 | #define MQUEUE_MAGIC 0x19800202 | |
488 | #endif | |
489 | ||
87c05f36 DH |
490 | #ifndef SECURITYFS_MAGIC |
491 | #define SECURITYFS_MAGIC 0x73636673 | |
492 | #endif | |
493 | ||
494 | #ifndef TRACEFS_MAGIC | |
495 | #define TRACEFS_MAGIC 0x74726163 | |
496 | #endif | |
497 | ||
498 | #ifndef BPF_FS_MAGIC | |
499 | #define BPF_FS_MAGIC 0xcafe4a11 | |
500 | #endif | |
501 | ||
77f9fa3b LP |
502 | #ifndef OCFS2_SUPER_MAGIC |
503 | #define OCFS2_SUPER_MAGIC 0x7461636f | |
504 | #endif | |
505 | ||
94d82985 LP |
506 | #ifndef MS_MOVE |
507 | #define MS_MOVE 8192 | |
508 | #endif | |
509 | ||
7ef71470 ZJS |
510 | #ifndef MS_REC |
511 | #define MS_REC 16384 | |
512 | #endif | |
513 | ||
7cb1094a | 514 | #ifndef MS_PRIVATE |
7ef71470 | 515 | #define MS_PRIVATE (1<<18) |
7cb1094a HH |
516 | #endif |
517 | ||
7ef71470 ZJS |
518 | #ifndef MS_REC |
519 | #define MS_REC (1<<19) | |
520 | #endif | |
521 | ||
522 | #ifndef MS_SHARED | |
523 | #define MS_SHARED (1<<20) | |
524 | #endif | |
525 | ||
526 | #ifndef MS_RELATIME | |
527 | #define MS_RELATIME (1<<21) | |
528 | #endif | |
529 | ||
530 | #ifndef MS_KERNMOUNT | |
531 | #define MS_KERNMOUNT (1<<22) | |
532 | #endif | |
533 | ||
534 | #ifndef MS_I_VERSION | |
535 | #define MS_I_VERSION (1<<23) | |
54ecda32 LP |
536 | #endif |
537 | ||
48ac500b | 538 | #ifndef MS_STRICTATIME |
7ef71470 | 539 | #define MS_STRICTATIME (1<<24) |
48ac500b LP |
540 | #endif |
541 | ||
7ef71470 ZJS |
542 | #ifndef MS_LAZYTIME |
543 | #define MS_LAZYTIME (1<<25) | |
a9621528 AM |
544 | #endif |
545 | ||
7ef71470 ZJS |
546 | #ifndef SCM_SECURITY |
547 | #define SCM_SECURITY 0x03 | |
a9621528 AM |
548 | #endif |
549 | ||
8351ceae LP |
550 | #ifndef PR_SET_NO_NEW_PRIVS |
551 | #define PR_SET_NO_NEW_PRIVS 38 | |
552 | #endif | |
d4447f4d AK |
553 | |
554 | #ifndef PR_SET_CHILD_SUBREAPER | |
555 | #define PR_SET_CHILD_SUBREAPER 36 | |
556 | #endif | |
a8348796 | 557 | |
80ebe5c2 HGB |
558 | #ifndef PR_SET_MM_ARG_START |
559 | #define PR_SET_MM_ARG_START 8 | |
560 | #endif | |
561 | ||
562 | #ifndef PR_SET_MM_ARG_END | |
563 | #define PR_SET_MM_ARG_END 9 | |
564 | #endif | |
565 | ||
566 | #ifndef PR_SET_MM_ENV_START | |
567 | #define PR_SET_MM_ENV_START 10 | |
568 | #endif | |
569 | ||
570 | #ifndef PR_SET_MM_ENV_END | |
571 | #define PR_SET_MM_ENV_END 11 | |
572 | #endif | |
573 | ||
1381f244 HGB |
574 | #ifndef EFIVARFS_MAGIC |
575 | #define EFIVARFS_MAGIC 0xde5e81e4 | |
576 | #endif | |
577 | ||
8cbe9f06 HGB |
578 | #ifndef SMACK_MAGIC |
579 | #define SMACK_MAGIC 0x43415d53 | |
580 | #endif | |
581 | ||
ffc01f06 HGB |
582 | #ifndef DM_DEFERRED_REMOVE |
583 | #define DM_DEFERRED_REMOVE (1 << 17) | |
584 | #endif | |
585 | ||
56766f99 HGB |
586 | #ifndef MAX_HANDLE_SZ |
587 | #define MAX_HANDLE_SZ 128 | |
588 | #endif | |
589 | ||
349cc4a5 ZJS |
590 | #if ! HAVE_SECURE_GETENV |
591 | # if HAVE___SECURE_GETENV | |
4db17f29 ZJS |
592 | # define secure_getenv __secure_getenv |
593 | # else | |
66330455 | 594 | # error "neither secure_getenv nor __secure_getenv are available" |
4db17f29 ZJS |
595 | # endif |
596 | #endif | |
85210bff LP |
597 | |
598 | #ifndef CIFS_MAGIC_NUMBER | |
65b3903f | 599 | # define CIFS_MAGIC_NUMBER 0xFF534D42 |
85210bff | 600 | #endif |
8742514c LP |
601 | |
602 | #ifndef TFD_TIMER_CANCEL_ON_SET | |
65b3903f | 603 | # define TFD_TIMER_CANCEL_ON_SET (1 << 1) |
8742514c | 604 | #endif |
f7db7a69 SL |
605 | |
606 | #ifndef SO_REUSEPORT | |
65b3903f | 607 | # define SO_REUSEPORT 15 |
f7db7a69 | 608 | #endif |
118ecf32 | 609 | |
43f2c88d LP |
610 | #ifndef SO_PEERGROUPS |
611 | # define SO_PEERGROUPS 59 | |
612 | #endif | |
613 | ||
118ecf32 | 614 | #ifndef EVIOCREVOKE |
65b3903f | 615 | # define EVIOCREVOKE _IOW('E', 0x91, int) |
118ecf32 DH |
616 | #endif |
617 | ||
d5dd44b0 LP |
618 | #ifndef EVIOCSMASK |
619 | ||
620 | struct input_mask { | |
621 | uint32_t type; | |
622 | uint32_t codes_size; | |
623 | uint64_t codes_ptr; | |
624 | }; | |
625 | ||
626 | #define EVIOCSMASK _IOW('E', 0x93, struct input_mask) | |
627 | #endif | |
628 | ||
118ecf32 | 629 | #ifndef DRM_IOCTL_SET_MASTER |
65b3903f | 630 | # define DRM_IOCTL_SET_MASTER _IO('d', 0x1e) |
118ecf32 DH |
631 | #endif |
632 | ||
633 | #ifndef DRM_IOCTL_DROP_MASTER | |
65b3903f ZJS |
634 | # define DRM_IOCTL_DROP_MASTER _IO('d', 0x1f) |
635 | #endif | |
636 | ||
daad709a YM |
637 | /* The precise definition of __O_TMPFILE is arch specific; use the |
638 | * values defined by the kernel (note: some are hexa, some are octal, | |
639 | * duplicated as-is from the kernel definitions): | |
640 | * - alpha, parisc, sparc: each has a specific value; | |
641 | * - others: they use the "generic" value. | |
642 | */ | |
c09918f9 LP |
643 | |
644 | #ifndef __O_TMPFILE | |
daad709a YM |
645 | #if defined(__alpha__) |
646 | #define __O_TMPFILE 0100000000 | |
647 | #elif defined(__parisc__) || defined(__hppa__) | |
648 | #define __O_TMPFILE 0400000000 | |
649 | #elif defined(__sparc__) || defined(__sparc64__) | |
650 | #define __O_TMPFILE 0x2000000 | |
651 | #else | |
c09918f9 LP |
652 | #define __O_TMPFILE 020000000 |
653 | #endif | |
d5df18e4 | 654 | #endif |
c09918f9 LP |
655 | |
656 | /* a horrid kludge trying to make sure that this will fail on old kernels */ | |
657 | #ifndef O_TMPFILE | |
658 | #define O_TMPFILE (__O_TMPFILE | O_DIRECTORY) | |
659 | #endif | |
660 | ||
7965435e | 661 | #ifndef BPF_XOR |
9714c020 | 662 | #define BPF_XOR 0xa0 |
7965435e | 663 | #endif |
a5f03596 LP |
664 | |
665 | /* Note that LOOPBACK_IFINDEX is currently not exported by the | |
666 | * kernel/glibc, but hardcoded internally by the kernel. However, as | |
667 | * it is exported to userspace indirectly via rtnetlink and the | |
668 | * ioctls, and made use of widely we define it here too, in a way that | |
669 | * is compatible with the kernel's internal definition. */ | |
670 | #ifndef LOOPBACK_IFINDEX | |
671 | #define LOOPBACK_IFINDEX 1 | |
672 | #endif | |
875c2e22 LP |
673 | |
674 | #ifndef MAX_AUDIT_MESSAGE_LENGTH | |
675 | #define MAX_AUDIT_MESSAGE_LENGTH 8970 | |
676 | #endif | |
677 | ||
678 | #ifndef AUDIT_NLGRP_MAX | |
679 | #define AUDIT_NLGRP_READLOG 1 | |
680 | #endif | |
2822da4f LP |
681 | |
682 | #ifndef CAP_MAC_OVERRIDE | |
683 | #define CAP_MAC_OVERRIDE 32 | |
684 | #endif | |
685 | ||
686 | #ifndef CAP_MAC_ADMIN | |
687 | #define CAP_MAC_ADMIN 33 | |
688 | #endif | |
689 | ||
690 | #ifndef CAP_SYSLOG | |
691 | #define CAP_SYSLOG 34 | |
692 | #endif | |
693 | ||
694 | #ifndef CAP_WAKE_ALARM | |
695 | #define CAP_WAKE_ALARM 35 | |
696 | #endif | |
697 | ||
698 | #ifndef CAP_BLOCK_SUSPEND | |
699 | #define CAP_BLOCK_SUSPEND 36 | |
700 | #endif | |
701 | ||
702 | #ifndef CAP_AUDIT_READ | |
703 | #define CAP_AUDIT_READ 37 | |
704 | #endif | |
60e1651a | 705 | |
ebd93cb6 LP |
706 | #ifndef RENAME_NOREPLACE |
707 | #define RENAME_NOREPLACE (1 << 0) | |
708 | #endif | |
f7ad54a3 | 709 | |
f7ad54a3 LP |
710 | #ifndef KCMP_FILE |
711 | #define KCMP_FILE 0 | |
712 | #endif | |
606df97b PH |
713 | |
714 | #ifndef INPUT_PROP_POINTING_STICK | |
715 | #define INPUT_PROP_POINTING_STICK 0x05 | |
716 | #endif | |
bd1acc9f HG |
717 | |
718 | #ifndef INPUT_PROP_ACCELEROMETER | |
719 | #define INPUT_PROP_ACCELEROMETER 0x06 | |
720 | #endif | |
e287086b | 721 | |
ea7a562a PH |
722 | #ifndef BTN_DPAD_UP |
723 | #define BTN_DPAD_UP 0x220 | |
724 | #define BTN_DPAD_RIGHT 0x223 | |
725 | #endif | |
726 | ||
727 | #ifndef KEY_ALS_TOGGLE | |
728 | #define KEY_ALS_TOGGLE 0x230 | |
729 | #endif | |
730 | ||
e287086b | 731 | typedef int32_t key_serial_t; |
e287086b | 732 | |
74dd6b51 LP |
733 | #ifndef KEYCTL_JOIN_SESSION_KEYRING |
734 | #define KEYCTL_JOIN_SESSION_KEYRING 1 | |
735 | #endif | |
736 | ||
737 | #ifndef KEYCTL_CHOWN | |
738 | #define KEYCTL_CHOWN 4 | |
739 | #endif | |
740 | ||
741 | #ifndef KEYCTL_SETPERM | |
742 | #define KEYCTL_SETPERM 5 | |
743 | #endif | |
744 | ||
745 | #ifndef KEYCTL_DESCRIBE | |
746 | #define KEYCTL_DESCRIBE 6 | |
747 | #endif | |
748 | ||
b1edf445 LP |
749 | #ifndef KEYCTL_LINK |
750 | #define KEYCTL_LINK 8 | |
751 | #endif | |
752 | ||
e287086b LP |
753 | #ifndef KEYCTL_READ |
754 | #define KEYCTL_READ 11 | |
755 | #endif | |
756 | ||
757 | #ifndef KEYCTL_SET_TIMEOUT | |
758 | #define KEYCTL_SET_TIMEOUT 15 | |
759 | #endif | |
760 | ||
74dd6b51 LP |
761 | #ifndef KEY_POS_VIEW |
762 | #define KEY_POS_VIEW 0x01000000 | |
763 | #define KEY_POS_READ 0x02000000 | |
764 | #define KEY_POS_WRITE 0x04000000 | |
765 | #define KEY_POS_SEARCH 0x08000000 | |
766 | #define KEY_POS_LINK 0x10000000 | |
767 | #define KEY_POS_SETATTR 0x20000000 | |
768 | ||
769 | #define KEY_USR_VIEW 0x00010000 | |
770 | #define KEY_USR_READ 0x00020000 | |
771 | #define KEY_USR_WRITE 0x00040000 | |
772 | #define KEY_USR_SEARCH 0x00080000 | |
773 | #define KEY_USR_LINK 0x00100000 | |
774 | #define KEY_USR_SETATTR 0x00200000 | |
775 | ||
776 | #define KEY_GRP_VIEW 0x00000100 | |
777 | #define KEY_GRP_READ 0x00000200 | |
778 | #define KEY_GRP_WRITE 0x00000400 | |
779 | #define KEY_GRP_SEARCH 0x00000800 | |
780 | #define KEY_GRP_LINK 0x00001000 | |
781 | #define KEY_GRP_SETATTR 0x00002000 | |
782 | ||
783 | #define KEY_OTH_VIEW 0x00000001 | |
784 | #define KEY_OTH_READ 0x00000002 | |
785 | #define KEY_OTH_WRITE 0x00000004 | |
786 | #define KEY_OTH_SEARCH 0x00000008 | |
787 | #define KEY_OTH_LINK 0x00000010 | |
788 | #define KEY_OTH_SETATTR 0x00000020 | |
789 | #endif | |
790 | ||
e287086b LP |
791 | #ifndef KEY_SPEC_USER_KEYRING |
792 | #define KEY_SPEC_USER_KEYRING -4 | |
793 | #endif | |
755d4b67 | 794 | |
74dd6b51 LP |
795 | #ifndef KEY_SPEC_SESSION_KEYRING |
796 | #define KEY_SPEC_SESSION_KEYRING -3 | |
797 | #endif | |
798 | ||
755d4b67 IP |
799 | #ifndef PR_CAP_AMBIENT |
800 | #define PR_CAP_AMBIENT 47 | |
801 | #endif | |
802 | ||
803 | #ifndef PR_CAP_AMBIENT_IS_SET | |
804 | #define PR_CAP_AMBIENT_IS_SET 1 | |
805 | #endif | |
806 | ||
807 | #ifndef PR_CAP_AMBIENT_RAISE | |
808 | #define PR_CAP_AMBIENT_RAISE 2 | |
809 | #endif | |
810 | ||
811 | #ifndef PR_CAP_AMBIENT_CLEAR_ALL | |
812 | #define PR_CAP_AMBIENT_CLEAR_ALL 4 | |
813 | #endif | |
6955a3ba | 814 | |
9714c020 | 815 | #if !HAVE_CHAR32_T |
c932fb71 SL |
816 | #define char32_t uint32_t |
817 | #endif | |
818 | ||
9714c020 | 819 | #if !HAVE_CHAR16_T |
c932fb71 SL |
820 | #define char16_t uint16_t |
821 | #endif | |
822 | ||
43a6a52e LP |
823 | #ifndef ETHERTYPE_LLDP |
824 | #define ETHERTYPE_LLDP 0x88cc | |
825 | #endif | |
826 | ||
0fe5f3c5 LP |
827 | #ifndef SOL_ALG |
828 | #define SOL_ALG 279 | |
829 | #endif | |
830 | ||
4e0399e6 SH |
831 | #ifndef AF_VSOCK |
832 | #define AF_VSOCK 40 | |
833 | #endif | |
834 | ||
80750adb ZJS |
835 | #ifndef EXT4_IOC_RESIZE_FS |
836 | # define EXT4_IOC_RESIZE_FS _IOW('f', 16, __u64) | |
837 | #endif | |
838 | ||
d7bea6b6 DP |
839 | #ifndef NSFS_MAGIC |
840 | #define NSFS_MAGIC 0x6e736673 | |
841 | #endif | |
842 | ||
843 | #ifndef NS_GET_NSTYPE | |
844 | #define NS_GET_NSTYPE _IO(0xb7, 0x3) | |
845 | #endif | |
846 | ||
43767d9d LP |
847 | #ifndef FALLOC_FL_KEEP_SIZE |
848 | #define FALLOC_FL_KEEP_SIZE 0x01 | |
849 | #endif | |
850 | ||
851 | #ifndef FALLOC_FL_PUNCH_HOLE | |
852 | #define FALLOC_FL_PUNCH_HOLE 0x02 | |
853 | #endif | |
854 | ||
36b5119a LP |
855 | #ifndef PF_KTHREAD |
856 | #define PF_KTHREAD 0x00200000 | |
857 | #endif | |
858 | ||
4c2e1b39 LP |
859 | #if ! HAVE_STRUCT_STATX |
860 | struct statx_timestamp { | |
861 | int64_t tv_sec; | |
862 | uint32_t tv_nsec; | |
863 | uint32_t __reserved; | |
864 | }; | |
865 | struct statx { | |
866 | uint32_t stx_mask; | |
867 | uint32_t stx_blksize; | |
868 | uint64_t stx_attributes; | |
869 | uint32_t stx_nlink; | |
870 | uint32_t stx_uid; | |
871 | uint32_t stx_gid; | |
872 | uint16_t stx_mode; | |
873 | uint16_t __spare0[1]; | |
874 | uint64_t stx_ino; | |
875 | uint64_t stx_size; | |
876 | uint64_t stx_blocks; | |
877 | uint64_t stx_attributes_mask; | |
878 | struct statx_timestamp stx_atime; | |
879 | struct statx_timestamp stx_btime; | |
880 | struct statx_timestamp stx_ctime; | |
881 | struct statx_timestamp stx_mtime; | |
882 | uint32_t stx_rdev_major; | |
883 | uint32_t stx_rdev_minor; | |
884 | uint32_t stx_dev_major; | |
885 | uint32_t stx_dev_minor; | |
886 | uint64_t __spare2[14]; | |
887 | }; | |
888 | #endif | |
889 | ||
890 | #ifndef STATX_BTIME | |
891 | #define STATX_BTIME 0x00000800U | |
892 | #endif | |
893 | ||
894 | #ifndef AT_STATX_DONT_SYNC | |
895 | #define AT_STATX_DONT_SYNC 0x4000 | |
896 | #endif | |
897 | ||
92f14395 LP |
898 | /* The maximum thread/process name length including trailing NUL byte. This mimics the kernel definition of the same |
899 | * name, which we need in userspace at various places but is not defined in userspace currently, neither under this | |
900 | * name nor any other. */ | |
901 | #ifndef TASK_COMM_LEN | |
902 | #define TASK_COMM_LEN 16 | |
903 | #endif | |
904 | ||
9714c020 | 905 | #include "missing_network.h" |
2f368e4a | 906 | #include "missing_syscall.h" |