Map syscall nr to syscall name
sahil aggarwal
sahilagg0693 at gmail.com
Fri May 8 06:23:25 EDT 2015
Found something easier:
syscallent.sh ( similar to used by strace )
---------------------------------------------------------
cat ${1+"$@"} |
sed -n 's/^#[ ]*define[ ][ ]*SYS_\([^ ]*\)[
]*[^0-9]*\([0-9]*\).*$/\1 \2/p
s/^#[ ]*define[ ][ ]*__NR_\([^ ]*\)[
]*[^0-9]*\([0-9]*\).*$/\1 \2/p
s/^#[ ]*define[ ][ ]*__NR_\([^ ]*\)[ ]*[^0-9()]*(__NR_Linux +
\([0-9]*\))$/\1 \2/p' |
sort -k2n | uniq |
awk '
BEGIN {
h = "#ifndef _H_SYSCALLENT\n#define
_H_SYSCALLENT\nchar *syscalls[] = { "
print h
}
{
s = "\"" $1 "\","
print s
}
END {
f = " };\n#endif"
print f
}
'
---------------------------------------------------------
This creates header file:
#ifndef _H_SYSCALLENT
#define _H_SYSCALLENT
char *syscalls[] = {
"read",
"write",
"open",
"close",
"stat",
"fstat",
"lstat",
"poll",
"lseek",
"mmap",
......
.....
...
}
#endif
---------------------------------------------------------
included in makefile:
ARCH := $(shell getconf LONG_BIT)
ifeq ($(ARCH),64)
./syscallent.sh /usr/include/asm/unistd_64.h > $(INCDIR)/syscallent.h
else
./syscallent.sh /usr/include/asm/unistd_32.h > $(INCDIR)/syscallent.h
endif
---------------------------------------------------------
Works fine for me. Just want to know if this will be portable method
and won't produce wrong result in any case.?
More information about the Kernelnewbies
mailing list