Driver module access to filesystem

Rick Richardson (
Wed, 2 Apr 1997 22:01:10 -0600 (CST)

Continuing along our road out of device driver installation hell
(see last message with do_mknod() in the subject), I'm trying
to work out module access to the filesystem.

We'd like to be able to read firmware files to be downloaded
to boards from the init_module() call of a device driver.
Then there is no need for gratuitous daemons to download
firmware through the device driver nor for linking large firmware
loads into the device driver. One could simply do:

insmod lala.o firmware=/lib/firmware.v1.2.39

I'm a little weak on my Linux memory allocation and I need some
help. Our driver needs to be able to temporarily allocate a page or
so in the user space of the invoking insmod process for a buffer so
that I can use the following line to read data from the file:

error = file.f_op->read(inode, &file, user_buffer, count);

I need a user space buffer because the f_op->read functions
enforce the requirement that user_buffer be in user space.

Once my init_module() has read the firmware and put it down
on the hardware I would then free this buffer.

Any hints on what kernel functions (preferably ones that are already
exported) that I can call to allocate/free this buffer?

Also, does anybody see a philosophical reason why we shouldn't
be doing this? I'm not able to see a reason why this shouldn't
be the usual practice, perhaps even encouraged by providing
documented functions for drivers writers to call to accomplish
this rather than having to hack it together -- kernel_open_file(),
kernel_read_file(), and kernel_close_file() or something like that.


Rick Richardson        Sr. Principal Engr.    Can you be sure I'm really me
Digi Intl.             Email:   and not my clone???  Has anybody
11001 Bren Rd. East    Fax:   (612) 912-4955  seen The Leader's nose???
Minnetonka, MN 55343   Tel:   (612) 912-3212