Memory mapping: MAP_PRIVATE and msync()

Liste des GroupesRevenir à l c 
Sujet : Memory mapping: MAP_PRIVATE and msync()
De : pehache.7 (at) *nospam* gmail.com (pehache)
Groupes : comp.lang.c
Date : 07. Apr 2024, 15:34:43
Autres entêtes
Organisation : Nemoweb
Message-ID : <osGzrqwQ8DBTJ8mCFoPEiv6Pn0M@jntp>
User-Agent : Nemo/0.999a
Hello,
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.
According to the man pages, calling msync (3) on a such a mapping does NOT writes the changes back:
"When the msync() function is called on MAP_PRIVATE mappings, any modified data shall not be written to the underlying object and shall not cause such data to be made visible to other processes"
https://linux.die.net/man/3/msync
So: is there a way to write the changes back to the file? An obvious application is:
- mapping the file with MAP_PRIVATE
- make some modifications in memory only (fast) while keeping the original version on disk (safe)
- at some point (when the user decides, and once the consistency of the changes have been verified) writing the modifications to the disk
I'm pretty sure it exists some way or another, but I don't know how.

Date Sujet#  Auteur
7 Apr 24 * Memory mapping: MAP_PRIVATE and msync()11pehache
7 Apr 24 +* Re: Memory mapping: MAP_PRIVATE and msync()6pehache
7 Apr 24 i+- Re: Memory mapping: MAP_PRIVATE and msync()1pehache
8 Apr 24 i`* Re: Memory mapping: MAP_PRIVATE and msync()4Lawrence D'Oliveiro
8 Apr 24 i +- Re: Memory mapping: MAP_PRIVATE and msync()1Kaz Kylheku
8 Apr 24 i `* Re: Memory mapping: MAP_PRIVATE and msync()2bart
9 Apr 24 i  `- Re: Memory mapping: MAP_PRIVATE and msync()1Lawrence D'Oliveiro
7 Apr 24 `* Re: Memory mapping: MAP_PRIVATE and msync()4Lew Pitcher
7 Apr 24  `* Re: Memory mapping: MAP_PRIVATE and msync()3pehache
8 Apr 24   `* Re: Memory mapping: MAP_PRIVATE and msync()2pehache
8 Apr 24    `- fu2 is fne (Was: Memory mapping: =?UTF-8?Q?MAP=5FPRIVATE=20and=20msync=28=29?=)1Kenny McCormack

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal