$ cat kmod.c
#include <linux/module.h>
#include <linux/init.h>
MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(void)
{
printk(KERN_ALERT "KERN_ALERT <1> \n");
printk(KERN_CRIT "KERN_CRIT <2> \n");
printk(KERN_ERR "KERN_ERR <3> \n");
printk(KERN_WARNING "KERN_WARING <4> \n");
printk(KERN_NOTICE "KERN_NOTICE <5> \n");
printk(KERN_INFO "KERN_INFO <6> \n");
printk(KERN_DEBUG "KERN_DEBUG <7> \n");
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT "driver unloaded, good bye kernel.\n");
}
module_init(hello_init);
module_exit(hello_exit);
参考
http://mcommit.hatenadiary.com/entry/2017/12/14/234643