Start working on a VFS implementation #22

Closed
apio wants to merge 44 commits from oop-vfs into main
3 changed files with 48 additions and 2 deletions
Showing only changes of commit cca4743a51 - Show all commits

View File

@ -14,7 +14,7 @@ namespace VFS
class Inode
{
public:
virtual Result<Inode*> find(const char* name) const = 0;
virtual Result<SharedPtr<Inode>> find(const char* name) const = 0;
virtual FileSystem& fs() const = 0;
@ -28,7 +28,7 @@ namespace VFS
class FileInode : Inode
{
public:
Result<Inode*> find(const char*) const override
Result<SharedPtr<Inode>> find(const char*) const override
{
return err(ENOTDIR);
}

View File

@ -1,5 +1,6 @@
#include "fs/tmpfs/FileSystem.h"
#include <luna/Alloc.h>
#include <luna/Ignore.h>
namespace TmpFS
{
@ -25,4 +26,10 @@ namespace TmpFS
{
m_root_inode = root;
}
Result<SharedPtr<VFS::Inode>> DirInode::find(const char* name) const
{
ignore(name);
todo();
}
}

View File

@ -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<FileSystem>)
{
m_fs = &fs;
}
void set_inode_number(usize inum, Badge<FileSystem>)
{
m_inode_number = inum;
}
Result<SharedPtr<VFS::Inode>> 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;
};
}