1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:38:11 +00:00

Kernel: Automatically sync shared file mappings when unmapped

To make sure we don't lose changes, shared file mappings will now be
fully synced when they are unmapped, whether explicitly or implicitly
(by the program exiting/crashing/etc.)

This can incur a lot of work, since we don't keep track of dirty pages,
but that's something we can optimize down the road. :^)
This commit is contained in:
Andreas Kling 2021-11-17 19:35:53 +01:00
parent af6358e1e1
commit 1f894cee59

View file

@ -38,6 +38,11 @@ Region::Region(VirtualRange const& range, NonnullRefPtr<VMObject> vmobject, size
Region::~Region()
{
if (is_writable() && vmobject().is_shared_inode()) {
// FIXME: This is very aggressive. Find a way to do less work!
(void)static_cast<SharedInodeVMObject&>(vmobject()).sync();
}
m_vmobject->remove_region(*this);
MM.unregister_region(*this);