diff options
author | Alice Frosi <afrosi@redhat.com> | 2023-03-24 10:07:48 +0100 |
---|---|---|
committer | Alice Frosi <afrosi@redhat.com> | 2023-03-24 15:38:07 +0100 |
commit | 069009f8e39238ec1a67fba6cfb287b9a0cac83e (patch) | |
tree | 77f817eb7b96178b71f3d573a83cec19f7fba09c /scripts | |
parent | 06b0f6d323c396ca1df000af96fdd07cc69b06e0 (diff) | |
download | seitan-069009f8e39238ec1a67fba6cfb287b9a0cac83e.tar seitan-069009f8e39238ec1a67fba6cfb287b9a0cac83e.tar.gz seitan-069009f8e39238ec1a67fba6cfb287b9a0cac83e.tar.bz2 seitan-069009f8e39238ec1a67fba6cfb287b9a0cac83e.tar.lz seitan-069009f8e39238ec1a67fba6cfb287b9a0cac83e.tar.xz seitan-069009f8e39238ec1a67fba6cfb287b9a0cac83e.tar.zst seitan-069009f8e39238ec1a67fba6cfb287b9a0cac83e.zip |
Re-organize project and add license header
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/nr_syscalls.sh | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/scripts/nr_syscalls.sh b/scripts/nr_syscalls.sh new file mode 100755 index 0000000..380d6f1 --- /dev/null +++ b/scripts/nr_syscalls.sh @@ -0,0 +1,63 @@ +#!/bin/sh -eu +# +# SPDX-License-Identifier: AGPL-3.0-or-later +# +# SEITAN - Syscall Expressive Interpreter, Transformer and Notifier +# +# filter.sh - Build binary-search tree BPF program with SECCOMP_RET_USER_NOTIF +# +# Copyright (c) 2022 Red Hat GmbH +# Author: Stefano Brivio <sbrivio@redhat.com> + +IN="${@}" +OUT_NUMBERS="common/numbers.h" + +HEADER_NUMBERS="/* This file was automatically generated by $(basename ${0}) */ +#ifndef NUMBERS_H_ +#define NUMBERS_H_ + +struct syscall_numbers { + char name[1024]; + long number; +}; + +struct syscall_numbers numbers[] = {" + +FOOTER_NUMBERS="}; + +#endif" + +syscalls=( + "accept" + "bind" + "connect" + "getpeername" + "getsockname" + "getsockopt" + "listen" + "mount" + "openat" + "recvfrom" + "recvmmsg" + "recvmsg" + "sendmmsg" + "sendmsg" + "sendto" + "setsockopt" + "shutdown" + "socket" + "socketpair" +) + +printf '%s\n' "${HEADER_NUMBERS}" > "${OUT_NUMBERS}" +# syscall_nr - Get syscall number from compiler, also note in numbers.h +__in="$(printf "#include <asm-generic/unistd.h>\n#include <sys/syscall.h>\n__NR_%s" ${syscalls[@]})" +__out="$(echo "${__in}" |cc -E -xc - -o - |sed -n '/\#.*$/!p'| sed '/^$/d')" + +awk -v AS="${syscalls[*]}" -v BS="${__out[*]}" \ +'BEGIN { MAX=split(AS,a, / /); split(BS,b, / /); +for (x = 1; x <= MAX; x++) + { printf "\t{\"%s\",\t%d},\n", a[x], b[x] } + }' >> "${OUT_NUMBERS}" + +printf '%s\n' "${FOOTER_NUMBERS}" >> "${OUT_NUMBERS}" |