[PLUG] Inserting module in 2.4.20-8

Jayesh Agrawal jayeshleo at gmail.com
Fri Dec 7 11:19:39 IST 2007


Hello !

 I have written a hello.c program
#define MODULE
#define LINUX
#define __KERNEL__

#include<linux/init.h>
#include<linux/module.h>
#include<linux/kernel.h>
#include<linux/config.h>



int init_module(void)
{
printk("<1> Hello World 1.\n");
return 0;
}

void cleanup_module(void)
{
printk("<1> Bye World");
}

I have also written a Makefile for it...

TARGET := hello
WARN := -W -Wall -Wstrict-prototypes -Wmissing-prototypes
INCLUDE := -isystem /lib/modules/'uname -r'/build/include
CFLAGS := -O2 -DMODULE -D__KERNEL__ ${WARN} ${INCLUDE}
CC := gcc

${TARGET}.o: ${TARGET}.c

.PHONY: clean

clean:
rm -rf ${TARGET}.o

Can anybody please tell me the steps to insert the module in the
kernel. so that if i do dmesg on terminal it should say "Hello
World"..Tell me corrections if any in the above two programs... I was
able to compile to make hello-1.o file.

This is what i am getting

[root at localhost root]# insmod ./hello-1.o
./hello-1.o: kernel-module version mismatch
        ./hello-1.o was compiled for kernel version 2.4.20
        while this kernel is version 2.4.20-8smp.


Thanks.




More information about the Plug-mail mailing list