学习内核模块编程,第一个小程序当然是hello,kernel!了.
1.首先编写hello.c文件
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
MODULE_LICENSE("GPL");
static int hello_init(void)
{
printk(KERN_ALERT "hello,I am fine.\n");
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT "goodbye,kernel\n");
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_AUTHOR("mcu");
MODULE