#include <linux/module.h> static int hello_init() { printk("<0>hello world\n"); return 0; } static void hello_exit() { printk("<0>exit"); } module_init(hello_init); module_exit(hello_exit);
Makefile
ifneq ($(KERNELRELEASE),)
obj-m := hello.o
else
KDIR := /lib/modules/$(shell uname -r)/build
all:
make -C $(KDIR) M=$(PWD) modules
clean:
rm-f *.ko *.o *.mod.o *.mod.c *.symvers
endif