[Top] [All Lists]

Re: file handling in kernel mode

To: Ralf Baechle <>
Subject: Re: file handling in kernel mode
From: Brad Parker <>
Date: Sun, 16 Nov 2003 19:46:35 -0500
Cc: durai <>,
In-reply-to: Message from Ralf Baechle <> of "Sun, 16 Nov 2003 23:51:33 +0100." <>
Original-recipient: rfc822;
>On Sun, Nov 16, 2003 at 02:30:05PM +0530, durai wrote:
>> Hello,
>> I need to read a file from a device driver and i wrote a sample driver
>> like this
>> This kernel mode code which try to read the file until end of file is
>> reached. This code had been is working without any problems in RedHat
>> linux and uClinux.
>> But the same code causes a General Protection Fault in my mips linux.
>> I tested the same code in mips running on uClinux which runs well.
>> what is wrong with mips linux?

Shouldn't someone point out that having a driver read a file is 
very, very wrong and a classic FAQ question?

Perhaps I'm mistaken but this seems to come up once a year on every port
list I'm on.

The "unix way" is to have something in userland feed the data to the
driver.  Things in the kernel should never reach back up into the file
system. It's just not done.

Drivers are passive objects which do the bidding of "managers" which
live in userland.  Add an ioctl to the driver which allows a userland
daemon to feed the microcode/firmware/fpga-data/whatever to the driver
in pieces.

Resist the temptation to put code in the driver to access the file

ps: isn't hotplug already setup to notice when a device comes up and to
have a shell script run?  it's bad enough that the hotplug code runs a
shell script from the kernel.  I can't believe that got through...

(and if you have time, go read the plan 9 design docs.  then ask yourself
what those guys would do :-)


<Prev in Thread] Current Thread [Next in Thread>