2

I wonder to find out the codes of the function "sys_access", but i could only find it`s declare:(in include\Syscalls.h)

asmlinkage long sys_access(const char __user *filename, int mode);

i guess it coded by Assemble, but how could i found that?
by the way , i use the source insight to read the linux kernel...it cannot find the symbol in file *.S . Is there more effective tools to read the linux kernel?

Sim Sun
  • 587
  • 1
  • 4
  • 28
  • possible duplicate of [Where can I find system call source code?](http://stackoverflow.com/questions/10149621/where-can-i-find-system-call-source-code). Better group them all into one question, or we'd get 350 similar questions :-) – Ciro Santilli OurBigBook.com May 15 '15 at 16:34

1 Answers1

4

I assume that you have already downloaded kernel sources (not only headers). This function is implemented in C and placed in fs/open.c:

SYSCALL_DEFINE3(faccessat, int, dfd, const char __user *, filename, int, mode)
{
     ...
}

SYSCALL_DEFINE2(access, const char __user *, filename, int, mode)
{
        return sys_faccessat(AT_FDCWD, filename, mode);
}

There are a bunch of methods to search trough files contents. In simple cases I prefer the usage of grep:

$> grep -r "access" /usr/src/linux-2.6/*
maverik
  • 5,508
  • 3
  • 35
  • 55
  • I already have the whole kernel sources. grep will get so many results....i think `SYSCALL_DEFINE2` is a marco which make `access` to `sys_access`.The symbol will be built after linked.so i cann`t located the function like this... – Sim Sun Mar 28 '11 at 09:29
  • do you have some nice method to find the function like that? – Sim Sun Mar 28 '11 at 09:30
  • It is grep. You can use any regular expression you want to make your search easy. For example: `grep -r "SYSCALL_DEFINE.(.*acess.*" /usr/src/linux-2.6/*`. Anyway, regardless of the tool you use to perform search you'll need regexps to find such things. – maverik Mar 28 '11 at 09:38
  • 1
    [ctags](http://ctags.sourceforge.net/) can be very useful for navigating such source code. Or [Doxygen](http://www.stack.nl/~dimitri/doxygen/). No regular expressions required. – johnsyweb Mar 28 '11 at 10:09
  • 1
    @Johnsyweb: While I do like tagging tools, I don't think ctags will be able to recognize `SYSCALL_DEFINEn(foo)` as `sys_foo`. Is there a special configuration that helps with this? (btw, I personally found that [GNU Global](http://www.gnu.org/software/global/) works well for the kernel source.) – Karmastan Mar 28 '11 at 16:40