Akshat Gupta

Finally invoved in Open Source :)

Getting hands dirty with Linux module

I have always been intimated by people who work on Linux kernel. This May I had the opportunity to make my own module. So here is my take on this.

The first thing that is required is the latest kernel on a VM. Yes VM is the most important thing …. you do not want your machine to crash or lose data or get your RAM fried ;). After having the kernel ready (make sure you compile the kernel so that you have the sources and all the kernel development flags are set) go through a good tutorial which helps you with the Hello World module …. you have developed your own module.

Easy right … but the pain is yet to come. Lot of help with sample codes can be found by googling .. but not all can be used directly. Before using the code snippet one needs to make sure about the kernel version thanks to the changing api’s for each release of the kernel. So what do you do from here. Copy the code snippet, compile and hope for the best. If it does not compile, you know you are facing changed API .. the best thing to do in that case is to check the header files and fix the function calls. The comments in the header file are excellent and they guide a noob well on what all needs to be touched and what need not be.

Here are some nice Links which I found:

Hello word

Some code snippets
TIP: Do not be scared to try out things … worst (and most) case is a reboot 😉

TIP: Install logrotate as the log file will be becoming long very soon

TIP: The kernel stack space is only 4KB do not allocate space that is more than this

I will be adding more tips as and when I remember them till then …..Happy hacking

Advertisements

May 21, 2009 - Posted by | Uncategorized

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: