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

binoy.jayan at wipro.com binoy.jayan at wipro.com
Mon Jan 6 00:26:06 EST 2014


Hi,

If you have your file data in a user space buffer, "get_user_pages" and "kmap" can be used to get it mapped to a kernel virtual address. But I still doubt that this would solve the problem of mapping the disk file data to kernel space.

Regards,
Binoy Jayan

________________________________
From: kernelnewbies-bounces at kernelnewbies.org [kernelnewbies-bounces at kernelnewbies.org] on behalf of Yu Bi [lazysmartegg at gmail.com]
Sent: Tuesday, December 31, 2013 8:05 AM
To: kernelnewbies at kernelnewbies.org
Subject: Re: how to use mmap() on a disk file to get a kernel address?

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 API / VFS API).

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)?
[https://mail.google.com/mail/u/0/images/cleardot.gif]


On Thu, Dec 26, 2013 at 3:42 PM, Yu Bi <lazysmartegg at gmail.com<mailto:lazysmartegg at gmail.com>> 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?







The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. 

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.

www.wipro.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140106/57c95779/attachment.html 


More information about the Kernelnewbies mailing list