From ad5d217e760c7fb73ffc0c4c827d767d6be8ec80 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 10 Nov 2021 23:11:27 +0100 Subject: [PATCH] Kernel/Ext2FS: Propagate HashMap errors instead of panicking --- Kernel/FileSystem/Ext2FileSystem.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp index 3ee5a887c26..ae3be58d914 100644 --- a/Kernel/FileSystem/Ext2FileSystem.cpp +++ b/Kernel/FileSystem/Ext2FileSystem.cpp @@ -810,7 +810,7 @@ ErrorOr> Ext2FS::get_inode(InodeIdentifier inode) const auto inode_allocation_state = TRY(get_inode_allocation_state(inode.index())); if (!inode_allocation_state) { - m_inode_cache.set(inode.index(), nullptr); + TRY(m_inode_cache.try_set(inode.index(), nullptr)); return ENOENT; } @@ -824,7 +824,7 @@ ErrorOr> Ext2FS::get_inode(InodeIdentifier inode) const auto buffer = UserOrKernelBuffer::for_kernel_buffer(reinterpret_cast(&new_inode->m_raw_inode)); TRY(read_block(block_index, &buffer, sizeof(ext2_inode), offset)); - m_inode_cache.set(inode.index(), new_inode); + TRY(m_inode_cache.try_set(inode.index(), new_inode)); return new_inode; } @@ -1184,7 +1184,7 @@ ErrorOr Ext2FSInode::add_child(Inode& child, const StringView& name, mode_ TRY(write_directory(entries)); TRY(populate_lookup_cache()); - m_lookup_cache.set(name, child.index()); + TRY(m_lookup_cache.try_set(name, child.index())); did_add_child(child.identifier(), name); return {}; } @@ -1536,7 +1536,7 @@ ErrorOr Ext2FSInode::populate_lookup_cache() const HashMap children; TRY(traverse_as_directory([&children](auto& entry) -> ErrorOr { - children.set(entry.name, entry.inode.index()); + TRY(children.try_set(entry.name, entry.inode.index())); return {}; }));