Sujet : Re: Memory mapping: MAP_PRIVATE and msync()
De : pehache.7 (at) *nospam* gmail.com (pehache)
Groupes : comp.lang.c comp.unix.programmerSuivi-à : comp.unix.programmerDate : 07. Apr 2024, 20:09:17
Autres entêtes
Organisation : Nemoweb
Message-ID : <3SRfxOJmmxW4o_baSf1Air4dZWk@jntp>
References : 1 2
User-Agent : Nemo/0.999a
Le 07/04/2024 à 15:49, Lew Pitcher a écrit :
On Sun, 07 Apr 2024 13:34:43 +0000, pehache wrote:
Hello,
Hi, pehache
When memory mapping a file with the MAP_PRIVATE flag, the modifications (writes) only exist in memory and are not written back to the file.
[snip]
So: is there a way to write the changes back to the file?
[snip]
The comp.unix.programmer newsgroup will be of better help for this sort
of question (it's not really on-topic for comp.lang.c).
But, of the top of my head; with my limited understanding of the unix
mmap() kernel call, the only ways to "write the changes" are to either
1) mmap(MAP_SHARED) and modify the mapped area, or
2) write() the mapped area back to the file.
I'm currenly using the first option in my code. Either way, the whole mapped area is written back, even if there were only a few changes. I was hoping there could be another way to wrtite back only the modified pages.
But, as I said, comp.unix.programmer will be of better help.
fu2