Re: Accessing File System from Module

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Sep 19, 2002 at 12:27:33AM -0700, Greg KH wrote:
> On Thu, Sep 19, 2002 at 10:25:48AM +0200, yaelgilad wrote:
> > Hi,
> > I am building a kernel module which will probably need 
> > to access files, real or virtual. The module will be inserted
> > to an "out-of-the-box" kernel. I have full control of which-boxes :-)
> > 
> > Are there any obvious issues I should be aware of ?
> 
> Yes, you should not ever access files from within the kernel.  Do not do
> this, change your design, it is broken.

Well, you should avoid reading files from a disk. Make a utility to feed
pre-parsed data to you. It reduces complexity of code in kernel and
makes things more flexible.

> > I need to create a kernel thread, which will loop
> > on a blocking read from some something in /dev.
> 
> Heh, if you're wanting to block on data from a device, do that in
> userspace, not within the kernel.

However, if it can be done in user-space, do it there. Remember, that
doing things in kernel gives very limited speed advantage while it makes
things complicated.

If it for any reason can't be done in user-land, you probably could get
the data without opening the device file. If end up with the need to
open it, don't go through the filesystem. It's a waste of everything.
You can get apropriate structure for the device the way generic device
open does and mimic what it does (block devices can be accessed the way
fs drivers do).

-------------------------------------------------------------------------------
						 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/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux