#pragma once #include #include #include #include #include #include "fs/ext2/ext2.h" /* Simple Wrapper class around the denali client to translate blocks to sectors. * * By necessity contains the Ext Superblock (to make the translation * calculation). * */ class Ext2BlockReader { public: static glcr::ErrorOr> Init( const DenaliInfo& denali_info); // TODO: Consider creating a new class wrapper with these computations. Superblock* GetSuperblock(); uint64_t BlockSize(); uint64_t NumberOfBlockGroups(); uint64_t BgdtBlockNum(); uint64_t BgdtBlockSize(); uint64_t InodeSize(); // FIXME: This probably needs to take into account the block group number // because the last table will likely be smaller. uint64_t InodeTableBlockSize(); glcr::ErrorOr ReadBlock(uint64_t block_number); glcr::ErrorOr ReadBlocks(uint64_t block_number, uint64_t num_blocks); glcr::ErrorOr ReadBlocks( const glcr::Vector& block_list); private: DenaliClient denali_; uint64_t device_id_; uint64_t lba_offset_; mmth::OwnedMemoryRegion super_block_region_; Ext2BlockReader(DenaliClient&& denali, uint64_t device_id, uint64_t lba_offset, mmth::OwnedMemoryRegion&& super_block); uint64_t SectorsPerBlock(); };