On Tue, Jan 11, 2005 at 09:32:02 +0100, Arjan van de Ven wrote: > On Mon, 2005-01-10 at 05:33 -0800, linux lover wrote: > > Hello, > > I want to read file in kernel module. can anybody > > help me by giving code for that? > > Also whats suitable way to do that in kernel /proc or > > shared memory? what i want is to read and write a user > > file frequently. > > that is not allowed in kernel modules in general. ... but a proc file is not a normal file, it's a communication channel between userspace and kernelspace. It's not a file, it's either a buffer in kernel memory, or, more generaly a set of function implementing whatever should happen when userspace calls read and write. Basicaly it's not allowed for kernel to store and load information. The information should be passed to a user-space helper instead. You can use a char device, proc file (you are implementing the kernel-side here, which does not look like file at all, though) or a netlink socket. Netlink is best for packet (ie. command) oriented communication, device is best for stream oriented communication and proc files are best for providing random access to a buffer (devices and proc are both files, so you can do both with both, but each has additional interface to make the particular kind of access easier). ------------------------------------------------------------------------------- Jan 'Bulb' Hudec <bulb@xxxxxx>
Attachment:
signature.asc
Description: Digital signature