accessing files from within a kernel module

accessing files from within a kernel module

Post by aldo.gaviol » Sat, 04 Nov 2000 01:53:49



    How do I read/write normal files from within a kernel module? Where
shall I look in the source code for the implementation of read() system
call??? I couldn't figure out where it is.
    Please help.
 
 
 

accessing files from within a kernel module

Post by Peter T. Breue » Sat, 04 Nov 2000 02:42:44


:     How do I read/write normal files from within a kernel module? Where

You don't. (there is code in 2.4.* kernels to make this possible,
however).

: shall I look in the source code for the implementation of read() system
: call??? I couldn't figure out where it is.

It's nowhere and everywhere. Each block device will provide it's own
implementation of read. They'll be read/write of BLOCKs, however.
It'll be your file system that translates r/w calls on FILEs to r/w
calls on blocks.

Peter

 
 
 

accessing files from within a kernel module

Post by Mike Cast » Sat, 04 Nov 2000 03:30:24




>    How do I read/write normal files from within a kernel module? Where
>shall I look in the source code for the implementation of read() system
>call??? I couldn't figure out where it is.
>    Please help.

Generally, don't do that.  It is a lot of hassle, and prone to problems.

Instead, have a user mode helper application send it to you.

This has been discussed on linux-kernel several times.  

Here is one particular response:
http://www.uwsg.indiana.edu/hypermail/linux/kernel/0005.3/0061.html

More can be found at:
http://www.uwsg.indiana.edu/hypermail/linux/kernel/index.html

Do a search on "open file kernel mode"

mrc
--
       Mike Castle       Life is like a clock:  You can work constantly

www.netcom.com/~dalgoda/ and be right at least twice a day.  -- mrc
    We are all of us living in the shadow of Manhattan.  -- Watchmen

 
 
 

1. Accessing files from within a kernel module

    I need to read a file from within a kernel module (a pseudo block device
driver).
The file is a simple ASCII in /opt, I couldn't figure out a metode to open
and read from it.
I'm trying to open with filp_open() and then read using the read pointed by
the file->dentry->inode->file operation structure i get, but the open()
fails with error code -14
May it is because I allocate the buffer in kernel space, while I should pass
a userspace pointer?
 I'd really appreciate any hints, thanks.

2. for (i=1, i<y, i++){do something} in sh

3. Can not open a file within a kernel module

4. Solaris-2.4 and LaserWriter help..

5. File access within a kernel mod

6. Answer to Bootpd Question

7. How can I tell if a kernel module is loaded from within kernel code?

8. Bad network performance on firewall host.

9. Environment Variables- access from within module

10. Accessing files / network from inside kernel module

11. Kernel Driver Module accessing a text file: How to?

12. Normal file access in a kernel module

13. Kernel Driver Module accessing a text file: How to?