Re: Opening files in kernel mode

From: Jesse Pollard (pollard@cats-chateau.net)
Date: Fri Jun 02 2000 - 05:53:42 EST


On Fri, 02 Jun 2000, Francis GALIEGUE wrote:
>On Fri, 2 Jun 2000, S.Venkat Raman wrote:
>
>> Hi,
>> Does anyone know if there is a function to
>> open ( and read )a file when working in kernel
>> mode. Like for example there is a kernel
>> equivalent of printf ( printk ) and malloc (kmalloc).
>> Open is not there in <linux/fcntl.h> i am
>> also looking for kernel version of read too
>> which is also not there in <linux/unistd.h>.
>>
>> if i try and use <fcntl.h> and <unistd.h> there
>> are some conflicts with the other files that
>> i include as a result it doesnt compile.
>>
>> i am need the functions as part of a device driver
>> in which i need to open a file and copy the
>> contents into the device.
>>
>> Please CC a reply to me incase you have some
>> solution to this problem.
>>
>
>Why don't you use a file in /proc for this, or an ioctl?
>

I second that - Most drivers that require such code (see the multi-port
serial drivers for an example) use an external program to supply the
initialization. This has a number of advantages:

  1. the kernel doesn't have a lot of code that is used only once
  2. the external program can be altered easier to handle new load formats
  3. the loader can be debugged easier since it isn't part of the kernel
  4. the driver is simpler
  5. Error handling is MUCH easier (wrong file, damaged file, missing file...)

-- 
-------------------------------------------------------------------------
Jesse I Pollard, II
Email: pollard@cats-chateau.net

Any opinions expressed are solely my own.

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



This archive was generated by hypermail 2b29 : Wed Jun 07 2000 - 21:00:14 EST