1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 12:05:00 +00:00

Kernel: Hoist VM range allocation up to sys$mmap() itself

Instead of letting each File subclass do range allocation in their
mmap() override, do it up front in sys$mmap().

This makes us honor alignment requests for file-backed memory mappings
and simplifies the code somwhat.
This commit is contained in:
Andreas Kling 2021-01-25 14:52:36 +01:00
parent adcc1c1eff
commit ab14b0ac64
13 changed files with 26 additions and 36 deletions

View file

@ -39,15 +39,15 @@ AnonymousFile::~AnonymousFile()
{
}
KResultOr<Region*> AnonymousFile::mmap(Process& process, FileDescription&, VirtualAddress preferred_vaddr, size_t offset, size_t size, int prot, bool shared)
KResultOr<Region*> AnonymousFile::mmap(Process& process, FileDescription&, const Range& range, size_t offset, int prot, bool shared)
{
if (offset != 0)
return EINVAL;
if (size != m_vmobject->size())
if (range.size() != m_vmobject->size())
return EINVAL;
return process.allocate_region_with_vmobject(preferred_vaddr, size, m_vmobject, offset, {}, prot, shared);
return process.allocate_region_with_vmobject(range, m_vmobject, offset, {}, prot, shared);
}
}