Hello This is Maheshwar.
i am writing simple module for 2.4 kernel
module name is hello.c: vi hello.c
#define __KERNEL__
#define MODULES
#include<linux/init.h>
#include<linux/module.h>
#include<linux/kernel.h>
MODULE_LICENSE("GPL");
static int hello_init(void)
{
printk("\nhello maheshwar");
}
static void hello_exit(void)
{
printk("\nbye maheshwar");
return 0;
}
module_init(hello_init);
module_exit(hello_exit);
compile it using the following command:
gcc -I /usr/src/linux-2.4/include -Wall -c hello.c
you will get hello.o file ,insert the module into the kernel using following command
insmod hello.o
run dmesg
remove the module from the kernel using following command:
rmmod hello
for 2.6 kernel run following Makefile
obj-m +=hello.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean :
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
tldp.org/LDP/lkmpg/2.6/html/lkmpg.html --ENJAY