strsyscall.sh (638B)
- #!/bin/sh
- # SPDX-FileCopyrightText: 2024 Haelwenn (lanodan) Monnier <contact+mstrace@hacktivis.me>
- # SPDX-License-Identifier: MPL-2.0
- grep -F '#define SYS_' tmp_strsyscall.h | sort -n -k 3 -r | head -1 | if read op name num; then
- echo "\
- #define SYSCALLS_MAX $((num+1))
- extern const char *str_syscalls[SYSCALLS_MAX];" >|strsyscall.h
- fi
- cat <<'EOF'
- #include <sys/syscall.h>
- #include "strsyscall.h"
- const char *str_syscalls[SYSCALLS_MAX] = {
- EOF
- grep -F '#define SYS_' tmp_strsyscall.h | while read op name num; do
- name_short=${name//SYS_}
- printf '#ifdef %s\n\t[%s] = "%s",\n#endif\n' "$name" "$name" "${name//SYS_}"
- done
- echo '};'