Kernel: Optimize Ext2 disk reads

We used to read whole file until we reached the asked offset.
Now we can calculate the appropriate block and read just the asked data.
This commit is contained in:
Bananymous
2023-03-18 03:47:59 +02:00
parent 1a26a318a4
commit 8236598f9d
2 changed files with 102 additions and 128 deletions

View File

@@ -136,6 +136,8 @@ namespace Kernel
virtual BAN::ErrorOr<BAN::RefPtr<Inode>> directory_find(BAN::StringView) override;
private:
BAN::ErrorOr<uint32_t> data_block_index(uint32_t);
using block_callback_t = BAN::ErrorOr<bool>(*)(const BAN::Vector<uint8_t>&, void*);
BAN::ErrorOr<void> for_each_block(block_callback_t, void*);