diff options
author | Andreas Kling <kling@serenityos.org> | 2020-04-28 16:19:50 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-28 17:05:14 +0200 |
commit | 9c856811b2ad18b933fc1d9d5b8a771893fa7d9c (patch) | |
tree | 264439a31fc3978ba85bae11d7d2d48bce5de03a /Kernel/FileSystem | |
parent | 8a417c311f3c3c13dc5353619051aac777c9f1df (diff) | |
download | serenity-9c856811b2ad18b933fc1d9d5b8a771893fa7d9c.zip |
Kernel: Add Region helpers for accessing underlying physical pages
Since a Region is basically a view into a potentially larger VMObject,
it was always necessary to include the Region starting offset when
accessing its underlying physical pages.
Until now, you had to do that manually, but this patch adds a simple
Region::physical_page() for read-only access and a physical_page_slot()
when you want a mutable reference to the RefPtr<PhysicalPage> itself.
A lot of code is simplified by making use of this.
Diffstat (limited to 'Kernel/FileSystem')
-rw-r--r-- | Kernel/FileSystem/ProcFS.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp index b912728f9f..927383dd45 100644 --- a/Kernel/FileSystem/ProcFS.cpp +++ b/Kernel/FileSystem/ProcFS.cpp @@ -319,11 +319,10 @@ Optional<KBuffer> procfs$pid_vm(InodeIdentifier identifier) StringBuilder pagemap_builder; for (size_t i = 0; i < region.page_count(); ++i) { - auto page_index = region.first_page_index() + i; - auto& physical_page_slot = region.vmobject().physical_pages()[page_index]; - if (!physical_page_slot) + auto* page = region.physical_page(i); + if (!page) pagemap_builder.append('N'); - else if (physical_page_slot == MM.shared_zero_page()) + else if (page->is_shared_zero_page()) pagemap_builder.append('Z'); else pagemap_builder.append('P'); |