Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Virtual file backed by memory (reverse MMAP)?

mmap() is used to create memory region that is backed by file system. However, I want the reverse: a file that is backed by memory. Is that possible? I have a legacy static library (meaning it's not possible to change it) can only open a local file. I can't change it to use a redirected fd, or a stdin (because pipe does not support seek) I want the file content to be streamed from a Windows share (CIFS/SMB). Is it possible to create a virtual file on local file system with fake size and when the legacy static library access any part of the file(seek or read, no write), we handle it by doing a fetch from CIFS/SMB and return to the legacy library (just like handling a page fault)? Then legacy library would not notice any difference...

Mounting the CIFS/SMB share is not possible due to permission issue. Assume the environment is POSIX, however, OS specific advice is welcomed as well.

like image 511
Yi Wang Avatar asked Jul 01 '12 04:07

Yi Wang


1 Answers

Probably you are looking for shm_open. shm_overview(7) man page is good place to start searching.

like image 121
florek Avatar answered Sep 28 '22 00:09

florek