Hmm.. Ok, perhaps it is so. It just isn't obvious.
> |>> ocp = (char *)mmap( 0, st.st_size,
> |>> PROT_WRITE, MAP_FILE | MAP_PRIVATE, ofd, 0);
>
> |> No, you can't mmap() for writing the file.
>
> Sure you can (if you use MAP_SHARED).
It depends -- if the file page is pre-allocated, you can
write to it via MAP_SHARED, but you can't extend a file
just by overmapping a memory region, and then storeing
into those non-backed pages. That is where you will
always need write().
I recall the `ofd' was opened with O_TRUNC flag, which means
it had zero size...
In many systems attempt to mmap() [PROT_WRITE, MAP_SHARED] on
a file with holes in it (or beyond its end) produces an error.
Here we are treading on extremely varying area of system
implementations.
> --
> Andreas Schwab "And now for something
> schwab@issan.informatik.uni-dortmund.de completely different"
/Matti Aarnio <matti.aarnio@tele.fi>