
problem appending data to Memory mapped File in Unix
Hi
I have memory mapped a file using
mmap() and if i write something in the file i can see the changes
but if itry to write at the end of the file i can't see the changes.
The program goes this way.
int fd = open(filename, O_RDWR);
struct stat sbuf;
stat(filename, &sbuf);
char * data = mmap((caddr_t)0, sbuf.st_size, PROT_READ|PROT_WRITE,
MAP_SHARED,
fd, 0);
Everything goes fine like i can write within sbuf.st_size, but
if i do something like this
for(int i = sbuf.st_size; i < sbuf.st_size + 100 ; i++) data[i] = 'p';
msync((void *)data, sbuf.st_size + 100 );
I can't see any changes in the file, i mean on the disk.
Any help will be appreciated.
rgds
minnam