diff options
-rw-r--r-- | Kernel/FileSystem/ProcFS.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp index d01cc969bc..cc6a1d0f8a 100644 --- a/Kernel/FileSystem/ProcFS.cpp +++ b/Kernel/FileSystem/ProcFS.cpp @@ -47,6 +47,7 @@ enum ProcFileType { FI_Root_inodes, FI_Root_dmesg, FI_Root_pci, + FI_Root_devices, FI_Root_uptime, FI_Root_cmdline, FI_Root_self, // symlink @@ -269,6 +270,27 @@ Optional<KBuffer> procfs$pci(InodeIdentifier) return json.serialized<KBufferBuilder>(); } +Optional<KBuffer> procfs$devices(InodeIdentifier) +{ + JsonArray json; + Device::for_each([&json](auto& device) { + JsonObject obj; + obj.set("major", device.major()); + obj.set("minor", device.minor()); + obj.set("class_name", device.class_name()); + + if (device.is_block_device()) + obj.set("type", "block"); + else if (device.is_character_device()) + obj.set("type", "character"); + else + ASSERT_NOT_REACHED(); + + json.append(move(obj)); + }); + return json.serialized<KBufferBuilder>(); +} + Optional<KBuffer> procfs$uptime(InodeIdentifier) { KBufferBuilder builder; @@ -1198,6 +1220,7 @@ ProcFS::ProcFS() m_entries[FI_Root_dmesg] = { "dmesg", FI_Root_dmesg, procfs$dmesg }; m_entries[FI_Root_self] = { "self", FI_Root_self, procfs$self }; m_entries[FI_Root_pci] = { "pci", FI_Root_pci, procfs$pci }; + m_entries[FI_Root_devices] = { "devices", FI_Root_devices, procfs$devices }; m_entries[FI_Root_uptime] = { "uptime", FI_Root_uptime, procfs$uptime }; m_entries[FI_Root_cmdline] = { "cmdline", FI_Root_cmdline, procfs$cmdline }; m_entries[FI_Root_sys] = { "sys", FI_Root_sys }; |