Re: Driver module access to filesystem

Tom Dyas (
Wed, 2 Apr 97 23:37:43 EST

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

There is no need. You can "trick" kernel functions that take userspace
pointers by placing the following code before the access in question:

unsigned long old_fs;

old_fs = get_fs();

/* make the call */


Look at how the NFS code calls into the network layer as an
example. There are other places in the kernel where this trick is used
as well.