syntax: printk(urgency fmt, arg(...));
urgency is KERN_something... you can look at these in include/linux/kernel.h.

example:
printk(KERN_EMERG "Aiee, killing interrupt handler\n");

printk() is the kernel-space version of printf, whose output goes to the console. There is also console_print(), which is more like puts and thus more efficient in some cases (hint hint, resc's example should have used console_print!!). The "urgency" is actually another string, and the compiler will concatinate it and your format string into one.

Similarly, there is also a kernel-space sprintf implementation.

Oh, and printk() can be really easy to overflow: on my kernel, at least, the buffer used is only 1024 bytes, and 3 of those are used for the urgency. And it won't do a bounds check. Short messages only.

Log in or register to write something here or to contact authors.