#include
#include
MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(void)
{
printk(KERN_ALERT "Hello World"\n);
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT "Goodbye,Cruel World\n");
}
module_init(hello_init);
module_exit(hello_exit);
编译该helloworld的makefile文件是:
obj-m := helloworld.o
KERNELDIR := /lib/modules/3.0.4/build
PWD := $(shell pwd)
modules:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
modules_install:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install
clean:
rm -rf *.o *~core .depend .*.cmd *.ko *.mod.c .tmp_versions $(TARGET)