I see a lot of people online referencing
arch/x86/entry/syscalls/syscall_64.tbl
for the syscall table, that works fine. But a lot of others reference
/include/uapi/asm-generic/unistd.h
which is commonly found in the headers package. How come syscall_64.tbl
shows,
0 common read sys_read
The right answer, and unistd.h
shows,
#define __NR_io_setup 0
__SC_COMP(__NR_io_setup, sys_io_setup, compat_sys_io_setup)
And then it shows __NR_read
as
#define __NR_read 63
__SYSCALL(__NR_read, sys_read)
Why is that 63, and not 1? How do I make sense of out of /include/uapi/asm-generic/unistd.h
? Still in /usr/include/asm/
there is
/usr/include/asm/unistd_x32.h
#define __NR_read (__X32_SYSCALL_BIT + 0)
#define __NR_write (__X32_SYSCALL_BIT + 1)
#define __NR_open (__X32_SYSCALL_BIT + 2)
#define __NR_close (__X32_SYSCALL_BIT + 3)
#define __NR_stat (__X32_SYSCALL_BIT + 4)
/usr/include/asm/unistd_64.h
#define __NR_read 0
#define __NR_write 1
#define __NR_open 2
#define __NR_close 3
#define __NR_stat 4
/usr/include/asm/unistd_32.h
#define __NR_restart_syscall 0
#define __NR_exit 1
#define __NR_fork 2
#define __NR_read 3
#define __NR_write 4
Could someone tell me the difference between these unistd
files. Explain how unistd.h
works? And what the best method for finding the syscall table?
tux
syscall). – Stephen Kitt Sep 03 '19 at 20:44