From 84a54c7cf70c9b2bfc47c529120dd089ad3d4a65 Mon Sep 17 00:00:00 2001 From: Sergey Bugaev Date: Fri, 9 Aug 2019 13:10:26 +0300 Subject: [PATCH] ProcFS: Make a new nifty /proc/net directory And move /proc/netadapters and /proc/net_tcp there. Now they're /proc/net/adapters and /proc/net/tcp respectively, with more to come ^) --- .../ProcessManager/NetworkAdapterModel.cpp | 2 +- Applications/ProcessManager/SocketModel.cpp | 2 +- Kernel/FileSystem/ProcFS.cpp | 32 ++++++++++++++++--- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/Applications/ProcessManager/NetworkAdapterModel.cpp b/Applications/ProcessManager/NetworkAdapterModel.cpp index 87cb6a926a1..c2c8a3aa9a2 100644 --- a/Applications/ProcessManager/NetworkAdapterModel.cpp +++ b/Applications/ProcessManager/NetworkAdapterModel.cpp @@ -5,7 +5,7 @@ void NetworkAdapterModel::update() { - CFile file("/proc/netadapters"); + CFile file("/proc/net/adapters"); if (!file.open(CIODevice::ReadOnly)) { dbg() << "Unable to open " << file.filename(); return; diff --git a/Applications/ProcessManager/SocketModel.cpp b/Applications/ProcessManager/SocketModel.cpp index bec130ab1b0..420be1e6609 100644 --- a/Applications/ProcessManager/SocketModel.cpp +++ b/Applications/ProcessManager/SocketModel.cpp @@ -5,7 +5,7 @@ void SocketModel::update() { - CFile file("/proc/net_tcp"); + CFile file("/proc/net/tcp"); if (!file.open(CIODevice::ReadOnly)) { dbg() << "Unable to open " << file.filename(); return; diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp index 13f115c3796..dbb9ed96fba 100644 --- a/Kernel/FileSystem/ProcFS.cpp +++ b/Kernel/FileSystem/ProcFS.cpp @@ -24,6 +24,7 @@ enum ProcParentDirectory { PDI_AbstractRoot = 0, PDI_Root, PDI_Root_sys, + PDI_Root_net, PDI_PID, PDI_PID_fd, }; @@ -45,12 +46,14 @@ enum ProcFileType { FI_Root_pci, FI_Root_uptime, FI_Root_cmdline, - FI_Root_netadapters, - FI_Root_net_tcp, FI_Root_self, // symlink FI_Root_sys, // directory + FI_Root_net, // directory __FI_Root_End, + FI_Root_net_adapters, + FI_Root_net_tcp, + FI_PID, __FI_PID_Start, @@ -116,6 +119,8 @@ static inline InodeIdentifier to_parent_id(const InodeIdentifier& identifier) return { identifier.fsid(), FI_Root }; case PDI_Root_sys: return { identifier.fsid(), FI_Root_sys }; + case PDI_Root_net: + return { identifier.fsid(), FI_Root_net }; case PDI_PID: return to_identifier(identifier.fsid(), PDI_Root, to_pid(identifier), FI_PID); case PDI_PID_fd: @@ -156,6 +161,7 @@ static inline bool is_directory(const InodeIdentifier& identifier) switch (proc_file_type) { case FI_Root: case FI_Root_sys: + case FI_Root_net: case FI_PID: case FI_PID_fd: return true; @@ -266,7 +272,7 @@ Optional procfs$cmdline(InodeIdentifier) return builder.build(); } -Optional procfs$netadapters(InodeIdentifier) +Optional procfs$net_adapters(InodeIdentifier) { JsonArray json; NetworkAdapter::for_each([&json](auto& adapter) { @@ -809,6 +815,7 @@ InodeMetadata ProcFSInode::metadata() const break; case FI_Root: case FI_Root_sys: + case FI_Root_net: case FI_PID: case FI_PID_fd: metadata.mode = 040777; @@ -907,6 +914,11 @@ bool ProcFSInode::traverse_as_directory(Function