question about file mapping

yang.wei9 at yang.wei9 at
Wed May 13 08:24:35 CEST 2015


I create a file on tmpfs, and it read/write works fine. However, it cannot 
mmap, and returns EINVAL.
I found the reason is that dataspace of the file is not valid. 

        L4::Cap<L4Re::Dataspace> fds = fi->data_space()
       if (!fds.is_valid())
          return -EINVAL;

How to make it valid?  Is there another method to do file mapping?

Here is an example code snippet:

const char* filename = "/tmp/testfile";
ret = mount("/", "tmp", "tmpfs", 0, 0);

fd = open(filename, O_RDWR|O_CREAT);

write 10K data into file

addr = mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); //return 
-1, and errno is EINVAL

ZTE Information Security Notice: The information contained in this mail (and any attachment transmitted herewith) is privileged and confidential and is intended for the exclusive use of the addressee(s).  If you are not an intended recipient, any disclosure, reproduction, distribution or other dissemination or use of the information contained is strictly prohibited.  If you have received this mail in error, please delete it and notify us immediately.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the l4-hackers mailing list