Inserting a module (2.6 kernel)
From: Steve Hemond
Date: Tue Jun 08 2004 - 19:30:48 EST
Hi people,
I am new to kernel module writing and I base myself on the Linux Device Drivers book from O'reilly. I have written this simple module :
#include <linux/module.h>
int init_module(void)
{
printk("<1>Module inserted\n");
return 0;
}
void cleanup_module(void)
{
printk("<1>Module removed\n");
}
--------------------------------------------
And this is the Makefile :
KERNELDIR = /usr/src/linux
include $(KERNELDIR)/.config
CFLAGS = -D__KERNEL__ -DMODULE -I$(KERNELDIR)/include \
-O -Wall
ifdef CONFIG_SMP
CFLAGS += -D__SMP__ -DSMP
endif
all : moduletest.o
clean :
rm -f *.o *~ core
---------------------------------------------
And look at this :
bash-2.05b# make
gcc -D__KERNEL__ -DMODULE -I/usr/src/linux/include -O -Wall -c -o moduletest.o moduletest.c
bash-2.05b# insmod ./moduletest.o
insmod: error inserting './moduletest.o': -1 Invalid module format
Anyone know what needs to be added or changed for kernel 2.6, or maybe its simply my own mistake?
(By the way, if you know of a kernel-beginner mailing list that would be better suited about this, tell me)
Thanks a lot in advance,
Best regards,
Steve
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/