简体   繁体   English

如何从内核调用系统调用?

[英]How to call system call from kernel?

I'm trying to invoke the getrusage() system call from kernel space, but I don't know how. 我正在尝试从内核空间调用getrusage()系统调用,但是我不知道如何。

I read about getting the kernel export ( Can we call system call in kernel space? ), but I don't know what that is or how to use it. 我读过有关导出内核的信息( 我们可以在内核空间中调用系统调用吗? ),但是我不知道它是什么或如何使用它。 Could someone show me how to call a system call from the kernel in C? 有人可以告诉我如何在C语言中从内核调用系统调用吗?

Edit: The old title was for a draft of a question, sorry! 编辑:旧标题是一个问题的草稿,对不起!

How to call system call from kernel? 如何从内核调用系统调用?

You don't. 你不知道 It doesn't even make sense. 这甚至没有意义。 It's like asking "How do I enter my house when I'm already inside my house?". 这就像问“我已经进入屋子后如何进入房屋?”。

In the kernel there's a whole bunch of functions. 内核中有很多功能。 Some of them are added to the system call table and some aren't; 其中一些被添加到系统调用表中,而某些则没有。 but if you're already in the kernel you can use them without caring if they were added to the system call table or not. 但是,如果您已经在内核中,则可以使用它们而不必关心它们是否已添加到系统调用表中。 Note that if you're writing a kernel module then it ends up being dynamic linking done when the module is loaded (a bit like the kernel is a shared library). 请注意,如果你正在写一个内核模块,然后它最终被动态加载模块时对链接进行(有点像内核是一个共享库)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM