What does the “name” parameter mean in the syscall_32.tbl linux file?

落爺英雄遲暮 提交于 2019-12-11 01:54:16

问题


I am adding some custom system calls to linux Fedora and I am currently trying to update "syscall_32.tbl". The only hiccup is that I am not too sure what the name field for the call table means.

Is this something we just make up? As in a name that we decide to call this particular system call?

For example the structure of the table is:

<number> <abi> <name> <entry point> <compat entry point>

For the <name> section is this a parameter that we decide on and just enter there? Or is it something more specific like the filename that the system call is located in?


回答1:


There is a system call table in the kernel, listing all the system calls and their implementing functions. The user-land requests a system call by specifying the index number of the syscall. Therefore this index number must match between kernel compilations and user-land code compilations. Since this list is an error-prone thing to maintain, the system call table that you have found was introduced, and code is generated from it automatically. That table correlates the system calls: their index number, the name to be used in the user-land, and the kernel function name implementing the system call. From this table, the Makefile generates the header files.

There is a header file syscalls_xx.h, it defines the table within the kernel (it lists all the kernel functions implementing the syscalls by their index).

There is another header file unistd_xx.h, it provides #define's for the user-land, listing the syscall index numbers by name. The name field you are asking will get into this list, by which the user-land can refer to this system call: __NR_<xxx>. This header file is copied and used in user-space code so that the syscall index numbers can be referenced by name (see the glibc sources, how these are used).

syscall_32.tbl:

350     i386    finit_module            sys_finit_module

unistd_32.h:

#define __NR_finit_module 350

syscalls_32.h:

__SYSCALL_I386(350, sys_finit_module, sys_finit_module)



回答2:


you also can use the complete list of system calls with their relative system call number in strace source code. e.g for i386 system here is the link:

syscallent.h (i386) in strace sourceforge



来源:https://stackoverflow.com/questions/19648470/what-does-the-name-parameter-mean-in-the-syscall-32-tbl-linux-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!