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