dmesg is not showing printk statement

后端 未结 2 1135
独厮守ぢ
独厮守ぢ 2020-12-10 03:48

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_cre         


        
相关标签:
2条回答
  • 2020-12-10 04:07

    Even after using echo "7" > /proc/sys/kernel/printk, printk didn't worked for me.

    https://lwn.net/Articles/487437/ says about modified or more enhanced version of printk called pr_** api's (pr_info,pr_emerg).

    I used pr_info instead of printk and it solved my problem.

    0 讨论(0)
  • 2020-12-10 04:11

    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*/
    

    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.

    0 讨论(0)
提交回复
热议问题