0

I tried using mmap like this:

off_t offset = 0x123456789;
long pagesize = sysconf(_SC_PAGE_SIZE);
int pageoffset = offset % pagesize;


//Open file, get file descriptor
fd = open("./test", O_RDONLY);
map_main = mmap(NULL, 106 + pageoffset, PROT_READ | PROT_EXEC,
                    MAP_SHARED, fd, offset - pageoffset);

Not behaving as expected.

Am I doing right, for reading file from specific location? Reference: Segfault while using mmap in C for reading binary files

4

0 回答 0