mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:58:11 +00:00
Kernel: Factor out range allocation from Process::allocate_region*().
These functions were doing exactly the same thing for range allocation, so share that code in an allocate_range() helper. Region allocation will now also fail if range allocation fails, which means that mmap() can actually fail without falling apart. Exciting times!
This commit is contained in:
parent
87b54a82c7
commit
6957825444
3 changed files with 20 additions and 24 deletions
|
@ -346,6 +346,8 @@ KResultOr<Region*> FileDescriptor::mmap(Process& process, LinearAddress laddr, s
|
|||
// FIXME: Implement mapping at a client-specified address. Most of the support is already in plcae.
|
||||
ASSERT(laddr.as_ptr() == nullptr);
|
||||
auto* region = process.allocate_file_backed_region(LinearAddress(), size, inode(), move(region_name), prot & PROT_READ, prot & PROT_WRITE);
|
||||
if (!region)
|
||||
return KResult(-ENOMEM);
|
||||
region->page_in();
|
||||
return region;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue