Yi Wang
Yi Wang

Reputation: 552

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.

Upvotes: 6

Views: 1223

Answers (1)

florek
florek

Reputation: 31

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

Upvotes: 2

Related Questions