hello.c
#include <linux/module.h>
#include <linux/init.h>
static int __init hello_init(void)
{
printk(KERN_ALERT "Hello,world!\n");
return 0;
}
static void __exit helo_exit(void)
{
printk(KERN_ALERT "GoodBye,cruel world!\n");
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE("Dual BSD/GPL");
MODULE_AUTHOR("codingbug");
MODULE_DESCRIPTION("STUDY_MODULE");
Makefile
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
1 obj-m += hello.o 2 KDIR:=/lib/modules/$(shell uname -r)/build 3 all: 4 make -C $(KDIR) M=$(PWD) modules 5 clean: 6 make -C $(KDIR) M=$(PWD) clean