diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-06-16 07:06:49 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-06-16 07:06:49 +0200 |
commit | 9e0f7acfe5d7529cf65d86cfd229780aca8c3694 (patch) | |
tree | c6b759258f09cb6535b6e471a963a48f1cf18b9d /Kernel/FileSystem | |
parent | 264890bfc3645b044b09e5b908ec60bbd678992c (diff) | |
download | serenity-9e0f7acfe5d7529cf65d86cfd229780aca8c3694.zip |
Kernel+Userland: Expose list of network adapters through /proc/netadapters.
Added a simple /bin/ifconfig program that just pretty-prints that file. :^)
Diffstat (limited to 'Kernel/FileSystem')
-rw-r--r-- | Kernel/FileSystem/ProcFS.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp index f1cc2c74aa..c042b5abb7 100644 --- a/Kernel/FileSystem/ProcFS.cpp +++ b/Kernel/FileSystem/ProcFS.cpp @@ -9,6 +9,7 @@ #include <Kernel/FileSystem/Custody.h> #include <Kernel/FileSystem/FileDescription.h> #include <Kernel/FileSystem/VirtualFileSystem.h> +#include <Kernel/Net/NetworkAdapter.h> #include <Kernel/PCI.h> #include <Kernel/VM/MemoryManager.h> #include <Kernel/kmalloc.h> @@ -40,6 +41,7 @@ enum ProcFileType { FI_Root_dmesg, FI_Root_pci, FI_Root_uptime, + FI_Root_netadapters, FI_Root_self, // symlink FI_Root_sys, // directory __FI_Root_End, @@ -251,6 +253,19 @@ ByteBuffer procfs$uptime(InodeIdentifier) return builder.to_byte_buffer(); } +ByteBuffer procfs$netadapters(InodeIdentifier) +{ + StringBuilder builder; + NetworkAdapter::for_each([&builder](auto& adapter) { + builder.appendf("%s,%s,%s,%s\n", + adapter.name().characters(), + adapter.class_name(), + adapter.mac_address().to_string().characters(), + adapter.ipv4_address().to_string().characters()); + }); + return builder.to_byte_buffer(); +} + ByteBuffer procfs$pid_vmo(InodeIdentifier identifier) { auto handle = ProcessInspectionHandle::from_pid(to_pid(identifier)); @@ -1098,6 +1113,7 @@ ProcFS::ProcFS() 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_uptime] = { "uptime", FI_Root_uptime, procfs$uptime }; + m_entries[FI_Root_netadapters] = { "netadapters", FI_Root_netadapters, procfs$netadapters }; m_entries[FI_Root_sys] = { "sys", FI_Root_sys }; m_entries[FI_PID_vm] = { "vm", FI_PID_vm, procfs$pid_vm }; |