In Linux where can I find the source code for all system calls given that I have the source tree? Also if I were to want to look up the source code and assembly for a particular system call is there something that I can type in terminal like my_system_call?
In Linux where can I find the source code for all system calls given
Share
You’ll need the Linux kernel sources in order to see the actual source of the system calls. Manual pages, if installed on your local system, only contain the documentation of the calls and not their source itself.
Unfortunately for you, system calls aren’t stored in just one particular location in the whole kernel tree. This is because various system calls can refer to different parts of the system (process management, filesystem management, etc.) and therefore it would be infeasible to store them apart from the part of the tree related to that particular part of the system.
The best thing you can do is look for the
SYSCALL_DEFINE[0-6]macro. It is used (obviously) to define the given block of code as a system call. For example,fs/ioctl.chas the following code :Such a definition means that the
ioctlsyscall is declared and takes three arguments. The number next to theSYSCALL_DEFINEmeans the number of arguments. For example, in the case ofgetpid(void), declared inkernel/timer.c, we have the following code :Hope that clears things up a little.