1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-30 15:28:11 +00:00

Kernel: Ensure Ext2FSInode's lookup is populated before using it

This fixes #8133.

Ext2FSInode::remove_child() searches the lookup cache, so if it's not
initialized, removing the child fails. If the child was a directory,
this led to it being corrupted and having 0 children.

I also added populate_lookup_cache to add_child. I hadn't seen any
bugs there, but if the cache wasn't populated before, adding that
one entry would make it think it was populated, so that would cause
bugs later.
This commit is contained in:
Sam Atkins 2021-06-19 14:12:11 +01:00 committed by Andreas Kling
parent f1ac0b6a5a
commit ab7023dbe5
2 changed files with 15 additions and 9 deletions

View file

@ -59,7 +59,7 @@ private:
virtual KResultOr<int> get_block_address(int) override;
KResult write_directory(Vector<Ext2FSDirectoryEntry>&);
bool populate_lookup_cache() const;
KResult populate_lookup_cache() const;
KResult resize(u64);
KResult write_indirect_block(BlockBasedFS::BlockIndex, Span<BlockBasedFS::BlockIndex>);
KResult grow_doubly_indirect_block(BlockBasedFS::BlockIndex, size_t, Span<BlockBasedFS::BlockIndex>, Vector<BlockBasedFS::BlockIndex>&, unsigned&);