From fc0b63ca3c4af109c155c5a572afe03621b9d20e Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 31 Jan 2019 06:13:55 +0100 Subject: [PATCH] Kernel: Include absolute paths of mount points in /proc/mounts --- Kernel/Ext2FileSystem.cpp | 2 +- Kernel/ProcFileSystem.cpp | 15 ++++++++++----- Kernel/VirtualFileSystem.cpp | 8 ++++++++ Kernel/VirtualFileSystem.h | 1 + 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Kernel/Ext2FileSystem.cpp b/Kernel/Ext2FileSystem.cpp index a5f3761dc0..883926a1d3 100644 --- a/Kernel/Ext2FileSystem.cpp +++ b/Kernel/Ext2FileSystem.cpp @@ -124,7 +124,7 @@ bool Ext2FS::initialize() const char* Ext2FS::class_name() const { - return "ext2fs"; + return "Ext2FS"; } InodeIdentifier Ext2FS::root_inode() const diff --git a/Kernel/ProcFileSystem.cpp b/Kernel/ProcFileSystem.cpp index 52a1942f97..a6c4c53c55 100644 --- a/Kernel/ProcFileSystem.cpp +++ b/Kernel/ProcFileSystem.cpp @@ -208,15 +208,20 @@ ByteBuffer procfs$dmesg(SynthFSInode&) ByteBuffer procfs$mounts(SynthFSInode&) { - InterruptDisabler disabler; + // FIXME: This is obviously racy against the VFS mounts changing. StringBuilder builder; VFS::the().for_each_mount([&builder] (auto& mount) { auto& fs = mount.guest_fs(); builder.appendf("%s @ ", fs.class_name()); if (!mount.host().is_valid()) - builder.appendf("/\n", fs.class_name()); - else - builder.appendf("%u:%u\n", mount.host().fsid(), mount.host().index()); + builder.appendf("/"); + else { + builder.appendf("%u:%u", mount.host().fsid(), mount.host().index()); + auto path = VFS::the().absolute_path(mount.host()); + builder.append(' '); + builder.append(path); + } + builder.append('\n'); }); return builder.to_byte_buffer(); } @@ -401,5 +406,5 @@ bool ProcFS::initialize() const char* ProcFS::class_name() const { - return "procfs"; + return "ProcFS"; } diff --git a/Kernel/VirtualFileSystem.cpp b/Kernel/VirtualFileSystem.cpp index 88ccca1add..bcfdab96c7 100644 --- a/Kernel/VirtualFileSystem.cpp +++ b/Kernel/VirtualFileSystem.cpp @@ -371,6 +371,14 @@ RetainPtr VFS::get_inode(InodeIdentifier inode_id) return inode_id.fs()->get_inode(inode_id); } +String VFS::absolute_path(InodeIdentifier inode_id) +{ + auto inode = get_inode(inode_id); + if (!inode) + return { }; + return absolute_path(*inode); +} + String VFS::absolute_path(Inode& core_inode) { int error; diff --git a/Kernel/VirtualFileSystem.h b/Kernel/VirtualFileSystem.h index fa171f4c15..df54222a93 100644 --- a/Kernel/VirtualFileSystem.h +++ b/Kernel/VirtualFileSystem.h @@ -79,6 +79,7 @@ public: void for_each_mount(Function) const; String absolute_path(Inode&); + String absolute_path(InodeIdentifier); InodeIdentifier root_inode_id() const; Inode* root_inode() { return m_root_inode.ptr(); }