why not you let Linux do the job? Inside the kernel module, u just have to call "printk()" and all output will go to file called /var/log/ dmesg, as overtime, as u can see below:
-rw-r----- 1 root adm 54121 2010-03-03 07:08 /var/log/dmesg -rw-r----- 1 root adm 54656 2010-03-02 07:25 /var/log/dmesg.0 -rw-r----- 1 root adm 13975 2010-03-01 07:20 /var/log/dmesg.1.gz -rw-r----- 1 root adm 13922 2010-02-28 20:01 /var/log/dmesg.2.gz -rw-r----- 1 root adm 14119 2010-02-28 15:23 /var/log/dmesg.3.gz -rw-r----- 1 root adm 13974 2010-02-28 12:01 /var/log/dmesg.4.gz the userspace daemon klogd will check that the size of the file is too large, and autoarchive it via gzipping. The output of klogd is also viewable via "dmesg" command. If you output to a customized file, u can use logrotate (man logrotate) to archive the file automatically. checkout more about logging: http://www.linuxjournal.com/article/4036 And if u insist on creating a different output file for your application....it is still via klogd...."man klogd" to see more. But your application is still consistently using printk() as the API. On Mar 2, 11:09 am, perumal316 <perumal...@gmail.com> wrote: > Hi, > > I am writing a kernel module which does logging. Currently I am > writing the messages to a textfile. But I don't want this file to > become too big. > > Is there any way I can specify to delete the file if it exceeds a > certain size or write to a new file through kernel module? > > Thanks In Advance, > Perumal