A place for thoughts, ideas, tutorials and bookmarks. My brain can only hold so much, you know.
© 2024. All rights reserved.
This snippet will show you how to open a file and map it into memory.
int fd, pagesize; char *data; /* open the file */ fd = open("somefile", O_RDONLY); /* get the current page size */ pagesize = getpagesize(); /* map the 2nd page into memory */ data = mmap((caddr_t)0, pagesize, PROT_READ, MAP_SHARED, fd, pagesize); /* start using the data pointer */
The mmap system call