Re: dumb question: How to create your own log files in a kernelmodule?

From: Richard B. Johnson
Date: Thu Apr 28 2005 - 15:14:06 EST

On Thu, 28 Apr 2005, Xin Zhao wrote:

Can anyone give me a hand? or point me to somewhere I can find related

Thanks in advance!


printk(KERN_XXX"whatever") was designed for this.

#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 */
printk(KERN_DEBUG fmt,##arg)
printk(KERN_INFO fmt,##arg)

You could define your own, KERN_PRIVATE "<8>" and have the syslog
facility filter on that.

Other ways are to write stuff to a buffer or linked-list and
read it out using an ioctl() or read() in your module. If you
do this, make sure that your module code doesn't wait forever
if the buffer gets full.

Dick Johnson
Penguin : Linux version 2.6.11 on an i686 machine (5537.79 BogoMips).
Notice : All mail here is now cached for review by Dictator Bush.
98.36% of all statistics are fiction.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at