#include
/* Defines the license for this LKM */
MODULE_LICENSE("GPL");
/* Init function called on module entry */
int my_module_init( void )
{
printk(KERN_INFO "my_module_init called. Module is now loaded.\n");
return 0;
}
/* Cleanup function called on module exit */
void my_module_cleanup( void )
{
printk(KERN_INFO "my_module_cleanup called. Module is now unloaded.\n");
return;
}
/* Declare entry and exit functions */
module_init( my_module_init );
module_exit( my_module_cleanup );
|
编写Makefile1:
obj-m : = test.o
KERNELDIR := /lib/modules/$(shell uname -r)/build
default:
(tab键)make -C $(KERNELDIR) M=$(shell pwd) modules
install:
insmod test.ko
uninstall:
rmmod test.ko
clean:
make -C $(KERNELDIR) M=$(shell pwd) clean
阅读(114) | 评论(0) | 转发(0) |