Writing a plain text file to disk from kernel space

Dag-Erling Smørgrav des at des.no
Tue May 15 10:32:53 UTC 2007


Lawrence Stewart <lstewart at room52.net> writes:
> I'm in the process of writing a kernel module to instrument some parts
> of the network stack in FreeBSD 6.2. Everything works perfectly,
> except that writing the logging info to syslog using printf is too
> inefficient for this particular task. Given that log messages need to
> be generated for each packet entering/leaving the network stack, my
> testing thus far has showed that syslog groans under the load and uses
> far too much CPU time.
>
> So, I'm looking for a way to manually open up a file from within
> kernel space and dump characters into it.

Look at the ktrace code.

Note that it opens the file in userland and passes it down to the
kernel.  You may want to consider a similar mechanism.

DES
-- 
Dag-Erling Smørgrav - des at des.no


More information about the freebsd-hackers mailing list