[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Writing to an exsisting entry in /proc
On Thu, Oct 02, 2003 at 05:59:57 -0400, Mark Hounschell wrote:
> I can see how to create and read/write the proc file system by looking
> at examples in the kernel source tree. However I do not see how to write
> to an exsisting entry from my kernel module. I see plenty of examples of
> create, read, and write, bit no "open". How can I open for write/read an
> exsisting entry without having to create first???
Short answer: You don't. It does not make sense.
Long answer: Proc entries are NOT files. And you are _implementing_
them, not using them.
When userland writes to it, a write method is invoked in kernel that
gets the data from userland. It really get's exactly the arguments
userland provided and is free to do ANYTHING with them. You can think of
the write syscall as a call to this method (which it really is).
When userland reads from it, a read method is invoked the kernel that
provides the data to userland. It again gets exactly the arguments
userland provided and is free to get the response WHEREVER IT WANTS.
Each inode (proc entry has an inode) can have at most one implementation
of read and write (though these can do different things for different
file offsets).
Note: If you want to change something, that is changed by userland via
proc, you do it by directly modifying appropriate variables in kernel.
-------------------------------------------------------------------------------
Jan 'Bulb' Hudec <bulb@ucw.cz>
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/