Home > database >  Where is sys_mount defined in linux kernel(.14.255)?
Where is sys_mount defined in linux kernel(.14.255)?

Time:09-30

I find the use of 'sys_' in many places in linux kernel,such as 'sys_mount' ,'sys_unlink'...... But I can't find where are these functions(or something else) defined.I guess they are defined in some ways like #define sys(name) sys_##name(){}. Can you tell me where and how they are defined?The kernel version is 4.14.255.

CodePudding user response:

The table of syscalls seems to be defined for each architecture, e.g.

#
# 64-bit system call numbers and entry vectors
#
# The format is:
# <number> <abi> <name> <entry point>
#
# The abi is "common", "64" or "x32" for this file.
#
0   common  read            sys_read
1   common  write           sys_write
2   common  open            sys_open
3   common  close           sys_close
...

Source: https://github.com/torvalds/linux/blob/v4.14/arch/x86/entry/syscalls/syscall_64.tbl

The functions themselves are spread throughout the code. For example, sys_read is defined as:

SYSCALL_DEFINE3(read, unsigned int, fd, char __user *, buf, size_t, count)
{
    return ksys_read(fd, buf, count);
}

Source: https://github.com/torvalds/linux/blob/v4.14/fs/read_write.c#L615-L618

The SYSCALL_DEFINE3 macro is defined at https://github.com/torvalds/linux/blob/v4.14/include/linux/syscalls.h#L198.

  • Related