how to use mmap() on a disk file to get a kernel address?

Yu Bi lazysmartegg at
Mon Dec 30 21:35:49 EST 2013

Thanks  for your idea.
Because I implement a  kernel  storage service  based on a disk file
through  VFS layer.
To  simplify the implementation,  I prefer  to   read/write  the mapped
kernel space address instead of the file data access api(such as page cache

In FreeBSD, I can use  vm_map_find to map a file into  kernel space
address( vnode pager)
But in linux,  I don't know how to implement this(map disk file into
kernel space)?

On Thu, Dec 26, 2013 at 3:42 PM, Yu Bi <lazysmartegg at> wrote:

> Hi,
>    I try to mmap a file in a linux kernel module. I have tried to use the
> function do_mmap_pgoff. But the address returned is memory virtual
> address in current process' user space, i.e., below the kernel boundary.
> Instead, I want to map the file in the kernel space and get the kernel
> virtual address of the mapped region. Is there any kernel API in Linux
> support this operation? Or I have to reimplement a kernel mmap version ?
>   But reimplement a kernel version mmap() is  not easy I guess. Do you
> have any idea?
-------------- next part --------------
An HTML attachment was scrubbed...

More information about the Kernelnewbies mailing list