iproute2
dmsetup
python3-dev
+ gawk
)
PACKAGES_OPTIONAL=(
bashcompletions += ['waitpid']
endif
+syscalls_h = custom_target('syscalls.h',
+ input : 'tools/all_syscalls',
+ output : 'syscalls.h',
+ command : ['bash', '@INPUT@', cc.cmd_array()],
+)
+
exe = executable(
'enosys',
- 'misc-utils/enosys.c',
+ 'misc-utils/enosys.c', syscalls_h,
include_directories : includes,
link_with : [lib_common],
install_dir : usrbin_exec_dir,
endif
if BUILD_ENOSYS
+
+misc-utils/enosys.c: syscalls.h
+
+syscalls.h: $(top_srcdir)/tools/all_syscalls
+ $(top_srcdir)/tools/all_syscalls $(CC) $(CFLAGS)
+
+-include syscalls.h.deps
+CLEANFILES += syscalls.h syscalls.h.deps
+
usrbin_exec_PROGRAMS += enosys
MANPAGES += misc-utils/enosys.1
dist_noinst_DATA += misc-utils/enosys.1.adoc
};
static const struct syscall syscalls[] = {
- { "move_mount", __NR_move_mount },
- { "open_tree", __NR_open_tree },
- { "fsopen", __NR_fsopen },
- { "fallocate", __NR_fallocate },
+#define UL_SYSCALL(name, nr) { name, nr },
+#include "syscalls.h"
+#undef UL_SYSCALL
};
+static_assert(sizeof(syscalls) > 0, "no syscalls found");
static void __attribute__((__noreturn__)) usage(void)
{
tools/config-gen.d/non-libmount.conf \
\
tools/asciidoctor-includetracker.rb \
- tools/asciidoctor-unicodeconverter.rb
+ tools/asciidoctor-unicodeconverter.rb \
+ \
+ tools/all_syscalls
--- /dev/null
+#!/bin/bash
+
+set -e
+
+OUTPUT=syscalls.h
+SYSCALL_INCLUDES="
+#include <sys/syscall.h>
+"
+
+trap 'rm $OUTPUT $OUTPUT.deps' ERR
+
+"$@" -MD -MF "$OUTPUT.deps" <<< "$SYSCALL_INCLUDES" -dM -E - \
+ | gawk 'match($0, /^#define __NR_([^ ]+)/, res) { print "UL_SYSCALL(\"" res[1] "\", __NR_" res[1] ")" }' \
+ | sort \
+ > "$OUTPUT"