views:

77

answers:

3

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.

+3  A: 

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.

dbyrne
So far it looks good, I'll look it over closer when I get to school, and it's looking like it's solved! -- Have you ever done this before, in your opinion is it very difficult? It doesn't look to be from my perspective, but I haven't ever attempted it, so I'm not sure.
onaclov2000
I think you should be fine. Compiling the kernel takes about 5 minutes or so unless you are on ancient hardware.
dbyrne
Hmmm I did make yestoallconfig (or something like that), and then a make, and its been goign for at least 30 minutes, I'm on a 3.2Ghz machine with dual processor, and I think around 4Gb of ram.... then again I'm compiling from scratch if that helps
onaclov2000
Yeah, I guess the compilation time will have a pretty wide variance depending on your configuration. How long did it end up taking?
dbyrne
+2  A: 

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

Kedar Soparkar
That's way better than my lazy answer. I upvote yours.
haylem
+3  A: 

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
haylem
I have the 2nd edition of the Device drivers book, and the 3rd is online free, very interesting book!
onaclov2000
The first one I mentioned is the best if you want to get into linux kernel development. It covers the design of the OS itself well, and drives you through your hacking it.
haylem