kernel: Rename FileSystem::root() to root_inode() and add a shortcut for the root filesystem's root inode

This commit is contained in:
apio 2023-02-25 18:05:25 +01:00
parent ddc4692671
commit 6daad7787a
Signed by: apio
GPG Key ID: B8A7D06E42258954
4 changed files with 10 additions and 3 deletions

View File

@ -3,4 +3,9 @@
namespace VFS namespace VFS
{ {
SharedPtr<FileSystem> root_fs; SharedPtr<FileSystem> root_fs;
Inode& root_inode()
{
return root_fs->root_inode();
}
} }

View File

@ -44,7 +44,7 @@ namespace VFS
class FileSystem class FileSystem
{ {
public: public:
virtual Inode& root() const = 0; virtual Inode& root_inode() const = 0;
virtual Result<SharedPtr<Inode>> create_file_inode() = 0; virtual Result<SharedPtr<Inode>> create_file_inode() = 0;
@ -54,4 +54,6 @@ namespace VFS
extern SharedPtr<FileSystem> root_fs; extern SharedPtr<FileSystem> root_fs;
Result<Inode*> resolve_path(const char* path); Result<Inode*> resolve_path(const char* path);
Inode& root_inode();
} }

View File

@ -8,7 +8,7 @@ namespace TmpFS
class FileSystem : public VFS::FileSystem class FileSystem : public VFS::FileSystem
{ {
public: public:
VFS::Inode& root() const override VFS::Inode& root_inode() const override
{ {
return *m_root_inode; return *m_root_inode;
} }

View File

@ -58,7 +58,7 @@ Result<void> init()
VFS::root_fs = TRY(TmpFS::FileSystem::create()); 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()); kinfoln("root inode number: %zu", root_inode.inode_number());
TarStream::Entry entry; TarStream::Entry entry;