From 6daad7787ae03b156d70c2bf20f4fccfa9d563d0 Mon Sep 17 00:00:00 2001 From: apio Date: Sat, 25 Feb 2023 18:05:25 +0100 Subject: [PATCH] kernel: Rename FileSystem::root() to root_inode() and add a shortcut for the root filesystem's root inode --- kernel/src/fs/VFS.cpp | 5 +++++ kernel/src/fs/VFS.h | 4 +++- kernel/src/fs/tmpfs/FileSystem.h | 2 +- kernel/src/main.cpp | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/kernel/src/fs/VFS.cpp b/kernel/src/fs/VFS.cpp index dfa9b609..1da679c4 100644 --- a/kernel/src/fs/VFS.cpp +++ b/kernel/src/fs/VFS.cpp @@ -3,4 +3,9 @@ namespace VFS { SharedPtr root_fs; + + Inode& root_inode() + { + return root_fs->root_inode(); + } } diff --git a/kernel/src/fs/VFS.h b/kernel/src/fs/VFS.h index ac1ec564..78801006 100644 --- a/kernel/src/fs/VFS.h +++ b/kernel/src/fs/VFS.h @@ -44,7 +44,7 @@ namespace VFS class FileSystem { public: - virtual Inode& root() const = 0; + virtual Inode& root_inode() const = 0; virtual Result> create_file_inode() = 0; @@ -54,4 +54,6 @@ namespace VFS extern SharedPtr root_fs; Result resolve_path(const char* path); + + Inode& root_inode(); } diff --git a/kernel/src/fs/tmpfs/FileSystem.h b/kernel/src/fs/tmpfs/FileSystem.h index 75929143..77c012c1 100644 --- a/kernel/src/fs/tmpfs/FileSystem.h +++ b/kernel/src/fs/tmpfs/FileSystem.h @@ -8,7 +8,7 @@ namespace TmpFS class FileSystem : public VFS::FileSystem { public: - VFS::Inode& root() const override + VFS::Inode& root_inode() const override { return *m_root_inode; } diff --git a/kernel/src/main.cpp b/kernel/src/main.cpp index f0c83f7b..b65c997d 100644 --- a/kernel/src/main.cpp +++ b/kernel/src/main.cpp @@ -58,7 +58,7 @@ Result init() VFS::root_fs = TRY(TmpFS::FileSystem::create()); - VFS::Inode& root_inode = VFS::root_fs->root(); + VFS::Inode& root_inode = VFS::root_inode(); kinfoln("root inode number: %zu", root_inode.inode_number()); TarStream::Entry entry;