[victoriafalls] Move a superblock-based calculations to the block reader

This commit is contained in:
Drew Galbraith 2023-07-06 09:58:26 -07:00
parent 52b4b273b7
commit 150bfd2fd4
5 changed files with 60 additions and 34 deletions

View file

@ -6,12 +6,25 @@
#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<Ext2BlockReader> Init(ScopedDenaliClient&& denali);
// TODO: Consider creating a new class wrapper with these computations.
Superblock* GetSuperblock();
uint64_t SectorsPerBlock();
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<MappedMemoryRegion> ReadBlock(uint64_t block_number);
glcr::ErrorOr<MappedMemoryRegion> ReadBlocks(uint64_t block_number,
@ -22,4 +35,6 @@ class Ext2BlockReader {
MappedMemoryRegion super_block_region_;
Ext2BlockReader(ScopedDenaliClient&& denali, MappedMemoryRegion super_block);
uint64_t SectorsPerBlock();
};