hello.c
#include <linux/init.h>
#include <linux/module.h>
MODULE_LICENSE("Dual BSD/GPL");
static int hello_module_init(void)
{
printk(KERN_ALERT"hello/n");
return 0;
}
static void hello_module_exit(void)
{
printk(KERN_ALERT"bye-bye/n");
}
module_init(hello_module_init);
module_exit(hello_module_exit);
Makefile
#Makefile 2.6
ifneq ($(KERNELRELEASE),)
mymodule-objs:=hello.o
obj-m:=hello.o
else
PWD:=$(shell pwd)
KVER:=$(shell uname -r)
KDIR:=/lib/modules/$(KVER)/build
all:
$(MAKE) -C $(KDIR) M=$(PWD) modules
endif
一定记得要加TAB