diff --git a/kernel/include/kernel/FS/RamFS/Inode.h b/kernel/include/kernel/FS/RamFS/Inode.h index 6119a409..7cefae9c 100644 --- a/kernel/include/kernel/FS/RamFS/Inode.h +++ b/kernel/include/kernel/FS/RamFS/Inode.h @@ -96,6 +96,7 @@ namespace Kernel virtual BAN::ErrorOr> find_inode_impl(BAN::StringView) override; virtual BAN::ErrorOr list_next_inodes_impl(off_t, DirectoryEntryList*, size_t) override; virtual BAN::ErrorOr create_file_impl(BAN::StringView, mode_t, uid_t, gid_t) override; + virtual BAN::ErrorOr create_directory_impl(BAN::StringView, mode_t, uid_t, gid_t) override; virtual BAN::ErrorOr delete_inode_impl(BAN::StringView) override; private: diff --git a/kernel/kernel/FS/RamFS/Inode.cpp b/kernel/kernel/FS/RamFS/Inode.cpp index 5c0f0231..c1e034b8 100644 --- a/kernel/kernel/FS/RamFS/Inode.cpp +++ b/kernel/kernel/FS/RamFS/Inode.cpp @@ -202,16 +202,23 @@ namespace Kernel BAN::RefPtr inode; if (Mode(mode).ifreg()) inode = TRY(RamFileInode::create(m_fs, mode & ~Inode::Mode::TYPE_MASK, uid, gid)); - else if (Mode(mode).ifdir()) - inode = TRY(RamDirectoryInode::create(m_fs, ino(), mode & ~Inode::Mode::TYPE_MASK, uid, gid)); else - ASSERT_NOT_REACHED(); + return BAN::Error::from_errno(ENOTSUP); TRY(add_inode(name, inode)); return {}; } + BAN::ErrorOr RamDirectoryInode::create_directory_impl(BAN::StringView name, mode_t mode, uid_t uid, gid_t gid) + { + if (!Mode(mode).ifdir()) + return BAN::Error::from_errno(EINVAL); + auto inode = TRY(RamDirectoryInode::create(m_fs, ino(), mode & ~Inode::Mode::TYPE_MASK, uid, gid)); + TRY(add_inode(name, inode)); + return {}; + } + static uint8_t get_type(Inode::Mode mode) { if (mode.ifreg())