diff options
author | Conrad Pankoff <deoxxa@fknsrs.biz> | 2019-08-14 01:22:27 +1000 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-08-14 06:28:53 +0200 |
commit | 833f0beeedd41ca143a2f640a043d1415d980755 (patch) | |
tree | e8f4d89dd0abb22279056b152326d6490997d8e6 /Kernel | |
parent | dce003c7ebc3436f7c02241a9d9618387dc4af51 (diff) | |
download | serenity-833f0beeedd41ca143a2f640a043d1415d980755.zip |
Kernel: Reimplement /proc/pci as JSON, add some more fields
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/FileSystem/ProcFS.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
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<KBuffer> procfs$pid_vm(InodeIdentifier identifier) Optional<KBuffer> 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<KBufferBuilder>(); } Optional<KBuffer> procfs$uptime(InodeIdentifier) |