programmer questions - MMAP
Wojciech Puchar
wojtek at tensor.3miasto.net
Thu Apr 6 06:56:56 UTC 2006
>>
>> #include <sys/mman.h>
>> #include <fcntl.h>
>> #include <stdio.h>
>> #include <unistd.h>
>> main() {
>> int ff=open("test",O_RDWR|O_CREAT,0666);
>> char *adr;
>> lseek(ff,1<<24,0);
>> write(ff,"",1);
>> adr=mmap(0,1<<24,PROT_READ|PROT_WRITE,MAP_NOCORE,ff,0);
>
> Try MAP_NOCORE|MAP_SHARED here. It's probably defaulting to a private
> mapping.
WORKS!!! thank you.
another question - do i need to create 16MB hole to be able to write
directly up to 16MB data. it would be nice if mmap is able to extend the
file as needed without lseek/write. is it possible?
More information about the freebsd-questions
mailing list