c - mmap() for Remote File -
currently implementing version of mmap() objective map remote file on client machine. implementation, cannot utilize in-built or 3rd party libraries. having said that, in uncertainty whether implementation based on either of next 2 options:
load file on client machine after reading file contents client side , utilizemmap() syscall using file descriptor obtained client machine or allocating memory each chunk of file info received client side using sbrk() any suggestions appreciated!
here's idea:
when caller requests "remote mmap" part or entire file, allocate memory entire size right away , homecoming pointer. store record of allocation internally. use sftp or similar open remote file. don't yet, create sure exists , has right size. you install signal handlersigsegv. you utilize mprotect(2) set entire allocated space inaccessible (prot_none). when signal handler called, utilize siginfo_t argument's si_addr parameter know if segmentation fault in part allocated in step 1. if not, pass segmentation fault along, it's going fatal in programs. now know have part of memory has been requested not yet accessible. populate memory reading remote file opened in step 2 , homecoming signal handler. what accomplish "page faults" load on demand required parts of remote file. of course, if know access pattern (e.g. entire file needed in particular order, or needed multiple processes on time) can better, perhaps simpler things.
c linux mmap
No comments:
Post a Comment