kernel module: beginner

H

h.silent57

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
 
I

Ian Collins

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.
 
I

Ian Malone

Ian said:
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.
 
J

Joe Estock

Ian said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top