2

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?

1 Answer 1

7

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, exactly what I was looking for! For future reference, what is the easiest way of figuring out such caveats? Was it in the documentation somewhere?
Seems not to be documented (that is, there are some explanations on the Internet, no more official than mine). Pretty easy to figure it out when you look at cross-referenced linux source: lxr.linux.no/#linux+v3.7.4/fs/open.c or lxr.free-electrons.com/ident?i=sys_open (you just need enough curiousity to look up unknown macros all the way down, and some intuition telling where to expect interesting things).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.