1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:27:35 +00:00

Support basic mmap'ing of a file!

All right, we can now mmap() a file and it gets magically paged in from fs
in response to an NP page fault. This is really cool :^)

I need to refactor this to support sharing of read-only file-backed pages,
but it's cool to just have something working.
This commit is contained in:
Andreas Kling 2018-11-08 12:59:16 +01:00
parent fdbd9f1e27
commit 3c8064a787
8 changed files with 141 additions and 14 deletions

View file

@ -72,7 +72,7 @@ struct Region : public Retainable<Region> {
return (laddr - linearAddress).get() / PAGE_SIZE;
}
RetainPtr<VirtualFileSystem::Node> m_file;
RetainPtr<VirtualFileSystem::Node> m_vnode;
Unix::off_t m_file_offset { 0 };
LinearAddress linearAddress;
@ -115,6 +115,7 @@ public:
bool validate_user_write(const Process&, LinearAddress) const;
Vector<RetainPtr<PhysicalPage>> allocate_physical_pages(size_t count);
RetainPtr<PhysicalPage> allocate_physical_page();
void remap_region(Process&, Region&);
@ -142,6 +143,7 @@ private:
static Region* region_from_laddr(Process&, LinearAddress);
bool copy_on_write(Process&, Region&, unsigned page_index_in_region);
bool page_in_from_vnode(Process&, Region&, unsigned page_index_in_region);
byte* quickmap_page(PhysicalPage&);
void unquickmap_page();