在 Linux 中创建系统调用

发布于 2024-09-26 05:12:04 字数 465 浏览 7 评论 0原文

今天我们刚刚为我的“操作系统”课程完成了一个期中项目,要求我们实现一个系统调用(我想我假设我们必须编写一段代码来调用它)。

我知道我需要更新系统调用表(不记得名称,但没什么大不了的),以及创建该表将指向的内核模块,但这是否意味着我必须重新编译整个内核,以便内核知道我的模块?

我已经看到有可能劫持当前的系统调用,但我怀疑如果我这样做,我将不会获得我的作业的学分。

只是想感受一下我将做出的努力有多大。

更新: 好吧,这最终有点麻烦,他们从我相信 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

栩栩如生 2024-10-03 05:12:04

您想阅读:

  • 《Linux 内核编程,第三版》(平装本),作者:Michael Beck(作者)、Harald Bohme(作者)、Mirko Dziadzka(作者)、Ulrich Kunitz(作者)、Robert Magnus(作者) )、Dirk Verworner(作者)、Claus Schroter(作者),Addison-Wesley(培生教育)出版,ISBN-10:0201719754ISBN-13:978-0201719758

可能还有更多详细信息:

  • Understanding the Linux Kernel, Third Edition 作者:Daniel P. Bovet、Marco Cesati,由 O'Reilly 出版,ISBN 10:0-596-00565- 2ISBN 13:9780596005658
  • Linux 设备驱动程序,第三版作者:Jonathan Corbet、Alessandro Rubini、Greg Kroah-Hartman,由 O'Reilly 出版,ISBN 10:0-596-00590-3ISBN 13:9780596005900

You want to read:

  • Linux Kernel Programming, Third Edition (Paperback) by Michael Beck (Author), Harald Bohme (Author), Mirko Dziadzka (Author), Ulrich Kunitz (Author), Robert Magnus (Author), Dirk Verworner (Author), Claus Schroter (Author), published by Addison-Wesley (Pearson Education), ISBN-10: 0201719754 , ISBN-13: 978-0201719758

and possibly as well for more details:

  • Understanding the Linux Kernel, Third Edition By Daniel P. Bovet, Marco Cesati, published by O’Reilly, ISBN 10: 0-596-00565-2, ISBN 13: 9780596005658
  • Linux Device Drivers, Third Edition By Jonathan Corbet, Alessandro Rubini, Greg Kroah-Hartman, published by O’Reilly, ISBN 10: 0-596-00590-3, ISBN 13: 9780596005900
与他有关 2024-10-03 05:12:04

但这是否意味着我必须重新编译整个内核,以便内核知道我的模块?

是的,您需要重新编译内核。

but does this mean I'll have to recompile the whole kernel, so the kernel knows about my module?

Yes, you will need to recompile the kernel.

总攻大人 2024-10-03 05:12:04

我了解我需要更新
系统调用表

它是/usr/src/linux/arch/i386/kernel/syscall_table.S

这是否意味着我必须重新编译
整个内核,所以内核知道
关于我的模块?

是的,确实如此。

Just wanted to get a feel for the size of the effort I'll be making.

如果您知道要编写哪些代码作为系统调用的一部分,那么您就已经完成了。您只需等待内核重新编译时间结束即可。以下是一组说明:

实现系统调用在Linux中

I understand I'll need to update the
table of the system calls

It's /usr/src/linux/arch/i386/kernel/syscall_table.S

does this mean I'll have to recompile
the whole kernel, so the kernel knows
about my module?

Yes, indeed.

Just wanted to get a feel for the size of the effort I'll be making.

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文