Deutsch   English   Français   Italiano  
<osGzrqwQ8DBTJ8mCFoPEiv6Pn0M@jntp>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!news.mixmin.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!pasdenom.info!from-devjntp
Message-ID: <osGzrqwQ8DBTJ8mCFoPEiv6Pn0M@jntp>
JNTP-Route: news2.nemoweb.net
JNTP-DataType: Article
Subject: Memory mapping: =?UTF-8?Q?MAP=5FPRIVATE=20and=20msync=28=29?=
Newsgroups: comp.lang.c
JNTP-HashClient: mDaFF4rrTDVBcTjIEyulwvhjTkw
JNTP-ThreadID: Xt4PvXwVS7RUVBYIv4ru98146Os
JNTP-Uri: http://news2.nemoweb.net/?DataID=osGzrqwQ8DBTJ8mCFoPEiv6Pn0M@jntp
User-Agent: Nemo/0.999a
JNTP-OriginServer: news2.nemoweb.net
Date: Sun, 07 Apr 24 13:34:43 +0000
Organization: Nemoweb
JNTP-Browser: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:109.0) Gecko/20100101 Firefox/115.0
Injection-Info: news2.nemoweb.net; posting-host="516ee13c1e79fa65aedf115a32aee346f9289ca9"; logging-data="2024-04-07T13:34:43Z/8808721"; posting-account="44@news2.nemoweb.net"; mail-complaints-to="julien.arlandis@gmail.com"
JNTP-ProtocolVersion: 0.21.1
JNTP-Server: PhpNemoServer/0.94.5
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-JNTP-JsonNewsGateway: 0.96
From: pehache <pehache.7@gmail.com>
Bytes: 2138
Lines: 22

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.