]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/basic/missing_syscall.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
4 /* Missing glibc definitions to access certain kernel APIs */
9 static inline int missing_pivot_root(const char *new_root
, const char *put_old
) {
10 return syscall(__NR_pivot_root
, new_root
, put_old
);
13 # define pivot_root missing_pivot_root
16 /* ======================================================================= */
18 #if !HAVE_MEMFD_CREATE
19 # ifndef __NR_memfd_create
20 # if defined __x86_64__
21 # define __NR_memfd_create 319
22 # elif defined __arm__
23 # define __NR_memfd_create 385
24 # elif defined __aarch64__
25 # define __NR_memfd_create 279
26 # elif defined __s390__
27 # define __NR_memfd_create 350
28 # elif defined _MIPS_SIM
29 # if _MIPS_SIM == _MIPS_SIM_ABI32
30 # define __NR_memfd_create 4354
32 # if _MIPS_SIM == _MIPS_SIM_NABI32
33 # define __NR_memfd_create 6318
35 # if _MIPS_SIM == _MIPS_SIM_ABI64
36 # define __NR_memfd_create 5314
38 # elif defined __i386__
39 # define __NR_memfd_create 356
40 # elif defined __arc__
41 # define __NR_memfd_create 279
43 # warning "__NR_memfd_create unknown for your architecture"
47 static inline int missing_memfd_create(const char *name
, unsigned int flags
) {
48 # ifdef __NR_memfd_create
49 return syscall(__NR_memfd_create
, name
, flags
);
56 # define memfd_create missing_memfd_create
59 /* ======================================================================= */
62 # ifndef __NR_getrandom
63 # if defined __x86_64__
64 # define __NR_getrandom 318
65 # elif defined(__i386__)
66 # define __NR_getrandom 355
67 # elif defined(__arm__)
68 # define __NR_getrandom 384
69 # elif defined(__aarch64__)
70 # define __NR_getrandom 278
71 # elif defined(__ia64__)
72 # define __NR_getrandom 1339
73 # elif defined(__m68k__)
74 # define __NR_getrandom 352
75 # elif defined(__s390x__)
76 # define __NR_getrandom 349
77 # elif defined(__powerpc__)
78 # define __NR_getrandom 359
79 # elif defined _MIPS_SIM
80 # if _MIPS_SIM == _MIPS_SIM_ABI32
81 # define __NR_getrandom 4353
83 # if _MIPS_SIM == _MIPS_SIM_NABI32
84 # define __NR_getrandom 6317
86 # if _MIPS_SIM == _MIPS_SIM_ABI64
87 # define __NR_getrandom 5313
89 # elif defined(__arc__)
90 # define __NR_getrandom 278
92 # warning "__NR_getrandom unknown for your architecture"
96 static inline int missing_getrandom(void *buffer
, size_t count
, unsigned flags
) {
97 # ifdef __NR_getrandom
98 return syscall(__NR_getrandom
, buffer
, count
, flags
);
105 # define getrandom missing_getrandom
108 /* ======================================================================= */
111 static inline pid_t
missing_gettid(void) {
112 return (pid_t
) syscall(__NR_gettid
);
115 # define gettid missing_gettid
118 /* ======================================================================= */
120 #if !HAVE_NAME_TO_HANDLE_AT
121 # ifndef __NR_name_to_handle_at
122 # if defined(__x86_64__)
123 # define __NR_name_to_handle_at 303
124 # elif defined(__i386__)
125 # define __NR_name_to_handle_at 341
126 # elif defined(__arm__)
127 # define __NR_name_to_handle_at 370
128 # elif defined(__powerpc__)
129 # define __NR_name_to_handle_at 345
130 # elif defined(__arc__)
131 # define __NR_name_to_handle_at 264
133 # error "__NR_name_to_handle_at is not defined"
138 unsigned int handle_bytes
;
140 unsigned char f_handle
[0];
143 static inline int missing_name_to_handle_at(int fd
, const char *name
, struct file_handle
*handle
, int *mnt_id
, int flags
) {
144 # ifdef __NR_name_to_handle_at
145 return syscall(__NR_name_to_handle_at
, fd
, name
, handle
, mnt_id
, flags
);
152 # define name_to_handle_at missing_name_to_handle_at
155 /* ======================================================================= */
159 # if defined(__x86_64__)
160 # define __NR_setns 308
161 # elif defined(__i386__)
162 # define __NR_setns 346
163 # elif defined(__arc__)
164 # define __NR_setns 268
166 # error "__NR_setns is not defined"
170 static inline int missing_setns(int fd
, int nstype
) {
172 return syscall(__NR_setns
, fd
, nstype
);
179 # define setns missing_setns
182 /* ======================================================================= */
184 static inline pid_t
raw_getpid(void) {
185 #if defined(__alpha__)
186 return (pid_t
) syscall(__NR_getxpid
);
188 return (pid_t
) syscall(__NR_getpid
);
192 /* ======================================================================= */
195 # ifndef __NR_renameat2
196 # if defined __x86_64__
197 # define __NR_renameat2 316
198 # elif defined __arm__
199 # define __NR_renameat2 382
200 # elif defined __aarch64__
201 # define __NR_renameat2 276
202 # elif defined _MIPS_SIM
203 # if _MIPS_SIM == _MIPS_SIM_ABI32
204 # define __NR_renameat2 4351
206 # if _MIPS_SIM == _MIPS_SIM_NABI32
207 # define __NR_renameat2 6315
209 # if _MIPS_SIM == _MIPS_SIM_ABI64
210 # define __NR_renameat2 5311
212 # elif defined __i386__
213 # define __NR_renameat2 353
214 # elif defined __powerpc64__
215 # define __NR_renameat2 357
216 # elif defined __s390__ || defined __s390x__
217 # define __NR_renameat2 347
218 # elif defined __arc__
219 # define __NR_renameat2 276
221 # warning "__NR_renameat2 unknown for your architecture"
225 static inline int missing_renameat2(int oldfd
, const char *oldname
, int newfd
, const char *newname
, unsigned flags
) {
226 # ifdef __NR_renameat2
227 return syscall(__NR_renameat2
, oldfd
, oldname
, newfd
, newname
, flags
);
234 # define renameat2 missing_renameat2
237 /* ======================================================================= */
240 static inline int missing_kcmp(pid_t pid1
, pid_t pid2
, int type
, unsigned long idx1
, unsigned long idx2
) {
242 return syscall(__NR_kcmp
, pid1
, pid2
, type
, idx1
, idx2
);
249 # define kcmp missing_kcmp
252 /* ======================================================================= */
255 static inline long missing_keyctl(int cmd
, unsigned long arg2
, unsigned long arg3
, unsigned long arg4
,unsigned long arg5
) {
257 return syscall(__NR_keyctl
, cmd
, arg2
, arg3
, arg4
, arg5
);
263 # define keyctl missing_keyctl
266 static inline key_serial_t
missing_add_key(const char *type
, const char *description
, const void *payload
, size_t plen
, key_serial_t ringid
) {
268 return syscall(__NR_add_key
, type
, description
, payload
, plen
, ringid
);
274 # define add_key missing_add_key
277 static inline key_serial_t
missing_request_key(const char *type
, const char *description
, const char * callout_info
, key_serial_t destringid
) {
278 # ifdef __NR_request_key
279 return syscall(__NR_request_key
, type
, description
, callout_info
, destringid
);
285 # define request_key missing_request_key
289 /* ======================================================================= */
291 #if !HAVE_COPY_FILE_RANGE
292 # ifndef __NR_copy_file_range
293 # if defined(__x86_64__)
294 # define __NR_copy_file_range 326
295 # elif defined(__i386__)
296 # define __NR_copy_file_range 377
297 # elif defined __s390__
298 # define __NR_copy_file_range 375
299 # elif defined __arm__
300 # define __NR_copy_file_range 391
301 # elif defined __aarch64__
302 # define __NR_copy_file_range 285
303 # elif defined __powerpc__
304 # define __NR_copy_file_range 379
305 # elif defined __arc__
306 # define __NR_copy_file_range 285
308 # warning "__NR_copy_file_range not defined for your architecture"
312 static inline ssize_t
missing_copy_file_range(int fd_in
, loff_t
*off_in
,
313 int fd_out
, loff_t
*off_out
,
315 unsigned int flags
) {
316 # ifdef __NR_copy_file_range
317 return syscall(__NR_copy_file_range
, fd_in
, off_in
, fd_out
, off_out
, len
, flags
);
324 # define copy_file_range missing_copy_file_range
327 /* ======================================================================= */
331 # if defined __i386__
332 # define __NR_bpf 357
333 # elif defined __x86_64__
334 # define __NR_bpf 321
335 # elif defined __aarch64__
336 # define __NR_bpf 280
337 # elif defined __arm__
338 # define __NR_bpf 386
339 # elif defined __sparc__
340 # define __NR_bpf 349
341 # elif defined __s390__
342 # define __NR_bpf 351
343 # elif defined __tilegx__
344 # define __NR_bpf 280
346 # warning "__NR_bpf not defined for your architecture"
352 static inline int missing_bpf(int cmd
, union bpf_attr
*attr
, size_t size
) {
354 return (int) syscall(__NR_bpf
, cmd
, attr
, size
);
361 # define bpf missing_bpf
364 /* ======================================================================= */
366 #ifndef __IGNORE_pkey_mprotect
367 # ifndef __NR_pkey_mprotect
368 # if defined __i386__
369 # define __NR_pkey_mprotect 380
370 # elif defined __x86_64__
371 # define __NR_pkey_mprotect 329
372 # elif defined __arm__
373 # define __NR_pkey_mprotect 394
374 # elif defined __aarch64__
375 # define __NR_pkey_mprotect 394
376 # elif defined __powerpc__
377 # define __NR_pkey_mprotect 386
378 # elif defined _MIPS_SIM
379 # if _MIPS_SIM == _MIPS_SIM_ABI32
380 # define __NR_pkey_mprotect 4363
382 # if _MIPS_SIM == _MIPS_SIM_NABI32
383 # define __NR_pkey_mprotect 6327
385 # if _MIPS_SIM == _MIPS_SIM_ABI64
386 # define __NR_pkey_mprotect 5323
389 # warning "__NR_pkey_mprotect not defined for your architecture"
394 /* ======================================================================= */
398 # if defined __aarch64__ || defined __arm__
399 # define __NR_statx 397
400 # elif defined __alpha__
401 # define __NR_statx 522
402 # elif defined __i386__ || defined __powerpc64__
403 # define __NR_statx 383
404 # elif defined __sparc__
405 # define __NR_statx 360
406 # elif defined __x86_64__
407 # define __NR_statx 332
409 # warning "__NR_statx not defined for your architecture"
416 /* This typedef is supposed to be always defined. */
417 typedef struct statx struct_statx
;
420 static inline ssize_t
missing_statx(int dfd
, const char *filename
, unsigned flags
, unsigned int mask
, struct statx
*buffer
) {
422 return syscall(__NR_statx
, dfd
, filename
, flags
, mask
, buffer
);
429 # define statx missing_statx