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

Kernel: Pass 'prot' argument to File::mmap() and act on it.

Nothing crazy, this just means that PROT_READ allocates readable regions,
and that PROT_WRITE allocates writable ones.
This commit is contained in:
Andreas Kling 2019-05-30 12:38:35 +02:00
parent 004a630bfe
commit 66c1a9be3b
7 changed files with 11 additions and 9 deletions

View file

@ -89,9 +89,9 @@ int SharedMemory::write(FileDescriptor&, const byte* data, int data_size)
ASSERT_NOT_REACHED();
}
KResultOr<Region*> SharedMemory::mmap(Process& process, LinearAddress laddr, size_t offset, size_t size)
KResultOr<Region*> SharedMemory::mmap(Process& process, LinearAddress laddr, size_t offset, size_t size, int prot)
{
if (!vmo())
return KResult(-ENODEV);
return process.allocate_region_with_vmo(laddr, size, *vmo(), offset, name(), true, true);
return process.allocate_region_with_vmo(laddr, size, *vmo(), offset, name(), prot & PROT_READ, prot & PROT_WRITE);
}