mmap bug?

Giorgos Keramidas keramida at freebsd.org
Sun Jul 31 22:46:08 GMT 2005


On 2005-07-31 18:39, Garrett Wollman <wollman at csail.mit.edu> wrote:
><<On Sun, 31 Jul 2005 23:18:58 +0300, Giorgos Keramidas <keramida at FreeBSD.ORG> said:
>> The bug seems to be elsewhere, namely to the fact that the filesystem
>> code never realizes the file has changed size after I use mmap() to map
>> a region beyond its current size and write past its current end.
>
> You should not expect it to do that.  If you want to extend a file,
> use ftruncate() before mapping it.  Anything written past the end of a
> file should be discarded on last close.

I see.  Thank you for the explanation :)

It seems strange though that when the test program runs and finishes,
munmapping the region and closing the file the data is still visible.
Perhaps the fact that I used MAP_SHARED plays a role in that?

Is the fact that the data written to the mapped region visible after the
close (by mapping the same region) expected too?

- Giorgos



More information about the freebsd-current mailing list