Kum*_*rav 11 linux-kernel procfs
我正在尝试创建一个proc条目.我的init_module函数如下
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;
}
Run Code Online (Sandbox Code Playgroud)
以下是清理方法
void cleanup_module()
{
printk(KERN_INFO "proc2:module unloaded");
remove_proc_entry(proc_name,proc_entry);
}
Run Code Online (Sandbox Code Playgroud)
程序的其余部分包括变量定义和回调函数.
当我编译这个程序时,它编译得很好.当我使用insmod它时不回复我提示.
lsmod列出我的模块和一个人使用的节目(不知道是什么).
dmesg没有显示上述printk消息.
你能告诉我这里有什么问题吗?
Way*_*yne 18
尝试echo "7" > /proc/sys/kernel/printk启用所有控制台日志级别.
数字对应如下:
#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*/
Run Code Online (Sandbox Code Playgroud)
默认编号为4,这允许控制台至少仅显示消息KERN_WARNING.这就是为什么你看不到登录KERN_INFO级别的原因.
| 归档时间: |
|
| 查看次数: |
21266 次 |
| 最近记录: |