Results 1 to 6 of 6
Enjoy an ad free experience by logging in. Not a member yet? Register.
Writing to a file from a kernel module???
Can a kernel module write to a file? If so how can you do this...
I don't think that's possible. AFAIK the kernel doesn't use the C library, so there are no I/O functions available except for the built-in printk to print kernel messages for klogd.
AFAIK...not sure what this means...Gerard4143
Printk also prints to a file /var/log/messages. So the kernel does write to a file in some capacity....Gerard4143
Sorry for jargon, Gerard. AFAIK means "as far as I know".
Actually the kernel does not write to /var/log/messages. That is done by a separate program called klogd which runs in the background of your system (you will sometimes find programs of this sort referred to as daemons).
klogd and its twin brother syslogd are responsible for routing all system messages: klogd handles messages from the kernel and syslogd messages from other programs. The file /etc/syslog.conf specifies where these messages will go; on most Linux systems they go to /var/log/messages but some may be copied elsewhere. Read the man page on syslog.conf for further details.
At least, kernel modules, i.e. drivers, write to the /proc file system. klogd is a kernel module, too, or isn't it?
There is also a file /etc/mtab or the like where many kernels writes on at start-up what makes it difficult to run those kernels from read-only file systems.
There are maybe more examples but those have come to my mind.Bus Error: Passengers dumped. Hech gap yo'q.