在 Linux 中创建系统调用
今天我们刚刚为我的“操作系统”课程完成了一个期中项目,要求我们实现一个系统调用(我想我假设我们必须编写一段代码来调用它)。
我知道我需要更新系统调用表(不记得名称,但没什么大不了的),以及创建该表将指向的内核模块,但这是否意味着我必须重新编译整个内核,以便内核知道我的模块?
我已经看到有可能劫持当前的系统调用,但我怀疑如果我这样做,我将不会获得我的作业的学分。
只是想感受一下我将做出的努力有多大。
更新: 好吧,这最终有点麻烦,他们从我相信 2.6.32 开始改变了一些东西,所以当我回到我发现的在线教程特定的先前内核版本时,它真的很容易遵循。如果有人在网上发现了这一点并正在学习教程,最初我建议首先下载教程中的相同内核,然后在了解自己在做什么后从那里继续前进。如果你真的熟悉编译内核等,你可能不会有问题,但这是我第一次编译内核,所以编译了2个小时然后发现有些东西不起作用,很痛苦,并且必须重新做一遍,尤其是当我不确定自己做错了什么/没做错什么时。
We just got a midterm project today for my "operating systems" course, we are requested to implement a system call (and I guess I assume we'll have to write a piece of code to call it).
I understand I'll need to update the table of the system calls (can't remember the name, but no biggie), as well as create a kernel module that the table will point to, but does this mean I'll have to recompile the whole kernel, so the kernel knows about my module?
I have seen that it's possible to hijack a current system call, but I suspect that I won't get credit for my assignment if I do it that way.
Just wanted to get a feel for the size of the effort I'll be making.
UPDATE:
Well it kinda ended up being a hassle, they change some things from I believe 2.6.32 forward, so when I went back to a previous kernel version specific to the tutorials online I found, it was really easy to follow. If anyone catches this online and are following a tutorial, initially I would recommend downloading the same kernel in the tutorial initially, then move forward from there once you have an understanding of what you're doing. If you're really familiar with compiling kernels, etc, you might not have an issue, but this was my first time compiling a kernel, so it was a pain to compile for 2 hours and then find out something didn't work, and have to do it all over again, especially when I wasn't sure what I was/wasn't doing wrong.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您想阅读:
可能还有更多详细信息:
You want to read:
and possibly as well for more details:
是的,您需要重新编译内核。
Yes, you will need to recompile the kernel.
它是
/usr/src/linux/arch/i386/kernel/syscall_table.S
是的,确实如此。
如果您知道要编写哪些代码作为系统调用的一部分,那么您就已经完成了。您只需等待内核重新编译时间结束即可。以下是一组说明:
实现系统调用在Linux中
It's
/usr/src/linux/arch/i386/kernel/syscall_table.S
Yes, indeed.
If you know what code you are going to write as a part of the system call, you're already done. You only have to wait out the kernel recompilation time. Here's a set of instructions:
Implementing a System Call in Linux