Kernel Programming Questions

Greg KH greg at kroah.com
Fri May 23 23:01:09 UTC 2008


On Fri, May 23, 2008 at 04:42:41PM -0600, Vadim Klishko wrote:
> On Friday, May 23, 2008 4:00 PM, "Greg KH" wrote:
> 
> > On Fri, May 23, 2008 at 02:32:46PM -0600, Vadim Klishko wrote:
> >> Hello Everybody,
> >> 
> >> Could anyone please tell me what functions I could call from a Linux kernel module to:
> >> 
> >> 1) dynamically load a library,
> > 
> > None.
> > 
> >> 2) get the address of an exported function,
> > 
> > None.
> > 
> >> 3) unload the library?
> > 
> > None.
> > 
> > None of these things are things that you should do from within a kernel
> > module.
> > 
> >> Also, what are the functions that would allow me to read from and
> >> write to a binary or text file from within a kernel module?
> > 
> > None, this is not what a kernel module should ever be doing.
> > 
> > Let's turn it around the other way, what are you trying to achieve that
> > makes you think the above things are necessary to do?
> > 
> By reading a file, I am trying to load a system-wide device
> configuration. Of course, it could be hard-coded into the module, but
> why not try having it adjustable?

It's fine to be configurable, that's wonderful and something we do all
the time.

But it is userspace sending the data into the kernel driver, not the
other way around.  With the plethera of different filesystems, mount
points, boot sequences, namespaces and the like, the kernel can not
specific a single location of a config file and have it work with all
systems.

So have a startup script that parses the config file in userspace and
then writes the needed info into the driver using sysfs, or better yet,
configfs (which is sounds like what you need to use here.)

> > The kernelnewbies mailing list and wiki covers the above topic in great
> > detail if you wish to understand why you should not be doing any of the
> > above from within the kernel.
> > 
> Thank you for pointing me to kernelnewbies. I realize it's premature
> to argue before I have read their arguments against doing these things
> in the kernel, but the first objection that crosses my mind is this: I
> can do it in Windows. Why not in Linux?

Just because some other inflexible operating system allows you to do
this, don't assume that Linux with all of it's varied uses will follow
the same type of rules :)

Hope this helps,

greg k-h



More information about the devel mailing list