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
commit ab7023dbe5
Notes: sideshowbarker 2024-07-18 11:55:11 +09:00
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&);