Forum Moderators: bakedjake

Message Too Old, No Replies

how to insert module in fedora core 2

         

murali_ym

1:52 pm on Jan 27, 2005 (gmt 0)

10+ Year Member



The following module got error when i tried to insert to kernel.
// hello.c
#include <linux/module.h> // required by all modules
#include <linux/kernel.h> // required by printk()
#include <linux/init.h>

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Zoe");

// Start/Init function
static int hello_init(void) {
printk("<1>Hello world!\n"); // A logging mechanism for kernel
return 0; // A non-zero return means hello_init failed; the module can't be loaded.
}

// End/Cleanup function
static void hello_exit(void) {
printk("<1>Goodbye world!\n");
}

module_init(hello_init);
module_exit(hello_exit);

I got the following message when I have tried to install into kernel using insmod::
insmod -f ./hello.o

insmod: error inserting './hello.o': -1 Invalid module format

SeanW

6:49 pm on Jan 27, 2005 (gmt 0)

10+ Year Member



How did you compile it? Did you have -O2 -DMODULE -D__KERNEL__

Sean

murali_ym

4:15 am on Jan 28, 2005 (gmt 0)

10+ Year Member



yeah.i compiled it like that.but i was unable to "insmod".i have doubt on the existing FC2,since i did google only to find similar bugs

murali_ym

4:22 am on Jan 28, 2005 (gmt 0)

10+ Year Member



i compiled with this command and i got this error

cc -O2 -DMODULE -D__KERNEL__ -c hello.c
In file included from /usr/include/linux/module.h:10,
from hello.c:2:
/usr/include/linux/config.h:5:2: #error Incorrectly using glibc headers for a kernel module

if i commpiled with out __KERNEL__.its compiled correctly without error but i can't install module into kernel.if i try i got this error message.

insmod ./hello.o
insmod: error inserting './hello.o': -1 Invalid module format

Pls give me suggestion.