免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 9475 | 回复: 3
打印 上一主题 下一主题

驱动中使用register_reboot_notifier的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-03-22 17:15 |只看该作者 |倒序浏览
最近写了个驱动,经常重启系统,想在系统重启的时候记录一些东西,在网上查到这个函数,并且由一个例子,但是运行是一直不能想要的到的结果,希望高人指点一下,非常感谢。
测试系统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);

论坛徽章:
0
2 [报告]
发表于 2012-03-26 13:34 |只看该作者
怎么没有兄弟帮忙呀,自己顶一下。

论坛徽章:
0
3 [报告]
发表于 2015-10-09 10:19 |只看该作者
请问,你的问题解决了吗?我在运行reboot命令后,也看不到日志;但是insmod / rmmod  都是成功的。如果解决了麻烦你告诉我一下,QQ:909078892

论坛徽章:
0
4 [报告]
发表于 2015-10-09 19:21 |只看该作者
混一下。。。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP