Storage::Disk Namespace Reference

Namespaces

 EXFAT
 
 FAT
 
 GPT
 
 MBR
 

Classes

class  BlockDevice
 Base class for sector-addressable (block) devices. More...
 
struct  Buffer
 
class  BufferList
 
class  HostFileDevice
 Create custom storage device using backing file. More...
 
struct  DiskPart
 Adds information specific to MBR/GPT disk partitions. More...
 
struct  PartInfo
 In-memory partition information. More...
 
class  BasePartitionTable
 Common type for MBR/GPT partition table. More...
 
class  Scanner
 Class to iterate through disk partition tables. More...
 
class  SectorBuffer
 Buffer for working with disk sectors. More...
 

Typedefs

using SysTypes = BitSet< uint8_t, SysType >
 

Enumerations

enum class  Error { XX }
 
enum class  SysType : uint8_t {
  unknown , fat12 , fat16 , fat32 ,
  exfat
}
 Identifies exact disk volume type. More...
 
enum  SysIndicator {
  SI_FAT12 = 0x01 , SI_FAT16 = 0x04 , SI_FAT16B = 0x06 , SI_IFS = 0x07 ,
  SI_EXFAT = 0x07 , SI_FAT32X = 0x0c
}
 MBR partition system type indicator values. More...
 

Functions

template<typename T >
align_up (T value, uint32_t align)
 
template<typename T >
auto getBlockCount (T byteCount, uint32_t blockSize)
 
uint32_t crc32_byte (uint32_t crc, uint8_t d)
 
uint32_t crc32 (uint32_t bcc, const void *data, size_t length)
 
uint32_t crc32 (const void *data, size_t length)
 
bool operator! (Error err)
 
Error formatDisk (BlockDevice &device, GPT::PartitionTable &table, const Uuid &diskGuid={})
 Partition a device using the GPT scheme. More...
 
Error formatDisk (BlockDevice &device, MBR::PartitionTable &table)
 Partition a device using the MBR scheme. More...
 
SysType getSysTypeFromIndicator (SysIndicator si)
 
Error validate (BasePartitionTable &table, storage_size_t firstAvailableBlock, storage_size_t totalAvailableBlocks, uint32_t blockSize)
 Validate partition table entries. More...
 
bool scanPartitions (Device &device)
 

Variables

constexpr uint32_t PARTITION_ALIGN {0x100000U}
 
static constexpr SysTypes fatTypes = SysType::fat12 | SysType::fat16 | SysType::fat32 | SysType::exfat
 

Typedef Documentation

◆ SysTypes

using Storage::Disk::SysTypes = typedef BitSet<uint8_t, SysType>

Enumeration Type Documentation

◆ Error

enum Storage::Disk::Error
strong
Enumerator
XX 

◆ SysIndicator

MBR partition system type indicator values.

See also
https://en.wikipedia.org/wiki/Partition_type#List_of_partition_IDs
Enumerator
SI_FAT12 
SI_FAT16 

FAT16 with fewer than 65536 sectors.

SI_FAT16B 

FAT16B with 65536 or more sectors.

SI_IFS 
SI_EXFAT 
SI_FAT32X 

FAT32 with LBA.

◆ SysType

enum Storage::Disk::SysType : uint8_t
strong

Identifies exact disk volume type.

Enumerator
unknown 

Partition type not recognised.

fat12 
fat16 
fat32 
exfat 

Function Documentation

◆ align_up()

template<typename T >
T Storage::Disk::align_up ( value,
uint32_t  align 
)

◆ crc32() [1/2]

uint32_t Storage::Disk::crc32 ( const void *  data,
size_t  length 
)
inline

◆ crc32() [2/2]

uint32_t Storage::Disk::crc32 ( uint32_t  bcc,
const void *  data,
size_t  length 
)

◆ crc32_byte()

uint32_t Storage::Disk::crc32_byte ( uint32_t  crc,
uint8_t  d 
)

◆ formatDisk() [1/2]

Error Storage::Disk::formatDisk ( BlockDevice device,
GPT::PartitionTable table,
const Uuid diskGuid = {} 
)

Partition a device using the GPT scheme.

Parameters
device
tablePartitions to create
Return values
Error

◆ formatDisk() [2/2]

Error Storage::Disk::formatDisk ( BlockDevice device,
MBR::PartitionTable table 
)

Partition a device using the MBR scheme.

Parameters
device
tablePartitions to create
Return values
Error

◆ getBlockCount()

template<typename T >
auto Storage::Disk::getBlockCount ( byteCount,
uint32_t  blockSize 
)

◆ getSysTypeFromIndicator()

SysType Storage::Disk::getSysTypeFromIndicator ( SysIndicator  si)
inline

◆ operator!()

bool Storage::Disk::operator! ( Error  err)
inline

◆ scanPartitions()

bool Storage::Disk::scanPartitions ( Device device)

◆ validate()

Error Storage::Disk::validate ( BasePartitionTable table,
storage_size_t  firstAvailableBlock,
storage_size_t  totalAvailableBlocks,
uint32_t  blockSize 
)

Validate partition table entries.

Parameters
firstAvailableBlockFirst block number which may be allocated to a partition
totalAvailableBlocksNumber of blocks available for partition allocation
blockSizeSize of a block
Return values
ErrorFor each partition:
  • If size <= 100 then the actual size is calculated as a percentage and updated
  • If offset = 0 then a suitable location is found and the offset updated

On success, partition entries are ordered by position.

Variable Documentation

◆ fatTypes

constexpr SysTypes Storage::Disk::fatTypes = SysType::fat12 | SysType::fat16 | SysType::fat32 | SysType::exfat
staticconstexpr

◆ PARTITION_ALIGN

constexpr uint32_t Storage::Disk::PARTITION_ALIGN {0x100000U}
constexpr