For Programmers: Free Programming Magazines  


Home > Archive > C > June 2006 > kernel module: beginner









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author kernel module: beginner
h.silent57@gmail.com

2006-06-28, 3:56 am

hi.. I m new to kernel programming..for my in-house project, I chose
to create a device driver for mouse for which I am required to
understand Kernel module programming..I tried to execute this small
module ..though it is getting complied but after trying hard with
insmod and makefile commands.. I am still not able to execute it..

Below is my program written on localhost in linux version 2.4.20-8

#define MODULE
#include <linux/module.h>

int init_module()
{
printk("init_module invokded\ n");
printk("the message is printed from the kernel space\n");
return 0;
}
void cleanup_module()
{printk("cleanup_module invoked\n");
printk("module is now going to be unloaded from kernel \n");
}

[student@localhost student]$ gcc -c simple.c
simple.c:6:8: warning: unknown escape sequence: '\040'

[student@localhost student]$ insmod simple.c
bash: insmod: command not found

Please help me out ... looking forward to your reply.
Thanx

Ian Collins

2006-06-28, 3:56 am

h.silent57@gmail.com wrote:
> hi.. I m new to kernel programming..for my in-house project, I chose
> to create a device driver for mouse for which I am required to
> understand Kernel module programming..I tried to execute this small
> module ..though it is getting complied but after trying hard with
> insmod and makefile commands.. I am still not able to execute it..
>

You should take this to a Linux kernel group, it's off topic here.

--
Ian Collins.
Ian Malone

2006-06-28, 7:57 am

Ian Collins wrote:
> h.silent57@gmail.com wrote:
> You should take this to a Linux kernel group, it's off topic here.
>


Actually I think this is a C question, the gcc warning suggests
the problem is the space after '':
printk("init_module invokded\ n");

I'd guess the OP meant '\n' (and "invoked" too). Get good at typing
(and reviewing), typos can cause endless pain when programming.

But yes, any questions about actually doing kernel programming
should be sent to a kernel group. I'd imagine there's a kernel
mailing list for people learning to program modules.

--
imalone
Joe Estock

2006-06-28, 7:58 am

Ian Malone wrote:
> Ian Collins wrote:
>
> Actually I think this is a C question, the gcc warning suggests
> the problem is the space after '':
> printk("init_module invokded\ n");
>
> I'd guess the OP meant '\n' (and "invoked" too). Get good at typing
> (and reviewing), typos can cause endless pain when programming.
>
> But yes, any questions about actually doing kernel programming
> should be sent to a kernel group. I'd imagine there's a kernel
> mailing list for people learning to program modules.
>


Theres also a manual and several thousand websites dedicated to this
topic. A quick search on google for "kernel module programming" should
bring up some informative results.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com