d33tah
d33tah

Reputation: 11618

How to find a definition of a specific syscall in Linux sources?

I recently wanted to see how is open() system call implemented in Linux kernel. Looking at the syscall table suggested that the name of the function I'm looking for is sys_open(), so I grepped for it. I couldn't find any declaration though, the closest I could get was do_sys_open in fs/open.c. Is it somehow translated into this function? What may I have missed?

Upvotes: 2

Views: 1564

Answers (1)

Anton Kovalenko
Anton Kovalenko

Reputation: 21517

No, do_sys_open is not the implementation of sys_open, it's just a common code of open and openat factored out.

Syscall function names, which are always sys_something, are generated by funny preprocessor macros (SYSCALL_DEFINEn where n is the number of arguments).

As you can see (very close to do_sys_open):

SYSCALL_DEFINE3(open, const char __user *, filename, int, flags, umode_t, mode)
{
        long ret;
        ....

This is the code of open syscall.

Upvotes: 7

Related Questions