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

Region::clone() should share the zone if it's read-only.

This avoids copying the .text and .rodata segments in fork().
The next step is copy-on-write support for the writable regions.
This commit is contained in:
Andreas Kling 2018-11-03 23:20:49 +01:00
parent da13c9a264
commit 7fe4063323

View file

@ -428,6 +428,10 @@ RetainPtr<Region> Region::clone()
InterruptDisabler disabler;
KernelPagingScope pagingScope;
if (is_readable && !is_writable) {
// Create a new region backed by the same zone.
return adopt(*new Region(linearAddress, size, zone.copyRef(), String(name), is_readable, is_writable));
}
// FIXME: Implement COW regions.
auto clone_zone = MM.createZone(zone->size());
auto clone_region = adopt(*new Region(linearAddress, size, move(clone_zone), String(name), is_readable, is_writable));