summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-07-28 11:37:50 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-07-28 11:37:50 +0200
commit52a5e34902f5c6d15e8027b281c2a7349ed88162 (patch)
tree4c71b9ecb5192399fc17f9234b76451febf49309 /Kernel/FileSystem
parentd4892b3fdc36546545058a3e3c5a10d61be07c8e (diff)
downloadserenity-52a5e34902f5c6d15e8027b281c2a7349ed88162.zip
Kernel: Convert /proc/PID/vm to JSON.
Diffstat (limited to 'Kernel/FileSystem')
-rw-r--r--Kernel/FileSystem/ProcFS.cpp25
1 files changed, 10 insertions, 15 deletions
diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp
index ce94ddf1bf..b1ea7d9491 100644
--- a/Kernel/FileSystem/ProcFS.cpp
+++ b/Kernel/FileSystem/ProcFS.cpp
@@ -222,23 +222,18 @@ ByteBuffer procfs$pid_vm(InodeIdentifier identifier)
if (!handle)
return {};
auto& process = handle->process();
- StringBuilder builder;
- builder.appendf("BEGIN END SIZE COMMIT FLAGS NAME\n");
+ JsonArray array;
for (auto& region : process.regions()) {
- StringBuilder flags_builder;
- if (region.is_readable())
- flags_builder.append('R');
- if (region.is_writable())
- flags_builder.append('W');
- builder.appendf("%x -- %x %x %x %-4s %s\n",
- region.vaddr().get(),
- region.vaddr().offset(region.size() - 1).get(),
- region.size(),
- region.amount_resident(),
- flags_builder.to_string().characters(),
- region.name().characters());
+ JsonObject region_object;
+ region_object.set("readable", region.is_readable());
+ region_object.set("writable", region.is_writable());
+ region_object.set("address", region.vaddr().get());
+ region_object.set("size", region.size());
+ region_object.set("amount_resident", region.amount_resident());
+ region_object.set("name", region.name());
+ array.append(move(region_object));
}
- return builder.to_byte_buffer();
+ return array.serialized().to_byte_buffer();
}
ByteBuffer procfs$pci(InodeIdentifier)