Kernel: Pass "shared" flag to Region constructor

Before this change, we would sometimes map a region into the address
space with !is_shared(), and then moments later call set_shared(true).

I found this very confusing while debugging, so this patch makes us pass
the initial shared flag to the Region constructor, ensuring that it's in
the correct state by the time we first map the region.
This commit is contained in:
Andreas Kling 2021-01-02 16:38:05 +01:00
parent 1898aa8cd4
commit 5dae85afe7
Notes: sideshowbarker 2024-07-19 00:12:09 +09:00
10 changed files with 21 additions and 20 deletions

View file

@ -79,7 +79,7 @@ KResultOr<Region*> InodeFile::mmap(Process& process, FileDescription& descriptio
vmobject = PrivateInodeVMObject::create_with_inode(inode());
if (!vmobject)
return KResult(-ENOMEM);
auto* region = process.allocate_region_with_vmobject(preferred_vaddr, size, *vmobject, offset, description.absolute_path(), prot);
auto* region = process.allocate_region_with_vmobject(preferred_vaddr, size, *vmobject, offset, description.absolute_path(), prot, shared);
if (!region)
return KResult(-ENOMEM);
return region;