I have a memory-mapped file and I'm writing changes to the memory region returned, but they don't appear to take.
The stderr shows the values:Code:int des = open("processed.dat", O_RDWR | O_CREAT | O_NOATIME, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); assert(des != -1); void *buf = mmap(NULL, SIZEOFTHESUCKA, PROT_READ | PROT_WRITE, MAP_PRIVATE, des, 0); assert(buf != MAP_FAILED); ... //some code that writes to buf const unsigned char *p = (const unsigned char *)buf; for (int i = 0; i < SIZEOFTHESUCKA; i++) fprintf(stderr, "%02X ", (int)p[i]); fprintf(stderr, "\n"); assert(munmap(buf, SIZEOFTHESUCKA) == 0); close(des);
But when I call:Code:6D 00 00 04 00 16 33 12
I only get:Code:hexdump processed.dat
I should also point out that before the file is opened it is already SIZEOFTHESUCKA bytes long, and is zeroed.Code:0000000 0000 0000 0000 0000 0000008
NDEBUG is not defined, so munmap() does get called.



LinkBack URL
About LinkBacks



