dmesg没有显示printk语句 [英] dmesg is not showing printk statement

查看:620
本文介绍了dmesg没有显示printk语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个proc条目. 我的init_module函数如下所示

I'm trying to create a proc entry. My init_module function is as below

int init_module()
{
printk(KERN_INFO "proc2:Module Loaded\n");
proc_entry=proc_create_data(proc_name,0644,NULL,&fops,NULL);
if(proc_entry==NULL)
{
    printk(KERN_INFO "proc2:Error registering proc entry");
}
else
{
    printk(KERN_INFO "proc2:Proc Entry Created");
}
return 0;
}

以下是清理方法

void cleanup_module()
{
printk(KERN_INFO "proc2:module unloaded");
remove_proc_entry(proc_name,proc_entry);
}

程序的其余部分包括变量定义和回调函数.

rest of program include variable definition and callback functions.

当我编译该程序时,它可以很好地编译. 当我使用insmod时,它不会回复我的提示. lsmod列出了我的模块并显示了一个模块所使用的模块(不知道是什么). dmesg不显示上述所有printk消息.

when i compile this program it compiles well. when i use insmod it doesn't reply me prompt. lsmod lists my module and shows used by one (don't know what). dmesg shows none of the above printk messages.

你能告诉我这是怎么回事吗?

can you tell me what's wrong here?

推荐答案

尝试使用echo "7" > /proc/sys/kernel/printk启用所有控制台日志级别.

Try echo "7" > /proc/sys/kernel/printk to enable all console log levels.

这些数字对应于以下内容:

The numbers are corresponding to below:

#define KERN_EMERG "<0>" /* system is unusable*/
#define KERN_ALERT "<1>" /* action must be taken immediately*/
#define KERN_CRIT "<2>" /* critical conditions*/
#define KERN_ERR "<3>" /* error conditions*/
#define KERN_WARNING "<4>" /* warning conditions*/
#define KERN_NOTICE "<5>" /* normal but significant condition*/
#define KERN_INFO "<6>" /* informational*/
#define KERN_DEBUG "<7>" /* debug-level messages*/

默认数字为4,它允许控制台至少在KERN_WARNING中显示消息. 这就是为什么您看不到KERN_INFO级别登录的原因.

The default number is 4, which allows console to show messages only at least in KERN_WARNING. That's why you cannot see log in KERN_INFO level.

这篇关于dmesg没有显示printk语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆