Edit: as pointed out by alkap, this regex misses a few syscalls, see his answer below this one for a command that doesn't miss any of them.
I am a particularly lazy person so having to manually maintain an include file with system call numbers is not something I want to do. A few months ago I wrote a one-liner to automatically generate those files and now I'm sharing it here because I figured it could be useful to someone.
Note: I am using Debian x86_64 multiarch, the location of these files may be different in your distro. In Debian you must have the package linux-libc-dev installed because it provides the required files.
For the 32 bit calls I use:
sed -n's/#define\s\s*[_A-Z][_A-Z]*//p' /usr/include/asm/unistd_32.h | sed -n's/^\([a-z][_a-z]*\)\s\s*\([0-9][0-9]*\)/sys_\1 = \2/p' > lin32.inc
And for 64 bit I use:
sed -n's/#define\s\s*[_A-Z][_A-Z]*//p' /usr/include/asm/unistd_64.h | sed -n's/^\([a-z][_a-z]*\)\s\s*\([0-9][0-9]*\)/sys_\1 = \2/p' > lin64.inc
The command is the same for both files, only file names are changed. If you can't find the files in that location you can use locate <file> to search for them. These files contain all system calls in the format #define __NR_syscall_name syscall_number.
_________________ I should save this password in some place I can remember.
Last edited by triplefault on 14 Jul 2017, 02:09; edited 1 time in total
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum