Le Sun, 9 Dec 2007 19:08:12 +0530, "Amogh Hooshdar" <amoghhooshdar@xxxxxxxxx> a écrit : > printk(KERN_INFO "hello, world\n" KERN_INFO "hello, again\n"); > > Initially, I was expecting it to print "hello world" in one line and > "<6>hello, again" in the next line. But this is printing "hello, > world" and "hello, again" in two different lines. So, is it that the > printk() puts the whole message in some kernel buffer. and the kernel > searches for PRIORITY-message-newline-PRIORITY-message-newline... and > so on and prints into dmesg? You can read the code that does this at: http://lxr.free-electrons.com/source/kernel/printk.c#549 Basically, there is a log_level_unknown, which is TRUE at the beginning. Then, we have a loop that loops over each character of the string. If it finds "<" followed by a number between 0 and 7 and followed by ">", then log_level_unknown becomes FALSE and loglevel_char contains the loglevel. And later, at http://lxr.free-electrons.com/source/kernel/printk.c#598, if we reach a newline, log_level_unknown is set to TRUE again, which means that it will look for a new log level. It explains the behaviour you are seing in your test. Sincerly, Thomas -- Thomas Petazzoni, thomas.petazzoni@xxxxxxxx, http://thomas.enix.org Jabber, thomas.petazzoni@xxxxxxxxx Toulibre, http://www.toulibre.org - APRIL, http://www.april.org Fingerprint : 0BE1 4CF3 CEA4 AC9D CC6E 1624 F653 CB30 98D3 F7A7
Attachment:
signature.asc
Description: PGP signature