]>
Commit | Line | Data |
---|---|---|
03467c88 | 1 | /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ |
15ae422b | 2 | |
c2f1db8f | 3 | #pragma once |
b9f880f4 | 4 | |
15ae422b LP |
5 | /*** |
6 | This file is part of systemd. | |
7 | ||
8 | Copyright 2010 Lennart Poettering | |
9 | ||
10 | systemd is free software; you can redistribute it and/or modify it | |
5430f7f2 LP |
11 | under the terms of the GNU Lesser General Public License as published by |
12 | the Free Software Foundation; either version 2.1 of the License, or | |
15ae422b LP |
13 | (at your option) any later version. |
14 | ||
15 | systemd is distributed in the hope that it will be useful, but | |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
5430f7f2 | 18 | Lesser General Public License for more details. |
15ae422b | 19 | |
5430f7f2 | 20 | You should have received a copy of the GNU Lesser General Public License |
15ae422b LP |
21 | along with systemd; If not, see <http://www.gnu.org/licenses/>. |
22 | ***/ | |
23 | ||
b9f880f4 LP |
24 | /* Missing glibc definitions to access certain kernel APIs */ |
25 | ||
3b794314 | 26 | #include <errno.h> |
8ae4b6d1 | 27 | #include <fcntl.h> |
875c2e22 | 28 | #include <linux/audit.h> |
2822da4f | 29 | #include <linux/capability.h> |
8ae4b6d1 TG |
30 | #include <linux/if_link.h> |
31 | #include <linux/input.h> | |
32 | #include <linux/loop.h> | |
cf1755ba | 33 | #include <linux/neighbour.h> |
8ae4b6d1 TG |
34 | #include <linux/oom.h> |
35 | #include <linux/rtnetlink.h> | |
36 | #include <stdlib.h> | |
37 | #include <sys/resource.h> | |
38 | #include <sys/syscall.h> | |
39 | #include <unistd.h> | |
dd6c17b1 LP |
40 | |
41 | #ifdef HAVE_AUDIT | |
42 | #include <libaudit.h> | |
43 | #endif | |
b9f880f4 | 44 | |
d59d0a2b | 45 | #ifdef ARCH_MIPS |
46 | #include <asm/sgidefs.h> | |
47 | #endif | |
48 | ||
700c6087 LP |
49 | #ifdef HAVE_LINUX_BTRFS_H |
50 | #include <linux/btrfs.h> | |
51 | #endif | |
52 | ||
a60e9f7f LP |
53 | #include "macro.h" |
54 | ||
b9f880f4 LP |
55 | #ifndef RLIMIT_RTTIME |
56 | #define RLIMIT_RTTIME 15 | |
57 | #endif | |
58 | ||
517d56b1 LP |
59 | /* If RLIMIT_RTTIME is not defined, then we cannot use RLIMIT_NLIMITS as is */ |
60 | #define _RLIMIT_MAX (RLIMIT_RTTIME+1 > RLIMIT_NLIMITS ? RLIMIT_RTTIME+1 : RLIMIT_NLIMITS) | |
61 | ||
4fd5948e LP |
62 | #ifndef F_LINUX_SPECIFIC_BASE |
63 | #define F_LINUX_SPECIFIC_BASE 1024 | |
64 | #endif | |
65 | ||
66 | #ifndef F_SETPIPE_SZ | |
67 | #define F_SETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 7) | |
68 | #endif | |
69 | ||
70 | #ifndef F_GETPIPE_SZ | |
71 | #define F_GETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 8) | |
72 | #endif | |
73 | ||
a6082d77 DM |
74 | #ifndef F_ADD_SEALS |
75 | #define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9) | |
a6082d77 | 76 | #define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10) |
a6082d77 | 77 | |
a6082d77 | 78 | #define F_SEAL_SEAL 0x0001 /* prevent further seals from being set */ |
a6082d77 | 79 | #define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */ |
a6082d77 | 80 | #define F_SEAL_GROW 0x0004 /* prevent file from growing */ |
a6082d77 DM |
81 | #define F_SEAL_WRITE 0x0008 /* prevent writes */ |
82 | #endif | |
83 | ||
f4a53250 MM |
84 | #ifndef F_OFD_GETLK |
85 | #define F_OFD_GETLK 36 | |
86 | #define F_OFD_SETLK 37 | |
87 | #define F_OFD_SETLKW 38 | |
88 | #endif | |
89 | ||
a6082d77 | 90 | #ifndef MFD_ALLOW_SEALING |
45071fca LP |
91 | #define MFD_ALLOW_SEALING 0x0002U |
92 | #endif | |
93 | ||
94 | #ifndef MFD_CLOEXEC | |
95 | #define MFD_CLOEXEC 0x0001U | |
a6082d77 DM |
96 | #endif |
97 | ||
16c42ce1 KS |
98 | #ifndef IP_FREEBIND |
99 | #define IP_FREEBIND 15 | |
100 | #endif | |
101 | ||
dd6c17b1 LP |
102 | #ifndef OOM_SCORE_ADJ_MIN |
103 | #define OOM_SCORE_ADJ_MIN (-1000) | |
104 | #endif | |
105 | ||
106 | #ifndef OOM_SCORE_ADJ_MAX | |
107 | #define OOM_SCORE_ADJ_MAX 1000 | |
108 | #endif | |
15ae422b | 109 | |
4927fcae | 110 | #ifndef AUDIT_SERVICE_START |
dd6c17b1 | 111 | #define AUDIT_SERVICE_START 1130 /* Service (daemon) start */ |
4927fcae LP |
112 | #endif |
113 | ||
114 | #ifndef AUDIT_SERVICE_STOP | |
dd6c17b1 | 115 | #define AUDIT_SERVICE_STOP 1131 /* Service (daemon) stop */ |
4927fcae LP |
116 | #endif |
117 | ||
6ea832a2 LP |
118 | #ifndef TIOCVHANGUP |
119 | #define TIOCVHANGUP 0x5437 | |
120 | #endif | |
121 | ||
b90865ba KS |
122 | #ifndef IP_TRANSPARENT |
123 | #define IP_TRANSPARENT 19 | |
124 | #endif | |
125 | ||
66269b05 TG |
126 | #ifndef SOL_NETLINK |
127 | #define SOL_NETLINK 270 | |
128 | #endif | |
129 | ||
9c5a882b TG |
130 | #ifndef NETLINK_LIST_MEMBERSHIPS |
131 | #define NETLINK_LIST_MEMBERSHIPS 9 | |
132 | #endif | |
133 | ||
a8348796 | 134 | #if !HAVE_DECL_PIVOT_ROOT |
dd6c17b1 LP |
135 | static inline int pivot_root(const char *new_root, const char *put_old) { |
136 | return syscall(SYS_pivot_root, new_root, put_old); | |
137 | } | |
a8348796 | 138 | #endif |
dd6c17b1 | 139 | |
b244d9f3 LP |
140 | #ifndef __NR_memfd_create |
141 | # if defined __x86_64__ | |
a6082d77 | 142 | # define __NR_memfd_create 319 |
b244d9f3 | 143 | # elif defined __arm__ |
a6082d77 | 144 | # define __NR_memfd_create 385 |
7fd68245 MO |
145 | # elif defined __aarch64__ |
146 | # define __NR_memfd_create 279 | |
7bcff8da HB |
147 | # elif defined __s390__ |
148 | # define __NR_memfd_create 350 | |
b244d9f3 | 149 | # elif defined _MIPS_SIM |
e6c01902 VOR |
150 | # if _MIPS_SIM == _MIPS_SIM_ABI32 |
151 | # define __NR_memfd_create 4354 | |
152 | # endif | |
153 | # if _MIPS_SIM == _MIPS_SIM_NABI32 | |
154 | # define __NR_memfd_create 6318 | |
155 | # endif | |
156 | # if _MIPS_SIM == _MIPS_SIM_ABI64 | |
157 | # define __NR_memfd_create 5314 | |
158 | # endif | |
03e8fdb3 | 159 | # elif defined __i386__ |
a6082d77 | 160 | # define __NR_memfd_create 356 |
03e8fdb3 DH |
161 | # else |
162 | # warning "__NR_memfd_create unknown for your architecture" | |
163 | # define __NR_memfd_create 0xffffffff | |
a6082d77 | 164 | # endif |
22be093f LP |
165 | #endif |
166 | ||
a6082d77 | 167 | #ifndef HAVE_MEMFD_CREATE |
06b7f7bd | 168 | static inline int memfd_create(const char *name, unsigned int flags) { |
46327770 | 169 | return syscall(__NR_memfd_create, name, flags); |
a6082d77 DM |
170 | } |
171 | #endif | |
172 | ||
539618a0 LP |
173 | #ifndef __NR_getrandom |
174 | # if defined __x86_64__ | |
74a550c5 | 175 | # define __NR_getrandom 318 |
568981d2 ZJS |
176 | # elif defined(__i386__) |
177 | # define __NR_getrandom 355 | |
7fd68245 | 178 | # elif defined(__arm__) |
568981d2 | 179 | # define __NR_getrandom 384 |
7fd68245 MO |
180 | # elif defined(__aarch64__) |
181 | # define __NR_getrandom 278 | |
568981d2 ZJS |
182 | # elif defined(__ia64__) |
183 | # define __NR_getrandom 1339 | |
184 | # elif defined(__m68k__) | |
185 | # define __NR_getrandom 352 | |
186 | # elif defined(__s390x__) | |
187 | # define __NR_getrandom 349 | |
d01efa07 MH |
188 | # elif defined(__powerpc__) |
189 | # define __NR_getrandom 359 | |
3bec6d46 AK |
190 | # elif defined _MIPS_SIM |
191 | # if _MIPS_SIM == _MIPS_SIM_ABI32 | |
192 | # define __NR_getrandom 4353 | |
193 | # endif | |
194 | # if _MIPS_SIM == _MIPS_SIM_NABI32 | |
195 | # define __NR_getrandom 6317 | |
196 | # endif | |
197 | # if _MIPS_SIM == _MIPS_SIM_ABI64 | |
198 | # define __NR_getrandom 5313 | |
199 | # endif | |
539618a0 LP |
200 | # else |
201 | # warning "__NR_getrandom unknown for your architecture" | |
202 | # define __NR_getrandom 0xffffffff | |
203 | # endif | |
204 | #endif | |
205 | ||
206 | #if !HAVE_DECL_GETRANDOM | |
207 | static inline int getrandom(void *buffer, size_t count, unsigned flags) { | |
208 | return syscall(__NR_getrandom, buffer, count, flags); | |
209 | } | |
210 | #endif | |
211 | ||
97768fc5 LP |
212 | #ifndef GRND_NONBLOCK |
213 | #define GRND_NONBLOCK 0x0001 | |
214 | #endif | |
215 | ||
216 | #ifndef GRND_RANDOM | |
217 | #define GRND_RANDOM 0x0002 | |
218 | #endif | |
219 | ||
4b357e15 MM |
220 | #ifndef BTRFS_IOCTL_MAGIC |
221 | #define BTRFS_IOCTL_MAGIC 0x94 | |
222 | #endif | |
223 | ||
224 | #ifndef BTRFS_PATH_NAME_MAX | |
225 | #define BTRFS_PATH_NAME_MAX 4087 | |
226 | #endif | |
227 | ||
228 | #ifndef BTRFS_DEVICE_PATH_NAME_MAX | |
229 | #define BTRFS_DEVICE_PATH_NAME_MAX 1024 | |
230 | #endif | |
231 | ||
232 | #ifndef BTRFS_FSID_SIZE | |
233 | #define BTRFS_FSID_SIZE 16 | |
234 | #endif | |
235 | ||
236 | #ifndef BTRFS_UUID_SIZE | |
237 | #define BTRFS_UUID_SIZE 16 | |
238 | #endif | |
239 | ||
8e8ba792 MO |
240 | #ifndef BTRFS_SUBVOL_RDONLY |
241 | #define BTRFS_SUBVOL_RDONLY (1ULL << 1) | |
242 | #endif | |
243 | ||
244 | #ifndef BTRFS_SUBVOL_NAME_MAX | |
245 | #define BTRFS_SUBVOL_NAME_MAX 4039 | |
246 | #endif | |
247 | ||
248 | #ifndef BTRFS_INO_LOOKUP_PATH_MAX | |
249 | #define BTRFS_INO_LOOKUP_PATH_MAX 4080 | |
250 | #endif | |
251 | ||
252 | #ifndef BTRFS_SEARCH_ARGS_BUFSIZE | |
253 | #define BTRFS_SEARCH_ARGS_BUFSIZE (4096 - sizeof(struct btrfs_ioctl_search_key)) | |
254 | #endif | |
255 | ||
3f952f92 LP |
256 | #ifndef BTRFS_QGROUP_LEVEL_SHIFT |
257 | #define BTRFS_QGROUP_LEVEL_SHIFT 48 | |
258 | #endif | |
259 | ||
4b357e15 MM |
260 | #ifndef HAVE_LINUX_BTRFS_H |
261 | struct btrfs_ioctl_vol_args { | |
262 | int64_t fd; | |
263 | char name[BTRFS_PATH_NAME_MAX + 1]; | |
264 | }; | |
265 | ||
8e8ba792 MO |
266 | struct btrfs_qgroup_limit { |
267 | __u64 flags; | |
268 | __u64 max_rfer; | |
269 | __u64 max_excl; | |
270 | __u64 rsv_rfer; | |
271 | __u64 rsv_excl; | |
272 | }; | |
273 | ||
274 | struct btrfs_qgroup_inherit { | |
275 | __u64 flags; | |
276 | __u64 num_qgroups; | |
277 | __u64 num_ref_copies; | |
278 | __u64 num_excl_copies; | |
279 | struct btrfs_qgroup_limit lim; | |
280 | __u64 qgroups[0]; | |
281 | }; | |
282 | ||
d97fb408 MO |
283 | struct btrfs_ioctl_qgroup_limit_args { |
284 | __u64 qgroupid; | |
285 | struct btrfs_qgroup_limit lim; | |
286 | }; | |
287 | ||
8e8ba792 MO |
288 | struct btrfs_ioctl_vol_args_v2 { |
289 | __s64 fd; | |
290 | __u64 transid; | |
291 | __u64 flags; | |
292 | union { | |
293 | struct { | |
294 | __u64 size; | |
295 | struct btrfs_qgroup_inherit *qgroup_inherit; | |
296 | }; | |
297 | __u64 unused[4]; | |
298 | }; | |
299 | char name[BTRFS_SUBVOL_NAME_MAX + 1]; | |
300 | }; | |
301 | ||
4b357e15 MM |
302 | struct btrfs_ioctl_dev_info_args { |
303 | uint64_t devid; /* in/out */ | |
304 | uint8_t uuid[BTRFS_UUID_SIZE]; /* in/out */ | |
305 | uint64_t bytes_used; /* out */ | |
306 | uint64_t total_bytes; /* out */ | |
307 | uint64_t unused[379]; /* pad to 4k */ | |
308 | char path[BTRFS_DEVICE_PATH_NAME_MAX]; /* out */ | |
309 | }; | |
310 | ||
311 | struct btrfs_ioctl_fs_info_args { | |
312 | uint64_t max_id; /* out */ | |
313 | uint64_t num_devices; /* out */ | |
314 | uint8_t fsid[BTRFS_FSID_SIZE]; /* out */ | |
315 | uint64_t reserved[124]; /* pad to 1k */ | |
316 | }; | |
8e8ba792 MO |
317 | |
318 | struct btrfs_ioctl_ino_lookup_args { | |
319 | __u64 treeid; | |
320 | __u64 objectid; | |
321 | char name[BTRFS_INO_LOOKUP_PATH_MAX]; | |
322 | }; | |
323 | ||
324 | struct btrfs_ioctl_search_key { | |
325 | /* which root are we searching. 0 is the tree of tree roots */ | |
326 | __u64 tree_id; | |
327 | ||
328 | /* keys returned will be >= min and <= max */ | |
329 | __u64 min_objectid; | |
330 | __u64 max_objectid; | |
331 | ||
332 | /* keys returned will be >= min and <= max */ | |
333 | __u64 min_offset; | |
334 | __u64 max_offset; | |
335 | ||
336 | /* max and min transids to search for */ | |
337 | __u64 min_transid; | |
338 | __u64 max_transid; | |
339 | ||
340 | /* keys returned will be >= min and <= max */ | |
341 | __u32 min_type; | |
342 | __u32 max_type; | |
343 | ||
344 | /* | |
345 | * how many items did userland ask for, and how many are we | |
346 | * returning | |
347 | */ | |
348 | __u32 nr_items; | |
349 | ||
350 | /* align to 64 bits */ | |
351 | __u32 unused; | |
352 | ||
353 | /* some extra for later */ | |
354 | __u64 unused1; | |
355 | __u64 unused2; | |
356 | __u64 unused3; | |
357 | __u64 unused4; | |
358 | }; | |
359 | ||
360 | struct btrfs_ioctl_search_header { | |
361 | __u64 transid; | |
362 | __u64 objectid; | |
363 | __u64 offset; | |
364 | __u32 type; | |
365 | __u32 len; | |
366 | }; | |
367 | ||
368 | ||
369 | struct btrfs_ioctl_search_args { | |
370 | struct btrfs_ioctl_search_key key; | |
371 | char buf[BTRFS_SEARCH_ARGS_BUFSIZE]; | |
372 | }; | |
373 | ||
374 | struct btrfs_ioctl_clone_range_args { | |
375 | __s64 src_fd; | |
376 | __u64 src_offset, src_length; | |
377 | __u64 dest_offset; | |
378 | }; | |
d97fb408 MO |
379 | |
380 | #define BTRFS_QUOTA_CTL_ENABLE 1 | |
381 | #define BTRFS_QUOTA_CTL_DISABLE 2 | |
382 | #define BTRFS_QUOTA_CTL_RESCAN__NOTUSED 3 | |
383 | struct btrfs_ioctl_quota_ctl_args { | |
384 | __u64 cmd; | |
385 | __u64 status; | |
386 | }; | |
4b357e15 MM |
387 | #endif |
388 | ||
389 | #ifndef BTRFS_IOC_DEFRAG | |
7bed7f0e ZJS |
390 | #define BTRFS_IOC_DEFRAG _IOW(BTRFS_IOCTL_MAGIC, 2, \ |
391 | struct btrfs_ioctl_vol_args) | |
4b357e15 MM |
392 | #endif |
393 | ||
d97fb408 MO |
394 | #ifndef BTRFS_IOC_RESIZE |
395 | #define BTRFS_IOC_RESIZE _IOW(BTRFS_IOCTL_MAGIC, 3, \ | |
396 | struct btrfs_ioctl_vol_args) | |
397 | #endif | |
398 | ||
8e8ba792 MO |
399 | #ifndef BTRFS_IOC_CLONE |
400 | #define BTRFS_IOC_CLONE _IOW(BTRFS_IOCTL_MAGIC, 9, int) | |
401 | #endif | |
402 | ||
403 | #ifndef BTRFS_IOC_CLONE_RANGE | |
404 | #define BTRFS_IOC_CLONE_RANGE _IOW(BTRFS_IOCTL_MAGIC, 13, \ | |
405 | struct btrfs_ioctl_clone_range_args) | |
406 | #endif | |
407 | ||
408 | #ifndef BTRFS_IOC_SUBVOL_CREATE | |
409 | #define BTRFS_IOC_SUBVOL_CREATE _IOW(BTRFS_IOCTL_MAGIC, 14, \ | |
410 | struct btrfs_ioctl_vol_args) | |
411 | #endif | |
412 | ||
413 | #ifndef BTRFS_IOC_SNAP_DESTROY | |
414 | #define BTRFS_IOC_SNAP_DESTROY _IOW(BTRFS_IOCTL_MAGIC, 15, \ | |
415 | struct btrfs_ioctl_vol_args) | |
416 | #endif | |
417 | ||
418 | #ifndef BTRFS_IOC_TREE_SEARCH | |
419 | #define BTRFS_IOC_TREE_SEARCH _IOWR(BTRFS_IOCTL_MAGIC, 17, \ | |
420 | struct btrfs_ioctl_search_args) | |
421 | #endif | |
422 | ||
423 | #ifndef BTRFS_IOC_INO_LOOKUP | |
424 | #define BTRFS_IOC_INO_LOOKUP _IOWR(BTRFS_IOCTL_MAGIC, 18, \ | |
425 | struct btrfs_ioctl_ino_lookup_args) | |
426 | #endif | |
427 | ||
428 | #ifndef BTRFS_IOC_SNAP_CREATE_V2 | |
429 | #define BTRFS_IOC_SNAP_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 23, \ | |
430 | struct btrfs_ioctl_vol_args_v2) | |
431 | #endif | |
432 | ||
433 | #ifndef BTRFS_IOC_SUBVOL_GETFLAGS | |
434 | #define BTRFS_IOC_SUBVOL_GETFLAGS _IOR(BTRFS_IOCTL_MAGIC, 25, __u64) | |
435 | #endif | |
436 | ||
437 | #ifndef BTRFS_IOC_SUBVOL_SETFLAGS | |
438 | #define BTRFS_IOC_SUBVOL_SETFLAGS _IOW(BTRFS_IOCTL_MAGIC, 26, __u64) | |
439 | #endif | |
440 | ||
4b357e15 MM |
441 | #ifndef BTRFS_IOC_DEV_INFO |
442 | #define BTRFS_IOC_DEV_INFO _IOWR(BTRFS_IOCTL_MAGIC, 30, \ | |
443 | struct btrfs_ioctl_dev_info_args) | |
444 | #endif | |
445 | ||
446 | #ifndef BTRFS_IOC_FS_INFO | |
447 | #define BTRFS_IOC_FS_INFO _IOR(BTRFS_IOCTL_MAGIC, 31, \ | |
7bed7f0e ZJS |
448 | struct btrfs_ioctl_fs_info_args) |
449 | #endif | |
450 | ||
451 | #ifndef BTRFS_IOC_DEVICES_READY | |
452 | #define BTRFS_IOC_DEVICES_READY _IOR(BTRFS_IOCTL_MAGIC, 39, \ | |
453 | struct btrfs_ioctl_vol_args) | |
4b357e15 MM |
454 | #endif |
455 | ||
d97fb408 MO |
456 | #ifndef BTRFS_IOC_QUOTA_CTL |
457 | #define BTRFS_IOC_QUOTA_CTL _IOWR(BTRFS_IOCTL_MAGIC, 40, \ | |
458 | struct btrfs_ioctl_quota_ctl_args) | |
459 | #endif | |
460 | ||
461 | #ifndef BTRFS_IOC_QGROUP_LIMIT | |
462 | #define BTRFS_IOC_QGROUP_LIMIT _IOR(BTRFS_IOCTL_MAGIC, 43, \ | |
463 | struct btrfs_ioctl_qgroup_limit_args) | |
464 | #endif | |
465 | ||
10f9c755 LP |
466 | #ifndef BTRFS_FIRST_FREE_OBJECTID |
467 | #define BTRFS_FIRST_FREE_OBJECTID 256 | |
468 | #endif | |
469 | ||
d9e2daaf LP |
470 | #ifndef BTRFS_LAST_FREE_OBJECTID |
471 | #define BTRFS_LAST_FREE_OBJECTID -256ULL | |
472 | #endif | |
473 | ||
b6b18498 LP |
474 | #ifndef BTRFS_ROOT_TREE_OBJECTID |
475 | #define BTRFS_ROOT_TREE_OBJECTID 1 | |
476 | #endif | |
477 | ||
478 | #ifndef BTRFS_QUOTA_TREE_OBJECTID | |
479 | #define BTRFS_QUOTA_TREE_OBJECTID 8ULL | |
480 | #endif | |
481 | ||
10f9c755 LP |
482 | #ifndef BTRFS_ROOT_ITEM_KEY |
483 | #define BTRFS_ROOT_ITEM_KEY 132 | |
484 | #endif | |
485 | ||
b6b18498 LP |
486 | #ifndef BTRFS_QGROUP_STATUS_KEY |
487 | #define BTRFS_QGROUP_STATUS_KEY 240 | |
488 | #endif | |
489 | ||
490 | #ifndef BTRFS_QGROUP_INFO_KEY | |
491 | #define BTRFS_QGROUP_INFO_KEY 242 | |
492 | #endif | |
493 | ||
494 | #ifndef BTRFS_QGROUP_LIMIT_KEY | |
495 | #define BTRFS_QGROUP_LIMIT_KEY 244 | |
496 | #endif | |
497 | ||
5bcd08db LP |
498 | #ifndef BTRFS_QGROUP_RELATION_KEY |
499 | #define BTRFS_QGROUP_RELATION_KEY 246 | |
500 | #endif | |
501 | ||
d9e2daaf LP |
502 | #ifndef BTRFS_ROOT_BACKREF_KEY |
503 | #define BTRFS_ROOT_BACKREF_KEY 144 | |
504 | #endif | |
505 | ||
746f8906 LP |
506 | #ifndef BTRFS_SUPER_MAGIC |
507 | #define BTRFS_SUPER_MAGIC 0x9123683E | |
508 | #endif | |
509 | ||
efdb0237 LP |
510 | #ifndef CGROUP_SUPER_MAGIC |
511 | #define CGROUP_SUPER_MAGIC 0x27e0eb | |
512 | #endif | |
513 | ||
514 | #ifndef TMPFS_MAGIC | |
515 | #define TMPFS_MAGIC 0x01021994 | |
516 | #endif | |
517 | ||
94d82985 LP |
518 | #ifndef MS_MOVE |
519 | #define MS_MOVE 8192 | |
520 | #endif | |
521 | ||
7cb1094a HH |
522 | #ifndef MS_PRIVATE |
523 | #define MS_PRIVATE (1 << 18) | |
524 | #endif | |
525 | ||
a8348796 | 526 | #if !HAVE_DECL_GETTID |
4d14be09 LP |
527 | static inline pid_t gettid(void) { |
528 | return (pid_t) syscall(SYS_gettid); | |
529 | } | |
a8348796 | 530 | #endif |
4d14be09 | 531 | |
54ecda32 LP |
532 | #ifndef SCM_SECURITY |
533 | #define SCM_SECURITY 0x03 | |
534 | #endif | |
535 | ||
48ac500b LP |
536 | #ifndef MS_STRICTATIME |
537 | #define MS_STRICTATIME (1<<24) | |
538 | #endif | |
539 | ||
a9621528 AM |
540 | #ifndef MS_REC |
541 | #define MS_REC 16384 | |
542 | #endif | |
543 | ||
544 | #ifndef MS_SHARED | |
545 | #define MS_SHARED (1<<20) | |
546 | #endif | |
547 | ||
8351ceae LP |
548 | #ifndef PR_SET_NO_NEW_PRIVS |
549 | #define PR_SET_NO_NEW_PRIVS 38 | |
550 | #endif | |
d4447f4d AK |
551 | |
552 | #ifndef PR_SET_CHILD_SUBREAPER | |
553 | #define PR_SET_CHILD_SUBREAPER 36 | |
554 | #endif | |
a8348796 LP |
555 | |
556 | #ifndef MAX_HANDLE_SZ | |
557 | #define MAX_HANDLE_SZ 128 | |
558 | #endif | |
559 | ||
66330455 LP |
560 | #ifndef __NR_name_to_handle_at |
561 | # if defined(__x86_64__) | |
848af055 | 562 | # define __NR_name_to_handle_at 303 |
66330455 | 563 | # elif defined(__i386__) |
848af055 | 564 | # define __NR_name_to_handle_at 341 |
66330455 | 565 | # elif defined(__arm__) |
f527b6b8 | 566 | # define __NR_name_to_handle_at 370 |
66330455 | 567 | # elif defined(__powerpc__) |
f527b6b8 | 568 | # define __NR_name_to_handle_at 345 |
66330455 LP |
569 | # else |
570 | # error "__NR_name_to_handle_at is not defined" | |
f527b6b8 | 571 | # endif |
a8348796 LP |
572 | #endif |
573 | ||
9388e99e | 574 | #if !HAVE_DECL_NAME_TO_HANDLE_AT |
a8348796 LP |
575 | struct file_handle { |
576 | unsigned int handle_bytes; | |
577 | int handle_type; | |
578 | unsigned char f_handle[0]; | |
579 | }; | |
580 | ||
581 | static inline int name_to_handle_at(int fd, const char *name, struct file_handle *handle, int *mnt_id, int flags) { | |
582 | return syscall(__NR_name_to_handle_at, fd, name, handle, mnt_id, flags); | |
583 | } | |
584 | #endif | |
4db17f29 ZJS |
585 | |
586 | #ifndef HAVE_SECURE_GETENV | |
587 | # ifdef HAVE___SECURE_GETENV | |
588 | # define secure_getenv __secure_getenv | |
589 | # else | |
66330455 | 590 | # error "neither secure_getenv nor __secure_getenv are available" |
4db17f29 ZJS |
591 | # endif |
592 | #endif | |
85210bff LP |
593 | |
594 | #ifndef CIFS_MAGIC_NUMBER | |
65b3903f | 595 | # define CIFS_MAGIC_NUMBER 0xFF534D42 |
85210bff | 596 | #endif |
8742514c LP |
597 | |
598 | #ifndef TFD_TIMER_CANCEL_ON_SET | |
65b3903f | 599 | # define TFD_TIMER_CANCEL_ON_SET (1 << 1) |
8742514c | 600 | #endif |
f7db7a69 SL |
601 | |
602 | #ifndef SO_REUSEPORT | |
65b3903f | 603 | # define SO_REUSEPORT 15 |
f7db7a69 | 604 | #endif |
118ecf32 DH |
605 | |
606 | #ifndef EVIOCREVOKE | |
65b3903f | 607 | # define EVIOCREVOKE _IOW('E', 0x91, int) |
118ecf32 DH |
608 | #endif |
609 | ||
610 | #ifndef DRM_IOCTL_SET_MASTER | |
65b3903f | 611 | # define DRM_IOCTL_SET_MASTER _IO('d', 0x1e) |
118ecf32 DH |
612 | #endif |
613 | ||
614 | #ifndef DRM_IOCTL_DROP_MASTER | |
65b3903f ZJS |
615 | # define DRM_IOCTL_DROP_MASTER _IO('d', 0x1f) |
616 | #endif | |
617 | ||
c09918f9 LP |
618 | #if defined(__i386__) || defined(__x86_64__) |
619 | ||
620 | /* The precise definition of __O_TMPFILE is arch specific, so let's | |
621 | * just define this on x86 where we know the value. */ | |
622 | ||
623 | #ifndef __O_TMPFILE | |
624 | #define __O_TMPFILE 020000000 | |
625 | #endif | |
626 | ||
627 | /* a horrid kludge trying to make sure that this will fail on old kernels */ | |
628 | #ifndef O_TMPFILE | |
629 | #define O_TMPFILE (__O_TMPFILE | O_DIRECTORY) | |
630 | #endif | |
631 | ||
632 | #endif | |
3b794314 HS |
633 | |
634 | #ifndef __NR_setns | |
635 | # if defined(__x86_64__) | |
636 | # define __NR_setns 308 | |
637 | # elif defined(__i386__) | |
638 | # define __NR_setns 346 | |
639 | # else | |
640 | # error "__NR_setns is not defined" | |
641 | # endif | |
642 | #endif | |
643 | ||
644 | #if !HAVE_DECL_SETNS | |
645 | static inline int setns(int fd, int nstype) { | |
646 | return syscall(__NR_setns, fd, nstype); | |
647 | } | |
648 | #endif | |
5f381b35 LP |
649 | |
650 | #if !HAVE_DECL_LO_FLAGS_PARTSCAN | |
651 | #define LO_FLAGS_PARTSCAN 8 | |
652 | #endif | |
a853c45d LP |
653 | |
654 | #ifndef LOOP_CTL_REMOVE | |
655 | #define LOOP_CTL_REMOVE 0x4C81 | |
656 | #endif | |
657 | ||
658 | #ifndef LOOP_CTL_GET_FREE | |
659 | #define LOOP_CTL_GET_FREE 0x4C82 | |
660 | #endif | |
0830ba61 | 661 | |
84dd59b5 DH |
662 | #if !HAVE_DECL_IFLA_INET6_ADDR_GEN_MODE |
663 | #define IFLA_INET6_UNSPEC 0 | |
664 | #define IFLA_INET6_FLAGS 1 | |
665 | #define IFLA_INET6_CONF 2 | |
666 | #define IFLA_INET6_STATS 3 | |
667 | #define IFLA_INET6_MCAST 4 | |
668 | #define IFLA_INET6_CACHEINFO 5 | |
669 | #define IFLA_INET6_ICMP6STATS 6 | |
670 | #define IFLA_INET6_TOKEN 7 | |
671 | #define IFLA_INET6_ADDR_GEN_MODE 8 | |
672 | #define __IFLA_INET6_MAX 9 | |
673 | ||
674 | #define IFLA_INET6_MAX (__IFLA_INET6_MAX - 1) | |
675 | ||
676 | #define IN6_ADDR_GEN_MODE_EUI64 0 | |
677 | #define IN6_ADDR_GEN_MODE_NONE 1 | |
678 | #endif | |
679 | ||
75616a13 ZJS |
680 | #if !HAVE_DECL_IFLA_MACVLAN_FLAGS |
681 | #define IFLA_MACVLAN_UNSPEC 0 | |
682 | #define IFLA_MACVLAN_MODE 1 | |
683 | #define IFLA_MACVLAN_FLAGS 2 | |
684 | #define __IFLA_MACVLAN_MAX 3 | |
685 | ||
686 | #define IFLA_MACVLAN_MAX (__IFLA_MACVLAN_MAX - 1) | |
687 | #endif | |
688 | ||
c4a5ddc9 TG |
689 | #if !HAVE_DECL_IFLA_IPVLAN_MODE |
690 | #define IFLA_IPVLAN_UNSPEC 0 | |
691 | #define IFLA_IPVLAN_MODE 1 | |
692 | #define __IFLA_IPVLAN_MAX 2 | |
693 | ||
694 | #define IFLA_IPVLAN_MAX (__IFLA_IPVLAN_MAX - 1) | |
695 | ||
696 | #define IPVLAN_MODE_L2 0 | |
697 | #define IPVLAN_MODE_L3 1 | |
698 | #define IPVLAN_MAX 2 | |
699 | #endif | |
700 | ||
6589d0db JAS |
701 | #if !HAVE_DECL_IFLA_VTI_REMOTE |
702 | #define IFLA_VTI_UNSPEC 0 | |
703 | #define IFLA_VTI_LINK 1 | |
704 | #define IFLA_VTI_IKEY 2 | |
705 | #define IFLA_VTI_OKEY 3 | |
706 | #define IFLA_VTI_LOCAL 4 | |
707 | #define IFLA_VTI_REMOTE 5 | |
708 | #define __IFLA_VTI_MAX 6 | |
709 | ||
710 | #define IFLA_VTI_MAX (__IFLA_VTI_MAX - 1) | |
711 | #endif | |
712 | ||
81577dc2 ZJS |
713 | #if !HAVE_DECL_IFLA_PHYS_PORT_ID |
714 | #undef IFLA_PROMISCUITY | |
715 | #define IFLA_PROMISCUITY 30 | |
716 | #define IFLA_NUM_TX_QUEUES 31 | |
717 | #define IFLA_NUM_RX_QUEUES 32 | |
718 | #define IFLA_CARRIER 33 | |
719 | #define IFLA_PHYS_PORT_ID 34 | |
720 | #define __IFLA_MAX 35 | |
721 | ||
722 | #define IFLA_MAX (__IFLA_MAX - 1) | |
723 | #endif | |
724 | ||
725 | #if !HAVE_DECL_IFLA_BOND_AD_INFO | |
726 | #define IFLA_BOND_UNSPEC 0 | |
727 | #define IFLA_BOND_MODE 1 | |
728 | #define IFLA_BOND_ACTIVE_SLAVE 2 | |
729 | #define IFLA_BOND_MIIMON 3 | |
730 | #define IFLA_BOND_UPDELAY 4 | |
731 | #define IFLA_BOND_DOWNDELAY 5 | |
732 | #define IFLA_BOND_USE_CARRIER 6 | |
733 | #define IFLA_BOND_ARP_INTERVAL 7 | |
734 | #define IFLA_BOND_ARP_IP_TARGET 8 | |
735 | #define IFLA_BOND_ARP_VALIDATE 9 | |
736 | #define IFLA_BOND_ARP_ALL_TARGETS 10 | |
737 | #define IFLA_BOND_PRIMARY 11 | |
738 | #define IFLA_BOND_PRIMARY_RESELECT 12 | |
739 | #define IFLA_BOND_FAIL_OVER_MAC 13 | |
740 | #define IFLA_BOND_XMIT_HASH_POLICY 14 | |
741 | #define IFLA_BOND_RESEND_IGMP 15 | |
742 | #define IFLA_BOND_NUM_PEER_NOTIF 16 | |
743 | #define IFLA_BOND_ALL_SLAVES_ACTIVE 17 | |
744 | #define IFLA_BOND_MIN_LINKS 18 | |
745 | #define IFLA_BOND_LP_INTERVAL 19 | |
746 | #define IFLA_BOND_PACKETS_PER_SLAVE 20 | |
747 | #define IFLA_BOND_AD_LACP_RATE 21 | |
748 | #define IFLA_BOND_AD_SELECT 22 | |
749 | #define IFLA_BOND_AD_INFO 23 | |
750 | #define __IFLA_BOND_MAX 24 | |
0830ba61 | 751 | |
79306206 | 752 | #define IFLA_BOND_MAX (__IFLA_BOND_MAX - 1) |
0830ba61 | 753 | #endif |
81577dc2 ZJS |
754 | |
755 | #if !HAVE_DECL_IFLA_VLAN_PROTOCOL | |
756 | #define IFLA_VLAN_UNSPEC 0 | |
757 | #define IFLA_VLAN_ID 1 | |
758 | #define IFLA_VLAN_FLAGS 2 | |
759 | #define IFLA_VLAN_EGRESS_QOS 3 | |
760 | #define IFLA_VLAN_INGRESS_QOS 4 | |
761 | #define IFLA_VLAN_PROTOCOL 5 | |
762 | #define __IFLA_VLAN_MAX 6 | |
763 | ||
764 | #define IFLA_VLAN_MAX (__IFLA_VLAN_MAX - 1) | |
765 | #endif | |
766 | ||
583c14fc | 767 | #if !HAVE_DECL_IFLA_VXLAN_REMCSUM_NOPARTIAL |
81577dc2 ZJS |
768 | #define IFLA_VXLAN_UNSPEC 0 |
769 | #define IFLA_VXLAN_ID 1 | |
770 | #define IFLA_VXLAN_GROUP 2 | |
771 | #define IFLA_VXLAN_LINK 3 | |
772 | #define IFLA_VXLAN_LOCAL 4 | |
773 | #define IFLA_VXLAN_TTL 5 | |
774 | #define IFLA_VXLAN_TOS 6 | |
775 | #define IFLA_VXLAN_LEARNING 7 | |
776 | #define IFLA_VXLAN_AGEING 8 | |
777 | #define IFLA_VXLAN_LIMIT 9 | |
778 | #define IFLA_VXLAN_PORT_RANGE 10 | |
779 | #define IFLA_VXLAN_PROXY 11 | |
780 | #define IFLA_VXLAN_RSC 12 | |
781 | #define IFLA_VXLAN_L2MISS 13 | |
782 | #define IFLA_VXLAN_L3MISS 14 | |
783 | #define IFLA_VXLAN_PORT 15 | |
784 | #define IFLA_VXLAN_GROUP6 16 | |
785 | #define IFLA_VXLAN_LOCAL6 17 | |
583c14fc MO |
786 | #define IFLA_VXLAN_UDP_CSUM 18 |
787 | #define IFLA_VXLAN_UDP_ZERO_CSUM6_TX 19 | |
788 | #define IFLA_VXLAN_UDP_ZERO_CSUM6_RX 20 | |
789 | #define IFLA_VXLAN_REMCSUM_TX 21 | |
790 | #define IFLA_VXLAN_REMCSUM_RX 22 | |
791 | #define IFLA_VXLAN_GBP 23 | |
792 | #define IFLA_VXLAN_REMCSUM_NOPARTIAL 24 | |
793 | #define __IFLA_VXLAN_MAX 25 | |
81577dc2 ZJS |
794 | |
795 | #define IFLA_VXLAN_MAX (__IFLA_VXLAN_MAX - 1) | |
796 | #endif | |
797 | ||
56bf3853 | 798 | #if !HAVE_DECL_IFLA_IPTUN_ENCAP_DPORT |
81577dc2 ZJS |
799 | #define IFLA_IPTUN_UNSPEC 0 |
800 | #define IFLA_IPTUN_LINK 1 | |
801 | #define IFLA_IPTUN_LOCAL 2 | |
802 | #define IFLA_IPTUN_REMOTE 3 | |
803 | #define IFLA_IPTUN_TTL 4 | |
804 | #define IFLA_IPTUN_TOS 5 | |
805 | #define IFLA_IPTUN_ENCAP_LIMIT 6 | |
806 | #define IFLA_IPTUN_FLOWINFO 7 | |
807 | #define IFLA_IPTUN_FLAGS 8 | |
808 | #define IFLA_IPTUN_PROTO 9 | |
809 | #define IFLA_IPTUN_PMTUDISC 10 | |
810 | #define IFLA_IPTUN_6RD_PREFIX 11 | |
811 | #define IFLA_IPTUN_6RD_RELAY_PREFIX 12 | |
812 | #define IFLA_IPTUN_6RD_PREFIXLEN 13 | |
813 | #define IFLA_IPTUN_6RD_RELAY_PREFIXLEN 14 | |
56bf3853 SS |
814 | #define IFLA_IPTUN_ENCAP_TYPE 15 |
815 | #define IFLA_IPTUN_ENCAP_FLAGS 16 | |
816 | #define IFLA_IPTUN_ENCAP_SPORT 17 | |
817 | #define IFLA_IPTUN_ENCAP_DPORT 18 | |
818 | ||
819 | #define __IFLA_IPTUN_MAX 19 | |
81577dc2 ZJS |
820 | |
821 | #define IFLA_IPTUN_MAX (__IFLA_IPTUN_MAX - 1) | |
822 | #endif | |
823 | ||
66f4bc77 SS |
824 | #if !HAVE_DECL_IFLA_GRE_ENCAP_DPORT |
825 | #define IFLA_GRE_UNSPEC 0 | |
826 | #define IFLA_GRE_LINK 1 | |
827 | #define IFLA_GRE_IFLAGS 2 | |
828 | #define IFLA_GRE_OFLAGS 3 | |
829 | #define IFLA_GRE_IKEY 4 | |
830 | #define IFLA_GRE_OKEY 5 | |
831 | #define IFLA_GRE_LOCAL 6 | |
832 | #define IFLA_GRE_REMOTE 7 | |
833 | #define IFLA_GRE_TTL 8 | |
834 | #define IFLA_GRE_TOS 9 | |
835 | #define IFLA_GRE_PMTUDISC 10 | |
836 | #define IFLA_GRE_ENCAP_LIMIT 11 | |
837 | #define IFLA_GRE_FLOWINFO 12 | |
838 | #define IFLA_GRE_FLAGS 13 | |
839 | #define IFLA_GRE_ENCAP_TYPE 14 | |
840 | #define IFLA_GRE_ENCAP_FLAGS 15 | |
841 | #define IFLA_GRE_ENCAP_SPORT 16 | |
842 | #define IFLA_GRE_ENCAP_DPORT 17 | |
843 | ||
844 | #define __IFLA_GRE_MAX 18 | |
845 | ||
846 | #define IFLA_GRE_MAX (__IFLA_GRE_MAX - 1) | |
847 | #endif | |
848 | ||
81577dc2 ZJS |
849 | #if !HAVE_DECL_IFLA_BRIDGE_VLAN_INFO |
850 | #define IFLA_BRIDGE_FLAGS 0 | |
851 | #define IFLA_BRIDGE_MODE 1 | |
852 | #define IFLA_BRIDGE_VLAN_INFO 2 | |
853 | #define __IFLA_BRIDGE_MAX 3 | |
854 | ||
855 | #define IFLA_BRIDGE_MAX (__IFLA_BRIDGE_MAX - 1) | |
856 | #endif | |
623a4c97 | 857 | |
c3eae485 SS |
858 | #if !HAVE_DECL_IFLA_BR_PRIORITY |
859 | #define IFLA_BR_UNSPEC 0 | |
860 | #define IFLA_BR_FORWARD_DELAY 1 | |
861 | #define IFLA_BR_HELLO_TIME 2 | |
862 | #define IFLA_BR_MAX_AGE 3 | |
863 | #define IFLA_BR_AGEING_TIME 4 | |
864 | #define IFLA_BR_STP_STATE 5 | |
865 | #define IFLA_BR_PRIORITY 6 | |
866 | #define __IFLA_BR_MAX 7 | |
867 | ||
868 | #define IFLA_BR_MAX (__IFLA_BR_MAX - 1) | |
869 | #endif | |
870 | ||
38a0245f | 871 | #if !HAVE_DECL_IFLA_BRPORT_LEARNING_SYNC |
8ecec322 ZJS |
872 | #define IFLA_BRPORT_UNSPEC 0 |
873 | #define IFLA_BRPORT_STATE 1 | |
874 | #define IFLA_BRPORT_PRIORITY 2 | |
875 | #define IFLA_BRPORT_COST 3 | |
876 | #define IFLA_BRPORT_MODE 4 | |
877 | #define IFLA_BRPORT_GUARD 5 | |
878 | #define IFLA_BRPORT_PROTECT 6 | |
879 | #define IFLA_BRPORT_FAST_LEAVE 7 | |
880 | #define IFLA_BRPORT_LEARNING 8 | |
881 | #define IFLA_BRPORT_UNICAST_FLOOD 9 | |
38a0245f SS |
882 | #define IFLA_BRPORT_PROXYARP 10 |
883 | #define IFLA_BRPORT_LEARNING_SYNC 11 | |
884 | #define __IFLA_BRPORT_MAX 12 | |
8ecec322 ZJS |
885 | |
886 | #define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1) | |
887 | #endif | |
888 | ||
cf1755ba MO |
889 | #if !HAVE_DECL_NDA_IFINDEX |
890 | #define NDA_UNSPEC 0 | |
891 | #define NDA_DST 1 | |
892 | #define NDA_LLADDR 2 | |
893 | #define NDA_CACHEINFO 3 | |
894 | #define NDA_PROBES 4 | |
895 | #define NDA_VLAN 5 | |
896 | #define NDA_PORT 6 | |
897 | #define NDA_VNI 7 | |
898 | #define NDA_IFINDEX 8 | |
899 | #define __NDA_MAX 9 | |
900 | ||
901 | #define NDA_MAX (__NDA_MAX - 1) | |
902 | #endif | |
903 | ||
623a4c97 LP |
904 | #ifndef IPV6_UNICAST_IF |
905 | #define IPV6_UNICAST_IF 76 | |
906 | #endif | |
ec2c5e43 | 907 | |
04d180c8 TG |
908 | #ifndef IFF_MULTI_QUEUE |
909 | #define IFF_MULTI_QUEUE 0x100 | |
910 | #endif | |
911 | ||
ec2c5e43 LP |
912 | #ifndef IFF_LOWER_UP |
913 | #define IFF_LOWER_UP 0x10000 | |
914 | #endif | |
915 | ||
916 | #ifndef IFF_DORMANT | |
917 | #define IFF_DORMANT 0x20000 | |
918 | #endif | |
91988149 LP |
919 | |
920 | #ifndef BOND_XMIT_POLICY_ENCAP23 | |
921 | #define BOND_XMIT_POLICY_ENCAP23 3 | |
922 | #endif | |
923 | ||
924 | #ifndef BOND_XMIT_POLICY_ENCAP34 | |
925 | #define BOND_XMIT_POLICY_ENCAP34 4 | |
926 | #endif | |
04b67d49 TG |
927 | |
928 | #ifndef NET_ADDR_RANDOM | |
929 | # define NET_ADDR_RANDOM 1 | |
930 | #endif | |
931 | ||
1cb636d9 CW |
932 | #ifndef NET_NAME_UNKNOWN |
933 | # define NET_NAME_UNKNOWN 0 | |
934 | #endif | |
935 | ||
04b67d49 TG |
936 | #ifndef NET_NAME_ENUM |
937 | # define NET_NAME_ENUM 1 | |
938 | #endif | |
939 | ||
940 | #ifndef NET_NAME_PREDICTABLE | |
941 | # define NET_NAME_PREDICTABLE 2 | |
942 | #endif | |
943 | ||
944 | #ifndef NET_NAME_USER | |
945 | # define NET_NAME_USER 3 | |
946 | #endif | |
947 | ||
948 | #ifndef NET_NAME_RENAMED | |
949 | # define NET_NAME_RENAMED 4 | |
950 | #endif | |
7965435e MO |
951 | |
952 | #ifndef BPF_XOR | |
953 | # define BPF_XOR 0xa0 | |
954 | #endif | |
a5f03596 LP |
955 | |
956 | /* Note that LOOPBACK_IFINDEX is currently not exported by the | |
957 | * kernel/glibc, but hardcoded internally by the kernel. However, as | |
958 | * it is exported to userspace indirectly via rtnetlink and the | |
959 | * ioctls, and made use of widely we define it here too, in a way that | |
960 | * is compatible with the kernel's internal definition. */ | |
961 | #ifndef LOOPBACK_IFINDEX | |
962 | #define LOOPBACK_IFINDEX 1 | |
963 | #endif | |
875c2e22 | 964 | |
34f7b9f9 LP |
965 | #if !HAVE_DECL_IFA_FLAGS |
966 | #define IFA_FLAGS 8 | |
967 | #endif | |
968 | ||
b06ac35c AS |
969 | #ifndef IFA_F_NOPREFIXROUTE |
970 | #define IFA_F_NOPREFIXROUTE 0x200 | |
971 | #endif | |
972 | ||
875c2e22 LP |
973 | #ifndef MAX_AUDIT_MESSAGE_LENGTH |
974 | #define MAX_AUDIT_MESSAGE_LENGTH 8970 | |
975 | #endif | |
976 | ||
977 | #ifndef AUDIT_NLGRP_MAX | |
978 | #define AUDIT_NLGRP_READLOG 1 | |
979 | #endif | |
2822da4f LP |
980 | |
981 | #ifndef CAP_MAC_OVERRIDE | |
982 | #define CAP_MAC_OVERRIDE 32 | |
983 | #endif | |
984 | ||
985 | #ifndef CAP_MAC_ADMIN | |
986 | #define CAP_MAC_ADMIN 33 | |
987 | #endif | |
988 | ||
989 | #ifndef CAP_SYSLOG | |
990 | #define CAP_SYSLOG 34 | |
991 | #endif | |
992 | ||
993 | #ifndef CAP_WAKE_ALARM | |
994 | #define CAP_WAKE_ALARM 35 | |
995 | #endif | |
996 | ||
997 | #ifndef CAP_BLOCK_SUSPEND | |
998 | #define CAP_BLOCK_SUSPEND 36 | |
999 | #endif | |
1000 | ||
1001 | #ifndef CAP_AUDIT_READ | |
1002 | #define CAP_AUDIT_READ 37 | |
1003 | #endif | |
60e1651a | 1004 | |
ee05e779 | 1005 | static inline int raw_clone(unsigned long flags, void *child_stack) { |
60e1651a KW |
1006 | #if defined(__s390__) || defined(__CRIS__) |
1007 | /* On s390 and cris the order of the first and second arguments | |
1008 | * of the raw clone() system call is reversed. */ | |
ee05e779 | 1009 | return (int) syscall(__NR_clone, child_stack, flags); |
60e1651a | 1010 | #else |
ee05e779 | 1011 | return (int) syscall(__NR_clone, flags, child_stack); |
60e1651a KW |
1012 | #endif |
1013 | } | |
ee05e779 ZJS |
1014 | |
1015 | static inline pid_t raw_getpid(void) { | |
a242a99d MT |
1016 | #if defined(__alpha__) |
1017 | return (pid_t) syscall(__NR_getxpid); | |
1018 | #else | |
ee05e779 | 1019 | return (pid_t) syscall(__NR_getpid); |
a242a99d | 1020 | #endif |
ee05e779 | 1021 | } |
ebd93cb6 LP |
1022 | |
1023 | #if !HAVE_DECL_RENAMEAT2 | |
e65ef51d ZJS |
1024 | |
1025 | #ifndef __NR_renameat2 | |
1026 | # if defined __x86_64__ | |
1027 | # define __NR_renameat2 316 | |
1028 | # elif defined __arm__ | |
1029 | # define __NR_renameat2 382 | |
1030 | # elif defined _MIPS_SIM | |
1031 | # if _MIPS_SIM == _MIPS_SIM_ABI32 | |
1032 | # define __NR_renameat2 4351 | |
1033 | # endif | |
1034 | # if _MIPS_SIM == _MIPS_SIM_NABI32 | |
1035 | # define __NR_renameat2 6315 | |
1036 | # endif | |
1037 | # if _MIPS_SIM == _MIPS_SIM_ABI64 | |
1038 | # define __NR_renameat2 5311 | |
1039 | # endif | |
1040 | # elif defined __i386__ | |
1041 | # define __NR_renameat2 353 | |
1042 | # else | |
1043 | # warning "__NR_renameat2 unknown for your architecture" | |
1044 | # define __NR_renameat2 0xffffffff | |
1045 | # endif | |
1046 | #endif | |
1047 | ||
ebd93cb6 LP |
1048 | static inline int renameat2(int oldfd, const char *oldname, int newfd, const char *newname, unsigned flags) { |
1049 | return syscall(__NR_renameat2, oldfd, oldname, newfd, newname, flags); | |
1050 | } | |
1051 | #endif | |
1052 | ||
1053 | #ifndef RENAME_NOREPLACE | |
1054 | #define RENAME_NOREPLACE (1 << 0) | |
1055 | #endif | |
f7ad54a3 LP |
1056 | |
1057 | #if !HAVE_DECL_KCMP | |
1058 | static inline int kcmp(pid_t pid1, pid_t pid2, int type, unsigned long idx1, unsigned long idx2) { | |
75b55457 | 1059 | #if defined(__NR_kcmp) |
f7ad54a3 | 1060 | return syscall(__NR_kcmp, pid1, pid2, type, idx1, idx2); |
75b55457 MG |
1061 | #else |
1062 | errno = ENOSYS; | |
1063 | return -1; | |
1064 | #endif | |
f7ad54a3 LP |
1065 | } |
1066 | #endif | |
1067 | ||
1068 | #ifndef KCMP_FILE | |
1069 | #define KCMP_FILE 0 | |
1070 | #endif | |
606df97b PH |
1071 | |
1072 | #ifndef INPUT_PROP_POINTING_STICK | |
1073 | #define INPUT_PROP_POINTING_STICK 0x05 | |
1074 | #endif | |
bd1acc9f HG |
1075 | |
1076 | #ifndef INPUT_PROP_ACCELEROMETER | |
1077 | #define INPUT_PROP_ACCELEROMETER 0x06 | |
1078 | #endif | |
e287086b LP |
1079 | |
1080 | #if !HAVE_DECL_KEY_SERIAL_T | |
1081 | typedef int32_t key_serial_t; | |
1082 | #endif | |
1083 | ||
1084 | #if !HAVE_DECL_KEYCTL | |
1085 | static inline long keyctl(int cmd, unsigned long arg2, unsigned long arg3, unsigned long arg4,unsigned long arg5) { | |
1086 | #if defined(__NR_keyctl) | |
1087 | return syscall(__NR_keyctl, cmd, arg2, arg3, arg4, arg5); | |
1088 | #else | |
1089 | errno = ENOSYS; | |
1090 | return -1; | |
1091 | #endif | |
1092 | } | |
1093 | ||
1094 | static inline key_serial_t add_key(const char *type, const char *description, const void *payload, size_t plen, key_serial_t ringid) { | |
1095 | #if defined (__NR_add_key) | |
1096 | return syscall(__NR_add_key, type, description, payload, plen, ringid); | |
1097 | #else | |
1098 | errno = ENOSYS; | |
1099 | return -1; | |
1100 | #endif | |
1101 | } | |
1102 | ||
1103 | static inline key_serial_t request_key(const char *type, const char *description, const char * callout_info, key_serial_t destringid) { | |
1104 | #if defined (__NR_request_key) | |
1105 | return syscall(__NR_request_key, type, description, callout_info, destringid); | |
1106 | #else | |
1107 | errno = ENOSYS; | |
1108 | return -1; | |
1109 | #endif | |
1110 | } | |
1111 | #endif | |
1112 | ||
1113 | #ifndef KEYCTL_READ | |
1114 | #define KEYCTL_READ 11 | |
1115 | #endif | |
1116 | ||
1117 | #ifndef KEYCTL_SET_TIMEOUT | |
1118 | #define KEYCTL_SET_TIMEOUT 15 | |
1119 | #endif | |
1120 | ||
1121 | #ifndef KEY_SPEC_USER_KEYRING | |
1122 | #define KEY_SPEC_USER_KEYRING -4 | |
1123 | #endif |