Hi, hackers,
I've try to use mmap() and resize the mapping. msync() syncronizes only the
memory that was mmapped with mmap(). How can I extend the main file? Memory is
filled correctly, but I must write extended data to file by hand.
In my examples 'x.txt' was 11 bytes (some text); Where I'm wrong?
----------
#include <unistd.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main() {
char *ptr;
int fd, size=20;
fd = open("x.txt", O_RDWR | O_CREAT);
ptr = mmap(0, 15, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
ptr[0] = 'D';
ptr[6] = 'D';
ptr = mremap(ptr, 10, 20, 1);
close(fd);
ptr[10] = 'Y';
ptr[12] = 'X';
printf("1%C\n", ptr[12]);
msync(ptr, size, MS_SYNC);
munmap(ptr, size);
}
----------
--
Dimitar Peikov
Programmer
"We Build e-Business"
RILA Solutions
27 Building, Acad.G.Bonchev Str.
1113 Sofia, Bulgaria
home: (+359 2) 595495
phone: (+359 2) 9797320
phone: (+359 2) 9797300
fax: (+359 2) 9733355
http://www.rila.com
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message