From 833f0beeedd41ca143a2f640a043d1415d980755 Mon Sep 17 00:00:00 2001 From: Conrad Pankoff Date: Wed, 14 Aug 2019 01:22:27 +1000 Subject: Kernel: Reimplement /proc/pci as JSON, add some more fields --- Kernel/FileSystem/ProcFS.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'Kernel') diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp index 44927f55a8..d1a666c9df 100644 --- a/Kernel/FileSystem/ProcFS.cpp +++ b/Kernel/FileSystem/ProcFS.cpp @@ -255,11 +255,22 @@ Optional procfs$pid_vm(InodeIdentifier identifier) Optional procfs$pci(InodeIdentifier) { - KBufferBuilder builder; - PCI::enumerate_all([&builder](PCI::Address address, PCI::ID id) { - builder.appendf("%b:%b.%b %w:%w\n", address.bus(), address.slot(), address.function(), id.vendor_id, id.device_id); + JsonArray json; + PCI::enumerate_all([&json](PCI::Address address, PCI::ID id) { + JsonObject obj; + obj.set("bus", address.bus()); + obj.set("slot", address.slot()); + obj.set("function", address.function()); + obj.set("vendor_id", id.vendor_id); + obj.set("device_id", id.device_id); + obj.set("revision_id", PCI::get_revision_id(address)); + obj.set("subclass", PCI::get_subclass(address)); + obj.set("class", PCI::get_class(address)); + obj.set("subsystem_id", PCI::get_subsystem_id(address)); + obj.set("subsystem_vendor_id", PCI::get_subsystem_vendor_id(address)); + json.append(obj); }); - return builder.build(); + return json.serialized(); } Optional procfs$uptime(InodeIdentifier) -- cgit v1.2.3