6 #ifndef FS_PARTITION_HPP_
7 #define FS_PARTITION_HPP_
17 FsPartition(
class FsDrive* drive,
int indexOnDrive);
27 class FsDrive* mDrive;
29 uint32_t mFatBeginLba;
30 uint32_t mClusterBeginLba;
31 uint32_t mRootDirFirstCluster;
32 uint32_t mInfoSectorLba;
33 uint32_t mBackupBootSectorLba;
34 uint32_t mInfoFreeClusterCount;
35 uint32_t mInfoNextFreeCluster;
36 uint32_t mClustersCount;
37 uint8_t mSectorsPerCluster;
42 uint32_t getRootClusterLba();
43 uint32_t getFatSectorLba(uint32_t cluster);
44 static uint32_t getFatSectorIndex(uint32_t cluster);
45 uint32_t getClusterBeginLba(uint32_t cluster);
46 uint32_t getClusterFromLba(uint32_t lba);
47 uint32_t getClusterFromFatIndex(uint32_t index);
48 uint32_t getFatIndexFromCluster(uint32_t cluster);
50 FsDefs::RESULT initFromBootSector(FsDefs::BOOT_SECTOR* bootSector, uint32_t partitionBeginLba);
51 FsDefs::RESULT getNextBlockLba(FsDefs::SECTOR* sector, uint32_t* lba);
52 FsDefs::RESULT getNextFreeCluster(FsDefs::SECTOR* sector, uint32_t* cluster);
53 FsDefs::RESULT appendFreeCluster(FsDefs::SECTOR* sector, uint32_t* cluster);
54 FsDefs::RESULT setFatValue(FsDefs::SECTOR* sector, uint32_t cluster, uint32_t value);
55 FsDefs::RESULT writeFatSector(FsDefs::SECTOR* sector, uint32_t cluster);
56 FsDefs::RESULT freeClusterChain(FsDefs::SECTOR* sector, uint32_t cluster);
57 FsDefs::RESULT updateInfo(FsDefs::SECTOR* sector);
59 bool readBlocks(FsDefs::SECTOR* buffer,
unsigned int blockNumber,
unsigned int blockCount);
60 bool writeBlocks(
const FsDefs::SECTOR* buffer,
unsigned int blockNumber,
unsigned int blockCount);