lkml.org 
[lkml]   [2004]   [Jun]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectInserting a module (2.6 kernel)
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@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:03    [W:0.041 / U:0.176 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site