Re: How to read file in kernel module?

From: Valdis . Kletnieks
Date: Mon Feb 07 2005 - 11:55:25 EST


On Mon, 07 Feb 2005 07:38:36 +0100, Arjan van de Ven said:
> On Sun, 2005-02-06 at 22:17 -0800, linux lover wrote:

> > Now what i want is to use same bufproc_read &
> > bufproc_write functions defined in /proc file
> > handling kernel module to be used in another kernel
> > module to read that /proc/file in kernel module.The
> > second kernel module only used to read /proc file in
> > kernel. I am not understanding how can i open that
> > /proc/file in second kenrel module to read in kernel?
> > regards,
>
> the answer really is that you should not read files from kernel
> modules; /proc or otherwise.

As Arjan said - what you probably want to be doing instead is changing
the code in your first module that provides the bufproc_* functions so
that they're wrappers around some code that does the "real work", and
then call the real_work function from your second module. Most likely,
what you *really* want to be passing around is some 'struct *foo', and
the bufproc_* functions are converting to/from a struct foo and a linear
byte stream. (In the limiting case where it's just one variable, why not
just 'EXPORT_SYMBOL(variable)' in the first module and then just assign or
read the variable from the second module?)

Attachment: pgp00000.pgp
Description: PGP signature