On Sun, Dec 09, 2007 at 07:08:12PM +0530, Amogh Hooshdar wrote: > I am a newbie in the world of Linux kernel. I have lots of questions > and some may be really silly. So, I will be asking a lot of questions > in the coming few months. I hope asking such questions is considered > OK here. If not, please guide me. Here is the question I have now. I > was playing with the printk() statements and how they work. I found a > strange thing. > > 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? It's dmesg() (and klogd) that interpret the priority levels for you. Here's a dmesg that dumps the raw kernel printk() buffer without any interpretation: #include <unistd.h> #include <sys/syscall.h> #include <errno.h> #include <stdio.h> static int my_syslog(int type, char *bufp, int len) { return syscall(__NR_syslog, type, bufp, len); } int main(void) { char buf[65536]; my_syslog(3, buf, 65535); printf("buf: %s\n", buf); return 0; } That should show you what's going on. Erik -- They're all fools. Don't worry. Darwin may be slow, but he'll eventually get them. -- Matthew Lammers in alt.sysadmin.recovery
Attachment:
signature.asc
Description: Digital signature