- 论坛徽章:
- 0
|
最近写了个驱动,经常重启系统,想在系统重启的时候记录一些东西,在网上查到这个函数,并且由一个例子,但是运行是一直不能想要的到的结果,希望高人指点一下,非常感谢。
测试系统fedora 14
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/notifier.h>
#include <linux/reboot.h>
MODULE_LICENSE("Dual BSD/GPL");
static int myreboot(struct notifier_block *self, unsigned long event, void *data)
{
printk(KERN_ALERT "Just a test! Event code: %li! System reboot now...", event);
return NOTIFY_OK;
}
static struct notifier_block myreboot_notifier = {
.notifier_call = myreboot,
};
static int myreboot_init(void)
{
register_reboot_notifier(&myreboot_notifier);
return 0;
}
static void myreboot_exit(void)
{
unregister_reboot_notifier(&myreboot_notifier);
}
module_init(myreboot_init);
module_exit(myreboot_exit); |
|