From fd1b331b86d53483c05fffb2ef8d4860956936d1 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Wed, 25 Oct 2023 19:34:00 +0300 Subject: [PATCH] Kernel: Ext2FS now uses Ext2Inodes as cached values --- kernel/include/kernel/FS/Ext2/FileSystem.h | 4 ++-- kernel/include/kernel/FS/Ext2/Inode.h | 2 +- kernel/kernel/FS/Ext2/Inode.cpp | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/kernel/include/kernel/FS/Ext2/FileSystem.h b/kernel/include/kernel/FS/Ext2/FileSystem.h index 717394c32c..be6e5bcfeb 100644 --- a/kernel/include/kernel/FS/Ext2/FileSystem.h +++ b/kernel/include/kernel/FS/Ext2/FileSystem.h @@ -69,7 +69,7 @@ namespace Kernel BAN::ErrorOr reserve_free_block(uint32_t primary_bgd); - BAN::HashMap>& inode_cache() { return m_inode_cache; } + BAN::HashMap>& inode_cache() { return m_inode_cache; } const Ext2::Superblock& superblock() const { return m_superblock; } @@ -110,7 +110,7 @@ namespace Kernel BAN::RefPtr m_root_inode; BAN::Vector m_superblock_backups; - BAN::HashMap> m_inode_cache; + BAN::HashMap> m_inode_cache; BlockBufferManager m_buffer_manager; diff --git a/kernel/include/kernel/FS/Ext2/Inode.h b/kernel/include/kernel/FS/Ext2/Inode.h index 10119f2783..943eeb8132 100644 --- a/kernel/include/kernel/FS/Ext2/Inode.h +++ b/kernel/include/kernel/FS/Ext2/Inode.h @@ -53,7 +53,7 @@ namespace Kernel , m_inode(inode) , m_ino(ino) {} - static BAN::ErrorOr> create(Ext2FS&, uint32_t); + static BAN::ErrorOr> create(Ext2FS&, uint32_t); private: Ext2FS& m_fs; diff --git a/kernel/kernel/FS/Ext2/Inode.cpp b/kernel/kernel/FS/Ext2/Inode.cpp index 85d306d281..13ad3e0529 100644 --- a/kernel/kernel/FS/Ext2/Inode.cpp +++ b/kernel/kernel/FS/Ext2/Inode.cpp @@ -21,7 +21,7 @@ namespace Kernel return (m_ino - 1) / m_fs.superblock().blocks_per_group; } - BAN::ErrorOr> Ext2Inode::create(Ext2FS& fs, uint32_t inode_ino) + BAN::ErrorOr> Ext2Inode::create(Ext2FS& fs, uint32_t inode_ino) { if (fs.inode_cache().contains(inode_ino)) return fs.inode_cache()[inode_ino]; @@ -36,7 +36,7 @@ namespace Kernel Ext2Inode* result_ptr = new Ext2Inode(fs, inode, inode_ino); if (result_ptr == nullptr) return BAN::Error::from_errno(ENOMEM); - auto result = BAN::RefPtr::adopt(result_ptr); + auto result = BAN::RefPtr::adopt(result_ptr); TRY(fs.inode_cache().insert(inode_ino, result)); return result; } @@ -589,7 +589,7 @@ needs_new_block: const auto& entry = *(const Ext2::LinkedDirectoryEntry*)entry_addr; BAN::StringView entry_name(entry.name, entry.name_len); if (entry.inode && entry_name == file_name) - return TRY(Ext2Inode::create(m_fs, entry.inode)); + return BAN::RefPtr(TRY(Ext2Inode::create(m_fs, entry.inode))); entry_addr += entry.rec_len; } }