Re: file handling in kernel mode

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

 



>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
system.

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 :-)

-brad



[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux