Return to BSD News archive
Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.mel.connect.com.au!munnari.OZ.AU!news.hawaii.edu!ames!olivea!wetware!nntp-hub.barrnet.net!inet-nntp-gw-1.us.oracle.com!news.caldera.com!park.uvsc.edu!usenet From: Terry Lambert <terry@lambert.org> Newsgroups: comp.unix.bsd.freebsd.misc Subject: Re: Can I write to a file from kernel Date: 12 Dec 1995 07:08:11 GMT Organization: Utah Valley State College, Orem, Utah Lines: 40 Message-ID: <4aj9or$hh9@park.uvsc.edu> References: <4affu1$go0@newsserv.cs.sunysb.edu> <4agspp$bqc@uriah.heep.sax.de> NNTP-Posting-Host: hecate.artisoft.com j@uriah.heep.sax.de (J Wunsch) wrote: ] ] vernick@cs.sunysb.edu (Michael Vernick) writes: ] > Is it possible to write to a file from the kernel? I am capturing ] > some benchmark information at the driver level and want to save it ] > to a file. ] ] Not directly, and it's not very desirable. For you, printf() or log() ] might be useful. Then, configure syslogd to save the items in the ] file of your choice. Indirectly. And I think it's *very* desirable. 8-). You must have a process context. So you have to have something in user space that opens the device and ioctl's it, never to return. Or hack a system call to do the same thing. This is actually *exactly* what the NFS server code does. Then use vn_open/vn_close/ etc. Or call VOP_... directly. The main problem you will face is that the operation can tsleep(), which is a bad thing to do in a driver at interrupt time. A semaphored handoff of the write to the process context will fix that for you. Then the process does the write on your behalf. You will need a buffer at least 10-20ms worth of data deep if you are waking the process to do the writes. Terry Lambert terry@cs.weber.edu --- Any opinions in this posting are my own and not those of my present or previous employers.