mirror of
https://github.com/RGBCube/serenity
synced 2025-07-19 11:37:39 +00:00
Kernel: Fix mmap with specific address for file backed mappings
This commit is contained in:
parent
79818bbf8e
commit
d64d0451e5
1 changed files with 10 additions and 6 deletions
|
@ -133,18 +133,22 @@ void* Process::sys$mmap(Userspace<const Syscall::SC_mmap_params*> user_params)
|
||||||
return (void*)-EINVAL;
|
return (void*)-EINVAL;
|
||||||
|
|
||||||
Region* region = nullptr;
|
Region* region = nullptr;
|
||||||
|
Optional<Range> range;
|
||||||
auto range = allocate_range(VirtualAddress(addr), size, alignment);
|
if (map_purgeable || map_anonymous) {
|
||||||
if (!range.is_valid())
|
range = allocate_range(VirtualAddress(addr), size, alignment);
|
||||||
|
if (!range.value().is_valid())
|
||||||
return (void*)-ENOMEM;
|
return (void*)-ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
if (map_purgeable) {
|
if (map_purgeable) {
|
||||||
|
|
||||||
auto vmobject = PurgeableVMObject::create_with_size(size);
|
auto vmobject = PurgeableVMObject::create_with_size(size);
|
||||||
region = allocate_region_with_vmobject(range, vmobject, 0, !name.is_null() ? name : "mmap (purgeable)", prot);
|
region = allocate_region_with_vmobject(range.value(), vmobject, 0, !name.is_null() ? name : "mmap (purgeable)", prot);
|
||||||
if (!region && (!map_fixed && addr != 0))
|
if (!region && (!map_fixed && addr != 0))
|
||||||
region = allocate_region_with_vmobject({}, size, vmobject, 0, !name.is_null() ? name : "mmap (purgeable)", prot);
|
region = allocate_region_with_vmobject({}, size, vmobject, 0, !name.is_null() ? name : "mmap (purgeable)", prot);
|
||||||
} else if (map_anonymous) {
|
} else if (map_anonymous) {
|
||||||
region = allocate_region(range, !name.is_null() ? name : "mmap", prot, false);
|
|
||||||
|
region = allocate_region(range.value(), !name.is_null() ? name : "mmap", prot, false);
|
||||||
if (!region && (!map_fixed && addr != 0))
|
if (!region && (!map_fixed && addr != 0))
|
||||||
region = allocate_region(allocate_range({}, size), !name.is_null() ? name : "mmap", prot, false);
|
region = allocate_region(allocate_range({}, size), !name.is_null() ? name : "mmap", prot, false);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue