Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
KyL
V2EX  ›  Linux

如何在 Linux Kernel 3.x 中找到某个 system call 的实现呢

  •  
  •   KyL · Aug 28, 2015 · 3194 views
    This topic created in 3939 days ago, the information mentioned may be changed or developed.

    比如我想要找到execve在内核中的实现代码。我在源码中搜索sys_execve,在代码中只能找到头文件声明,系统调用注册的相关代码,找不到函数体。其他系统调用也都有这个问题。请问该如何寻找呢?

    Supplement 1  ·  Aug 28, 2015

    我已经在StackOverflow 的问题里找到答案了

    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.

    4 replies    2015-08-28 17:31:03 +08:00
    whatot
        1
    whatot  
       Aug 28, 2015   ❤️ 1
    搜索 do_execve 看看,我也是 google 到的。

    linux-4.1 fs/exec.c:1704

    SYSCALL_DEFINE3 (execve,
    const char __user *, filename,
    const char __user *const __user *, argv,
    const char __user *const __user *, envp )
    {
    return do_execve (getname (filename ), argv, envp );
    }
    lynx
        2
    lynx  
       Aug 28, 2015
    google: execve site:lxr.free-electrons.com/source
    liwei
        3
    liwei  
       Aug 28, 2015
    make ARCH=x86 -j2 tags cscope
    vim -t sys_execve
    oska874
        4
    oska874  
       Aug 28, 2015
    arm 的我知道: arch/arm/kernel/call.S 里面有系统调用列表,然后你就可以在内核根目录 ctags -R ,在 vim 里面 tags <func_name> 了。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1620 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 16:30 · PVG 00:30 · LAX 09:30 · JFK 12:30
    ♥ Do have faith in what you're doing.