This is what I get:
Code:
root, test/ # lsmod
Module Size Used by
nvidia 3465148 12
root, test/ # cat hello.c
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(void)
{
printk("Hello World!\n");
return 0;
}
static void hello_exit(void)
{
printk("Good bye!\n");
}
module_init(hello_init);
module_exit(hello_exit);
root, test/ # cat Makefile
#
# Makefile for hello.c file
#
KDIR:=/lib/modules/$(shell uname -r)/build
obj-m:=hello.o
default:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
clean:
$(RM) .*.cmd *.mod.c *.o *.ko -r .tmp*
root, test/ # ll
insgesamt 8,0K
-rw-r--r-- 1 root 286 30. Nov 21:02 hello.c
-rw-r--r-- 1 root 191 30. Nov 21:03 Makefile
root, test/ # make
make -C /lib/modules/2.6.9-gentoo-r4/build SUBDIRS=/root/test modules
make[1]: Entering directory `/usr/src/linux-2.6.9-gentoo-r4'
CC [M] /root/test/hello.o
Building modules, stage 2.
MODPOST
CC /root/test/hello.mod.o
LD [M] /root/test/hello.ko
make[1]: Leaving directory `/usr/src/linux-2.6.9-gentoo-r4'
root, test/ # ll
insgesamt 24K
-rw-r--r-- 1 root 286 30. Nov 21:02 hello.c
-rw-r--r-- 1 root 2,2K 30. Nov 21:05 hello.ko
-rw-r--r-- 1 root 632 30. Nov 21:05 hello.mod.c
-rw-r--r-- 1 root 1,7K 30. Nov 21:05 hello.mod.o
-rw-r--r-- 1 root 1,2K 30. Nov 21:05 hello.o
-rw-r--r-- 1 root 191 30. Nov 21:03 Makefile
root, test/ # insmod hello.ko
root, test/ # lsmod
Module Size Used by
hello 1152 0
nvidia 3465148 12
root, test/ #
So I'd say it works. Are you sure you're building against the right kernel? You should be getting a .ko file I suppose.