Kernel/Ext2FS: Store the block list as a HashMap rather than a Vector

Since we now only store blocks that are actually allocated, it is
entirely valid for the block list to be empty, so this commit lifts the
restrictions on accessing inodes with an empty block list.
This commit is contained in:
implicitfield
2024-04-19 23:01:52 +04:00
committed by Tim Schumacher
parent ba96a0e4f8
commit 06d4672564
4 changed files with 64 additions and 42 deletions

View File

@@ -619,10 +619,9 @@ ErrorOr<void> Ext2FS::free_inode(Ext2FSInode& inode)
// Mark all blocks used by this inode as free.
{
auto blocks = TRY(inode.compute_block_list_with_meta_blocks());
for (auto block_index : blocks) {
VERIFY(block_index <= super_block().s_blocks_count);
if (block_index.value())
TRY(set_block_allocation_state(block_index, false));
for (auto const& [_, block_index] : blocks) {
VERIFY(block_index <= super_block().s_blocks_count && block_index != 0);
TRY(set_block_allocation_state(block_index, false));
}
}