Hi, I am trying to map a file into memory, starting with an offset, and I think I have stumbled into a bug. Maybe I am just misunderstanding how to use memfiles.
Anyway, the following works fine
import memfiles, os
var c = memfiles.open(paramStr(1), mappedSize = 2, offset = 0)
echo c.size
but when I add an offset, it fails
import memfiles, os
var c = memfiles.open(paramStr(1), mappedSize = 2, offset = 1)
echo c.size
Error: unhandled exception: Invalid argument [OSError].
If it helps, I am on Ubuntu 14.04. Any ideas why this should fail?
The contents of a file mapping (as opposed to an anonymous mapping; see MAP_ANONYMOUS below), are initialized using length bytes starting at offset offset in the file (or other object) referred to by the file descriptor fd. offset must be a multiple of the page size as returned by sysconf(_SC_PAGE_SIZE).
This should of course be documented in the memfiles module.
import posix
echo sysconf(SC_PAGE_SIZE)
Prints 4096 on my system.