//Hello.c
#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!\n");
}
module_init(hello_init);
module_exit(hello_exit);
//Makefile
ifneq ($(KERNEL|RELEASE),)
obj-m:=hello.o
else
obj-m:=hello.o
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD:=$(shell pwd)
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
.PHONY:clean
clean:
rm deit $(objects)
endif
/////
insmod hello.ko
lsmod | grep hello
rmmod hello
阅读(732) | 评论(0) | 转发(0) |