Storage::Disk::HostFileDevice Class Reference

Create custom storage device using backing file. More...

#include <HostFileDevice.h>

Inheritance diagram for Storage::Disk::HostFileDevice:
Collaboration diagram for Storage::Disk::HostFileDevice:

Public Member Functions

 HostFileDevice (const String &name, const String &filename, storage_size_t size)
 Construct a file device with custom size. More...
 
 HostFileDevice (const String &name, const String &filename)
 Construct a device using existing file. More...
 
 ~HostFileDevice ()
 
String getName () const override
 Obtain unique device name. More...
 
Type getType () const override
 Obtain device type. More...
 
- Public Member Functions inherited from Storage::Disk::BlockDevice
bool read (storage_size_t address, void *dst, size_t size) override
 Read data from the storage device. More...
 
bool write (storage_size_t address, const void *src, size_t size) override
 Write data to the storage device. More...
 
bool erase_range (storage_size_t address, storage_size_t size) override
 Erase a region of storage in preparation for writing. More...
 
size_t getBlockSize () const override
 Obtain smallest allocation unit for erase operations. More...
 
storage_size_t getSize () const override
 Obtain addressable size of this device. More...
 
storage_size_t getSectorCount () const override
 Obtain total number of sectors on this device. More...
 
bool sync () override
 Flush any pending writes to the physical media. More...
 
bool allocateBuffers (unsigned numBuffers)
 Set number of sector buffers to use. More...
 
- Public Member Functions inherited from Storage::Device
 Device ()
 
 ~Device ()
 
bool operator== (const String &name) const
 
const PartitionTablepartitions () const
 Provide read-only access to partition table. More...
 
PartitionTableeditablePartitions ()
 Provide full access to partition table. More...
 
bool loadPartitions (uint32_t tableOffset)
 Load partition table entries @tableOffset Location of partition table to read. More...
 
bool loadPartitions (Device &source, uint32_t tableOffset)
 Load partition table entries from another table. More...
 
virtual uint32_t getId () const
 Obtain device ID. More...
 
virtual uint16_t getSectorSize () const
 Get sector size, the unit of allocation for block-access devices. More...
 
size_t printTo (Print &p) const
 
- Public Member Functions inherited from LinkedObjectTemplate< Device >
Device * getNext () const
 
bool insertAfter (Device *object)
 
Iterator begin () const
 
Iterator end () const
 
Iterator cbegin () const
 
Iterator cend () const
 
- Public Member Functions inherited from LinkedObject
virtual ~LinkedObject ()
 
virtual LinkedObjectnext () const
 
bool insertAfter (LinkedObject *object)
 
bool operator== (const LinkedObject &other) const
 
bool operator!= (const LinkedObject &other) const
 

Protected Member Functions

bool raw_sector_read (storage_size_t address, void *dst, size_t size) override
 
bool raw_sector_write (storage_size_t address, const void *src, size_t size) override
 
bool raw_sector_erase_range (storage_size_t address, size_t size) override
 
bool raw_sync () override
 
- Protected Member Functions inherited from Storage::Disk::BlockDevice
bool flushBuffer (Buffer &buf)
 
bool flushBuffers ()
 

Additional Inherited Members

- Public Types inherited from Storage::Device
enum class  Type : uint8_t { partitionType = uint8_t(Partition::Type::storage) , XX }
 Storage type. More...
 
using List = LinkedObjectListTemplate< Device >
 
using OwnedList = OwnedLinkedObjectListTemplate< Device >
 
- Public Types inherited from LinkedObjectTemplate< Device >
using Iterator = IteratorTemplate< Device, Device *, Device & >
 
using ConstIterator = IteratorTemplate< const Device, const Device *, const Device & >
 
- Public Attributes inherited from Storage::Disk::BlockDevice
Stat stat
 
- Static Public Attributes inherited from Storage::Device
static constexpr uint16_t defaultSectorSize {512}
 
- Protected Attributes inherited from Storage::Disk::BlockDevice
std::unique_ptr< BufferListbuffers
 
uint64_t sectorCount {0}
 
uint16_t sectorSize {defaultSectorSize}
 
uint8_t sectorSizeShift {getSizeBits(defaultSectorSize)}
 
- Protected Attributes inherited from Storage::Device
PartitionTable mPartitions
 

Detailed Description

Create custom storage device using backing file.

Constructor & Destructor Documentation

◆ HostFileDevice() [1/2]

Storage::Disk::HostFileDevice::HostFileDevice ( const String name,
const String filename,
storage_size_t  size 
)

Construct a file device with custom size.

Parameters
nameName of device
filenamePath to file
sizeSize of device in bytes

◆ HostFileDevice() [2/2]

Storage::Disk::HostFileDevice::HostFileDevice ( const String name,
const String filename 
)

Construct a device using existing file.

Parameters
nameName of device
filenamePath to file

Device will match size of existing file

◆ ~HostFileDevice()

Storage::Disk::HostFileDevice::~HostFileDevice ( )

Member Function Documentation

◆ getName()

String Storage::Disk::HostFileDevice::getName ( ) const
inlineoverridevirtual

Obtain unique device name.

Implements Storage::Device.

◆ getType()

Type Storage::Disk::HostFileDevice::getType ( ) const
inlineoverridevirtual

Obtain device type.

Implements Storage::Device.

◆ raw_sector_erase_range()

bool Storage::Disk::HostFileDevice::raw_sector_erase_range ( storage_size_t  address,
size_t  size 
)
overrideprotectedvirtual

◆ raw_sector_read()

bool Storage::Disk::HostFileDevice::raw_sector_read ( storage_size_t  address,
void *  dst,
size_t  size 
)
overrideprotectedvirtual

◆ raw_sector_write()

bool Storage::Disk::HostFileDevice::raw_sector_write ( storage_size_t  address,
const void *  src,
size_t  size 
)
overrideprotectedvirtual

◆ raw_sync()

bool Storage::Disk::HostFileDevice::raw_sync ( )
inlineoverrideprotectedvirtual

The documentation for this class was generated from the following file: