diff options
author | Sergey Bugaev <bugaevc@gmail.com> | 2019-08-17 12:17:36 +0300 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-08-17 12:07:55 +0200 |
commit | fde8f7f538bfacd8ae98c8f8ab86c18609c39783 (patch) | |
tree | 547520ef330f10af35886bdd922b8d4ef6190261 /Kernel | |
parent | 425c356288dbe2c6a01bde6d76e71c1ae0137acf (diff) | |
download | serenity-fde8f7f538bfacd8ae98c8f8ab86c18609c39783.zip |
Kernel: Expose info about source devices of mounts in /proc/df
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/Devices/Device.cpp | 7 | ||||
-rw-r--r-- | Kernel/Devices/Device.h | 1 | ||||
-rw-r--r-- | Kernel/FileSystem/DiskBackedFileSystem.h | 2 | ||||
-rw-r--r-- | Kernel/FileSystem/FileSystem.h | 2 | ||||
-rw-r--r-- | Kernel/FileSystem/ProcFS.cpp | 9 |
5 files changed, 19 insertions, 2 deletions
diff --git a/Kernel/Devices/Device.cpp b/Kernel/Devices/Device.cpp index 601ff9fa71..39f7c16f4b 100644 --- a/Kernel/Devices/Device.cpp +++ b/Kernel/Devices/Device.cpp @@ -14,7 +14,12 @@ Device::~Device() VFS::the().unregister_device({}, *this); } -String Device::absolute_path(const FileDescription&) const +String Device::absolute_path() const { return String::format("device:%u,%u (%s)", m_major, m_minor, class_name()); } + +String Device::absolute_path(const FileDescription&) const +{ + return absolute_path(); +} diff --git a/Kernel/Devices/Device.h b/Kernel/Devices/Device.h index 467a81e5ad..9455d4e4a3 100644 --- a/Kernel/Devices/Device.h +++ b/Kernel/Devices/Device.h @@ -20,6 +20,7 @@ public: unsigned minor() const { return m_minor; } virtual String absolute_path(const FileDescription&) const override; + virtual String absolute_path() const; uid_t uid() const { return m_uid; } uid_t gid() const { return m_gid; } diff --git a/Kernel/FileSystem/DiskBackedFileSystem.h b/Kernel/FileSystem/DiskBackedFileSystem.h index 6221dac829..1b6ee8189c 100644 --- a/Kernel/FileSystem/DiskBackedFileSystem.h +++ b/Kernel/FileSystem/DiskBackedFileSystem.h @@ -7,6 +7,8 @@ class DiskBackedFS : public FS { public: virtual ~DiskBackedFS() override; + virtual bool is_disk_backed() const override { return true; } + DiskDevice& device() { return *m_device; } const DiskDevice& device() const { return *m_device; } diff --git a/Kernel/FileSystem/FileSystem.h b/Kernel/FileSystem/FileSystem.h index 0c8bad2860..270cc23152 100644 --- a/Kernel/FileSystem/FileSystem.h +++ b/Kernel/FileSystem/FileSystem.h @@ -65,6 +65,8 @@ public: int block_size() const { return m_block_size; } + virtual bool is_disk_backed() const { return false; } + protected: FS(); diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp index 5b18c989e6..d01cc969bc 100644 --- a/Kernel/FileSystem/ProcFS.cpp +++ b/Kernel/FileSystem/ProcFS.cpp @@ -9,6 +9,7 @@ #include <AK/JsonValue.h> #include <Kernel/Arch/i386/CPU.h> #include <Kernel/FileSystem/Custody.h> +#include <Kernel/FileSystem/DiskBackedFileSystem.h> #include <Kernel/FileSystem/FileDescription.h> #include <Kernel/FileSystem/VirtualFileSystem.h> #include <Kernel/KBufferBuilder.h> @@ -502,7 +503,13 @@ Optional<KBuffer> procfs$df(InodeIdentifier) fs_object.set("mount_point", mount.absolute_path()); fs_object.set("block_size", fs.block_size()); fs_object.set("readonly", fs.is_readonly()); - json.append(fs_object); + + if (fs.is_disk_backed()) + fs_object.set("device", static_cast<const DiskBackedFS&>(fs).device().absolute_path()); + else + fs_object.set("device", nullptr); + + json.append(move(fs_object)); }); return json.serialized<KBufferBuilder>(); } |