1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 18:18:12 +00:00

Kernel: Include absolute paths of mount points in /proc/mounts

This commit is contained in:
Andreas Kling 2019-01-31 06:13:55 +01:00
parent 34e745b0b4
commit fc0b63ca3c
4 changed files with 20 additions and 6 deletions

View file

@ -124,7 +124,7 @@ bool Ext2FS::initialize()
const char* Ext2FS::class_name() const
{
return "ext2fs";
return "Ext2FS";
}
InodeIdentifier Ext2FS::root_inode() const

View file

@ -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";
}

View file

@ -371,6 +371,14 @@ RetainPtr<Inode> 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;

View file

@ -79,6 +79,7 @@ public:
void for_each_mount(Function<void(const Mount&)>) const;
String absolute_path(Inode&);
String absolute_path(InodeIdentifier);
InodeIdentifier root_inode_id() const;
Inode* root_inode() { return m_root_inode.ptr(); }