Warum druckt printk keine Nachricht im Kernel-Log (dmesg)

Ich habe einen kleinen Kernel-Modulcode geschrieben, wie unten erwähnt. Ich teste ihn inubuntu 14.04

#include <linux/module.h> 
#include <linux/version.h>
#include <linux/kernel.h>
#include <linux/init.h>

int init_mod_func(void)
{
    printk(KERN_INFO "My module inserted\n ");
    return 0;
}

void cleanup_mod_func(void)
{
    printk(KERN_INFO "My module removed\n ");
}

module_init(init_mod_func);
module_exit(cleanup_mod_func);


MODULE_AUTHOR("Ankur");
MODULE_DESCRIPTION("TEST MODULE");
MODULE_LICENSE("GPL");

Jetzt wenn ich das obige Modul mit @ kompiliere und einfüinsmod Ich sehe keine printk Nachricht im dmesg. Jedoch nach dem Entfernen des Moduls mitrmmod Ich sehe beide Druckmeldungen.

Mit Abschluss schau, fand ich heraus, dass es wegen @ passiespace nach\n im printk.
Aber ich verstehe nicht, warum es so ist.

ankur:~/temp/tmp$ 
ankur:~/temp/tmp$ 
ankur:~/temp/tmp$ sudo dmesg -C /dev/null
ankur:~/temp/tmp$ 
ankur:~/temp/tmp$ 
ankur:~/temp/tmp$ sudo insmod testmod.ko 
ankur:~/temp/tmp$ dmesg
ankur:~/temp/tmp$ 
ankur:~/temp/tmp$ sudo rmmod testmod
ankur:~/temp/tmp$ dmesg
[ 4062.140441] My module inserted
[ 4062.140441]  
[ 4073.324994] My module removed
[ 4073.324994]

Antworten auf die Frage(2)

Ihre Antwort auf die Frage