kernel: Add a subclass of VFS::Inode to make it easier to implement file inodes

This commit is contained in:
apio 2023-02-25 17:54:01 +01:00
parent 045efc7046
commit 5edd316198
Signed by: apio
GPG Key ID: B8A7D06E42258954
2 changed files with 18 additions and 7 deletions

View File

@ -20,7 +20,23 @@ namespace VFS
virtual ~Inode() = default;
InodeType type;
virtual InodeType type() const = 0;
};
class FileInode : Inode
{
public:
Result<Inode*> find(const char*) const override
{
return err(ENOTDIR);
}
InodeType type() const override
{
return InodeType::RegularFile;
}
virtual ~FileInode() = default;
};
class FileSystem

View File

@ -26,18 +26,13 @@ namespace TmpFS
Vector<SharedPtr<VFS::Inode>> m_inodes;
};
class Inode : public VFS::Inode
class Inode : public VFS::FileInode
{
public:
Inode();
void set_fs(FileSystem& fs, Badge<FileSystem>);
Result<VFS::Inode*> find(const char*) const override
{
return err(ENOTSUP);
}
VFS::FileSystem& fs() const override
{
return *m_fs;