From 5edd3161989696eb6d76b0d1b0a3f081ee66d91d Mon Sep 17 00:00:00 2001 From: apio Date: Sat, 25 Feb 2023 17:54:01 +0100 Subject: [PATCH] kernel: Add a subclass of VFS::Inode to make it easier to implement file inodes --- kernel/src/fs/VFS.h | 18 +++++++++++++++++- kernel/src/fs/tmpfs/FileSystem.h | 7 +------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/kernel/src/fs/VFS.h b/kernel/src/fs/VFS.h index ea9a8084..5e5e6387 100644 --- a/kernel/src/fs/VFS.h +++ b/kernel/src/fs/VFS.h @@ -20,7 +20,23 @@ namespace VFS virtual ~Inode() = default; - InodeType type; + virtual InodeType type() const = 0; + }; + + class FileInode : Inode + { + public: + Result find(const char*) const override + { + return err(ENOTDIR); + } + + InodeType type() const override + { + return InodeType::RegularFile; + } + + virtual ~FileInode() = default; }; class FileSystem diff --git a/kernel/src/fs/tmpfs/FileSystem.h b/kernel/src/fs/tmpfs/FileSystem.h index 81a4b996..2b41105f 100644 --- a/kernel/src/fs/tmpfs/FileSystem.h +++ b/kernel/src/fs/tmpfs/FileSystem.h @@ -26,18 +26,13 @@ namespace TmpFS Vector> m_inodes; }; - class Inode : public VFS::Inode + class Inode : public VFS::FileInode { public: Inode(); void set_fs(FileSystem& fs, Badge); - Result find(const char*) const override - { - return err(ENOTSUP); - } - VFS::FileSystem& fs() const override { return *m_fs;