diff --git a/kernel/src/fs/VFS.h b/kernel/src/fs/VFS.h index 78801006..843ad15c 100644 --- a/kernel/src/fs/VFS.h +++ b/kernel/src/fs/VFS.h @@ -14,7 +14,7 @@ namespace VFS class Inode { public: - virtual Result find(const char* name) const = 0; + virtual Result> find(const char* name) const = 0; virtual FileSystem& fs() const = 0; @@ -28,7 +28,7 @@ namespace VFS class FileInode : Inode { public: - Result find(const char*) const override + Result> find(const char*) const override { return err(ENOTDIR); } diff --git a/kernel/src/fs/tmpfs/FileSystem.cpp b/kernel/src/fs/tmpfs/FileSystem.cpp index 14010ee7..934e8437 100644 --- a/kernel/src/fs/tmpfs/FileSystem.cpp +++ b/kernel/src/fs/tmpfs/FileSystem.cpp @@ -1,5 +1,6 @@ #include "fs/tmpfs/FileSystem.h" #include +#include namespace TmpFS { @@ -25,4 +26,10 @@ namespace TmpFS { m_root_inode = root; } + + Result> DirInode::find(const char* name) const + { + ignore(name); + todo(); + } } diff --git a/kernel/src/fs/tmpfs/FileSystem.h b/kernel/src/fs/tmpfs/FileSystem.h index 070a6e51..817af741 100644 --- a/kernel/src/fs/tmpfs/FileSystem.h +++ b/kernel/src/fs/tmpfs/FileSystem.h @@ -62,4 +62,43 @@ namespace TmpFS VFS::FileSystem* m_fs; usize m_inode_number; }; + + class DirInode : public VFS::Inode + { + public: + DirInode() = default; + + void set_fs(FileSystem& fs, Badge) + { + m_fs = &fs; + } + + void set_inode_number(usize inum, Badge) + { + m_inode_number = inum; + } + + Result> find(const char* name) const override; + + VFS::FileSystem& fs() const override + { + return *m_fs; + } + + usize inode_number() const override + { + return m_inode_number; + } + + VFS::InodeType type() const override + { + return VFS::InodeType::Directory; + } + + virtual ~DirInode() = default; + + private: + VFS::FileSystem* m_fs; + usize m_inode_number; + }; }