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