Kernel: Implement basic support for sys$mmap() with MAP_PRIVATE

You can now mmap a file as private and writable, and the changes you
make will only be visible to you.

This works because internally a MAP_PRIVATE region is backed by a
unique PrivateInodeVMObject instead of using the globally shared
SharedInodeVMObject like we always did before. :^)

Fixes #1045.
This commit is contained in:
Andreas Kling 2020-02-28 20:47:27 +01:00
commit 8fbdda5a2d
Notes: sideshowbarker 2024-07-19 08:59:02 +09:00
11 changed files with 45 additions and 31 deletions

View file

@ -166,9 +166,11 @@ u32 BXVGADevice::find_framebuffer_address()
return framebuffer_address;
}
KResultOr<Region*> BXVGADevice::mmap(Process& process, FileDescription&, VirtualAddress preferred_vaddr, size_t offset, size_t size, int prot)
KResultOr<Region*> BXVGADevice::mmap(Process& process, FileDescription&, VirtualAddress preferred_vaddr, size_t offset, size_t size, int prot, bool shared)
{
REQUIRE_PROMISE(video);
if (!shared)
return KResult(-ENODEV);
ASSERT(offset == 0);
ASSERT(size == framebuffer_size_in_bytes());
auto vmobject = AnonymousVMObject::create_for_physical_range(m_framebuffer_address, framebuffer_size_in_bytes());