Hi,
I have been trying to compile and insert a simple kernel module but without luck. This is what I did.
Since the freshly installed debian sarge 3.1 distro did not have any source files under /usr/src, I di uname -a to make sure of the kernel version that is installed:
Linux test 2.4.27-2-386 #1 Mon May 16 16:47:51 JST 2005 i686 GNU/Linux
and then I downloaded the kernel-source-2.4.27.tar.bz2, unziped and untarred it. I then copied this program from a book into example.c:
Code:
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
static char __initdata hellomessage[] = KERN_NOTICE "Hello, world!\n";
static char __exitdata byemessage[] = KERN_NOTICE "Goodbye, cruel world.\n";
static int __init start_hello_world(void)
{
printk(hellomessage);
return 0;
}
static void __exit go_away(void)
{
printk(byemessage);
}
module_init(start_hello_world);
module_exit(go_away);
I then compiled it using
gcc -DMODULE -D__KERNEL__ -I/usr/src/kernel-source-2.4.27/include -c example.c
I tried inserting it into the kernel using
/sbin/insmod example.o
but this is the message I got back:
example.o: kernel-module version mismatch
example.o was compiled for kernel version 2.6.0
while this kernel is version 2.4.27-2-386.
example.o: cannot create /var/log/ksymoops/20051125172050.ksyms Permission denied
I don't understand how it could have been compiled for a version of the kernel that I did not use. Thanks in advance.
Amish