How to make system call from another system call in kernel space

限于喜欢 提交于 2019-12-02 02:54:55

There is no generic way of doing this.

If you are in kernel space, you should invoke kernel functions that implement the system call functionality directly instead of using syscall-type instructions, or use other means of extracting the desired information / affecting the desired action.

For the specific case of getpid(), you can simply use current->pid.

The kernel name current is always a pointer to the current task_struct, which is defined via <linux/sched.h> (search for struct task_struct). Code that accesses members of that usually gets inlined, i.e. there's not even a function call (and much less a system call) required to get these when your code is running as part of the kernel.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!