After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 631061 - GMappedFile should be able to sync data back to file
GMappedFile should be able to sync data back to file
Status: RESOLVED DUPLICATE of bug 458796
Product: glib
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2010-10-01 04:16 UTC by Anatol Pomozov
Modified: 2010-10-01 14:13 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Anatol Pomozov 2010-10-01 04:16:59 UTC
I am trying to use MappedFile from Vala language and found that there is no easy mutiplatform way to flush modified data back to disk. Vala uses glib so this issue applicable to glib also.

I checked g_mapped_file_destroy function and found that is uses munmap, but not msync.

I might be wrong but i think there should be 2 changes:

1) Add a method something like g_mapped_file_sync(GMappedFile *file, gboolean sync = true) that allows to write modified data back to disk.
2) Call the method (1) in g_mapped_file_destroy function.

Let me know what do you think.
Comment 1 Allison Karlitskaya (desrt) 2010-10-01 14:13:01 UTC
GMappedFile is a strictly read-only mapping.  The 'writable' flag may be what is confusing here, but see the docs:

If writable is TRUE, the mapped buffer may be modified, otherwise it is an error to modify the mapped buffer. Modifications to the buffer are not visible to other processes mapping the same file, and are not written back to the file.

All that is happening here is that the file is being opened copy-on-write so that local modifications can be made (similar to how the static data region of a mmaped program can be modified without other instances of the program seeing the modification).

Calling sync() would do absolutely nothing here...

What I think you want is a method to map the file with MAP_SHARED.  See bug 458796 for that.

*** This bug has been marked as a duplicate of bug 458796 ***