Re: How to write a module which reads data from a file ?

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

 



On 5/3/06, Richard <field1227@xxxxxxxxx> wrote:
Hi,
 I want to write a module, and the module can read a lot of data from a
generic file. I don't want to read through /proc file, because the generic
file is a configure file for the module.
 So , how to write a module which reads data from a file ?

Don't do that.

kernel code borrows the context of whatever userspace application they
run on behalf of, it has no explicit process context of its own, so
manipulating files will always happen on behalf of a userspace process
(and likely a different one each time your code is invoked) - it's
going to be a mess and has all the potential in the world of blowing
up.
Just don't do it.
Use netlink sockets, procfs, sysfs etc, don't manipulate plain files
directly from kernel code.

Please search both the LKML & kernelnewbies archives, this has been
discussed to death already.

--
Jesper Juhl <jesper.juhl@xxxxxxxxx>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html

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