proc_cpuview.c proc_cpuview.h \
proc_fuse.c proc_fuse.h \
proc_loadavg.c proc_loadavg.h \
+ syscall_numbers.h \
sysfs_fuse.c sysfs_fuse.h \
utils.c utils.h
liblxcfs_la_CFLAGS = $(AM_CFLAGS)
proc_cpuview.c proc_cpuview.h \
proc_fuse.c proc_fuse.h \
proc_loadavg.c proc_loadavg.h \
+ syscall_numbers.h \
sysfs_fuse.c sysfs_fuse.h \
utils.c utils.h
liblxcfstest_la_CFLAGS = $(AM_CFLAGS) -DRELOADTEST
proc_cpuview.h \
proc_fuse.h \
proc_loadavg.h \
+ syscall_numbers.h \
sysfs_fuse.h \
utils.h
#include <linux/filter.h>
#endif
+#include "syscall_numbers.h"
+
#if !HAVE_BPF
-#if !(defined __NR_bpf && __NR_bpf > 0)
-#if defined __NR_bpf
-#undef __NR_bpf
-#endif
-#if defined __i386__
-#define __NR_bpf 357
-#elif defined __x86_64__
-#define __NR_bpf 321
-#elif defined __aarch64__
-#define __NR_bpf 280
-#elif defined __arm__
-#define __NR_bpf 386
-#elif defined __sparc__
-#define __NR_bpf 349
-#elif defined __s390__
-#define __NR_bpf 351
-#elif defined __tilegx__
-#define __NR_bpf 280
-#else
-#warning "__NR_bpf not defined for your architecture"
-#endif
-#endif
union bpf_attr;
static inline int missing_bpf(int cmd, union bpf_attr *attr, size_t size)
{
-#ifdef __NR_bpf
return (int)syscall(__NR_bpf, cmd, attr, size);
-#else
- errno = ENOSYS;
- return -1;
-#endif
}
#define bpf missing_bpf
size_t n_instructions;
#ifdef HAVE_STRUCT_BPF_CGROUP_DEV_CTX
struct bpf_insn *instructions;
-#endif
+#endif /* HAVE_STRUCT_BPF_CGROUP_DEV_CTX */
char *attached_path;
int attached_type;
*prog = NULL;
}
}
-#else
+#else /* HAVE_STRUCT_BPF_CGROUP_DEV_CTX */
static inline struct bpf_program *bpf_program_new(uint32_t prog_type)
{
errno = ENOSYS;
{
}
-#endif
+#endif /* HAVE_BPF */
-#define __do_bpf_program_free \
- __attribute__((__cleanup__(__auto_bpf_program_free__)))
+define_cleanup_function(struct bpf_program *, bpf_program_free);
#endif /* __LXC_CGROUP2_DEVICES_H */
--- /dev/null
+/* SPDX-License-Identifier: LGPL-2.1+ */
+#ifndef __LXCFS_SYSCALL_NUMBERS_H
+#define __LXCFS_SYSCALL_NUMBERS_H
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE 1
+#endif
+#include <asm/unistd.h>
+#include <errno.h>
+#include <sched.h>
+#include <stdint.h>
+#include <sys/syscall.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#ifndef __NR_pivot_root
+ #if defined __i386__
+ #define __NR_pivot_root 217
+ #elif defined __x86_64__
+ #define __NR_pivot_root 155
+ #elif defined __arm__
+ #define __NR_pivot_root 218
+ #elif defined __aarch64__
+ #define __NR_pivot_root 218
+ #elif defined __s390__
+ #define __NR_pivot_root 217
+ #elif defined __powerpc__
+ #define __NR_pivot_root 203
+ #elif defined __sparc__
+ #define __NR_pivot_root 146
+ #elif defined __ia64__
+ #define __NR_pivot_root 183
+ #elif defined _MIPS_SIM
+ #if _MIPS_SIM == _MIPS_SIM_ABI32 /* o32 */
+ #define __NR_pivot_root 4216
+ #endif
+ #if _MIPS_SIM == _MIPS_SIM_NABI32 /* n32 */
+ #define __NR_pivot_root 6151
+ #endif
+ #if _MIPS_SIM == _MIPS_SIM_ABI64 /* n64 */
+ #define __NR_pivot_root 5151
+ #endif
+ #else
+ #define -1
+ #warning "__NR_pivot_root not defined for your architecture"
+ #endif
+#endif
+
+#ifndef __NR_bpf
+ #if defined __i386__
+ #define __NR_bpf 357
+ #elif defined __x86_64__
+ #define __NR_bpf 321
+ #elif defined __arm__
+ #define __NR_bpf 386
+ #elif defined __aarch64__
+ #define __NR_bpf 386
+ #elif defined __s390__
+ #define __NR_bpf 351
+ #elif defined __powerpc__
+ #define __NR_bpf 361
+ #elif defined __sparc__
+ #define __NR_bpf 349
+ #elif defined __ia64__
+ #define __NR_bpf 317
+ #elif defined _MIPS_SIM
+ #if _MIPS_SIM == _MIPS_SIM_ABI32 /* o32 */
+ #define __NR_bpf 4355
+ #endif
+ #if _MIPS_SIM == _MIPS_SIM_NABI32 /* n32 */
+ #define __NR_bpf 6319
+ #endif
+ #if _MIPS_SIM == _MIPS_SIM_ABI64 /* n64 */
+ #define __NR_bpf 5315
+ #endif
+ #else
+ #define -1
+ #warning "__NR_bpf not defined for your architecture"
+ #endif
+#endif
+
+#ifndef __NR_pidfd_send_signal
+ #if defined __alpha__
+ #define __NR_pidfd_send_signal 534
+ #elif defined _MIPS_SIM
+ #if _MIPS_SIM == _MIPS_SIM_ABI32 /* o32 */
+ #define __NR_pidfd_send_signal 4424
+ #endif
+ #if _MIPS_SIM == _MIPS_SIM_NABI32 /* n32 */
+ #define __NR_pidfd_send_signal 6424
+ #endif
+ #if _MIPS_SIM == _MIPS_SIM_ABI64 /* n64 */
+ #define __NR_pidfd_send_signal 5424
+ #endif
+ #else
+ #define __NR_pidfd_send_signal 424
+ #endif
+#endif
+
+#ifndef __NR_pidfd_open
+ #if defined __alpha__
+ #define __NR_pidfd_open 544
+ #elif defined _MIPS_SIM
+ #if _MIPS_SIM == _MIPS_SIM_ABI32 /* o32 */
+ #define __NR_pidfd_open 4434
+ #endif
+ #if _MIPS_SIM == _MIPS_SIM_NABI32 /* n32 */
+ #define __NR_pidfd_open 6434
+ #endif
+ #if _MIPS_SIM == _MIPS_SIM_ABI64 /* n64 */
+ #define __NR_pidfd_open 5434
+ #endif
+ #else
+ #define __NR_pidfd_open 434
+ #endif
+#endif
+
+#endif /* __LXCFS_SYSCALL_NUMBERS_H */
#include "config.h"
#include "macro.h"
+#include "syscall_numbers.h"
/* Reserve buffer size to account for file size changes. */
#define BUF_RESERVE_SIZE 512
#ifndef HAVE_PIDFD_OPEN
static inline int pidfd_open(pid_t pid, unsigned int flags)
{
-#ifdef __NR_pidfd_open
return syscall(__NR_pidfd_open, pid, flags);
-#else
- return ret_errno(ENOSYS);
-#endif
}
#endif
static inline int pidfd_send_signal(int pidfd, int sig, siginfo_t *info,
unsigned int flags)
{
-#ifdef __NR_pidfd_send_signal
return syscall(__NR_pidfd_send_signal, pidfd, sig, info, flags);
-#else
- return ret_errno(ENOSYS);
-#endif
}
#endif