Messages in this thread | | | Date | Thu, 18 Nov 1999 18:22:51 -0500 (EST) | From | "Richard B. Johnson" <> | Subject | Re: accessing regular files from kernel module |
| |
On Thu, 18 Nov 1999, Philip Hall wrote:
> I have looked in the Linux devicedrivers book, done searches > in news groups using dejanews, and read the Kernel hackers guide > among others, and can not find a definite answer to this question. > Others have asked the same question, but I have never seen the answers. > I need to read and write regular files from with in a kernel module. > Is this possible? > I suspect it isn't, but just want conformation. > > thanks. > > phil >
The answer, as you suspect, is yes and no. For a file descriptor to mean anything, you need a "process context". Therefore, if you need to handle files within the kernel, you need a "kernel thread".
Therefore, you can't just open()/read()/write()/close() files within the kernel. Further, when file I/O is occurring, the process needs to be able to sleep. This means that your driver module has to be very careful about locks.
Presently, a kernel thread may not be able to be created from a module. This further complicates things. This means that, to handle files, the kernel thread has to be part of the kernel.
Since more and more persons seem to need file-handling capability within modules, maybe it's time to create a generic file-handling kernel thread with which all modules communicate when they need file capability. This kernel thread would act as a file-server, performing file I/O on behalf of the client, the module.
Cheers, Dick Johnson
Penguin : Linux version 2.3.13 on an i686 machine (400.59 BogoMips). Warning : It's hard to remain at the trailing edge of technology.
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |