class FakeBlockDevice

Defined at line 35 of file ../../src/storage/lib/block_client/cpp/fake_block_device.h

A fake device implementing (most of) the BlockDevice interface on top of an in-memory VMO

representing the device. This allows clients of the BlockDevice interface to test against this

fake in-process instead of relying on a real block device.

This device also supports pausing processing FIFO transactions to allow tests to emulate slow

devices or validate behavior in intermediate states.

This class is thread-safe.

This class is not movable or copyable.

Public Methods

void FakeBlockDevice (const Config & )

Defined at line 20 of file ../../src/storage/lib/block_client/cpp/fake_block_device.cc

zx::result<zx::vmo> VmoChildReference ()

Returns a VMO child reference of the block device.

Defined at line 32 of file ../../src/storage/lib/block_client/cpp/fake_block_device.cc

void Pause ()

When paused, this device will make FIFO operations block until Resume() is called. The device

is in the Resume() state by default.

Defined at line 42 of file ../../src/storage/lib/block_client/cpp/fake_block_device.cc

void FakeBlockDevice (uint64_t block_count, uint32_t block_size)

Defined at line 44 of file ../../src/storage/lib/block_client/cpp/fake_block_device.h

void FakeBlockDevice (const FakeBlockDevice & )

Defined at line 46 of file ../../src/storage/lib/block_client/cpp/fake_block_device.h

FakeBlockDevice & operator= (const FakeBlockDevice & )

Defined at line 47 of file ../../src/storage/lib/block_client/cpp/fake_block_device.h

void Resume ()

Defined at line 47 of file ../../src/storage/lib/block_client/cpp/fake_block_device.cc

void FakeBlockDevice (FakeBlockDevice && other)

Defined at line 48 of file ../../src/storage/lib/block_client/cpp/fake_block_device.h

FakeBlockDevice & operator= (FakeBlockDevice && other)

Defined at line 49 of file ../../src/storage/lib/block_client/cpp/fake_block_device.h

void ~FakeBlockDevice ()

Defined at line 51 of file ../../src/storage/lib/block_client/cpp/fake_block_device.h

void SetWriteBlockLimit (uint64_t limit)

Sets the number of blocks which may be written to the block device. Once |limit| is reached,

all following operations will return ZX_ERR_IO.

May be "std::nullopt" to allow an unlimited count of blocks.

Defined at line 53 of file ../../src/storage/lib/block_client/cpp/fake_block_device.cc

void ResetWriteBlockLimit ()

Turns off the "write block limit".

Defined at line 58 of file ../../src/storage/lib/block_client/cpp/fake_block_device.cc

uint64_t GetWriteBlockCount ()

Defined at line 63 of file ../../src/storage/lib/block_client/cpp/fake_block_device.cc

void set_hook (Hook hook)

Defined at line 64 of file ../../src/storage/lib/block_client/cpp/fake_block_device.h

void ResetBlockCounts ()

Defined at line 68 of file ../../src/storage/lib/block_client/cpp/fake_block_device.cc

void SetInfoFlags (fuchsia_storage_block::wire::DeviceFlag flags)

Defined at line 73 of file ../../src/storage/lib/block_client/cpp/fake_block_device.cc

void SetBlockCount (uint64_t block_count)

Defined at line 78 of file ../../src/storage/lib/block_client/cpp/fake_block_device.cc

void SetBlockSize (uint32_t block_size)

Defined at line 84 of file ../../src/storage/lib/block_client/cpp/fake_block_device.cc

zx::result<std::string> GetTopologicalPath ()

Defined at line 90 of file ../../src/storage/lib/block_client/cpp/fake_block_device.h

bool IsRegistered (vmoid_t vmoid)

Defined at line 90 of file ../../src/storage/lib/block_client/cpp/fake_block_device.cc

zx::result<> Rebind (std::string_view url_suffix)

Defined at line 94 of file ../../src/storage/lib/block_client/cpp/fake_block_device.h

zx_status_t VolumeGetInfo (fuchsia_storage_block::wire::VolumeManagerInfo * out_manager_info, fuchsia_storage_block::wire::VolumeInfo * out_volume_info)

Defined at line 98 of file ../../src/storage/lib/block_client/cpp/fake_block_device.h

zx_status_t VolumeQuerySlices (const uint64_t * slices, size_t slices_count, fuchsia_storage_block::wire::VsliceRange * out_ranges, size_t * out_ranges_count)

Defined at line 104 of file ../../src/storage/lib/block_client/cpp/fake_block_device.h

zx_status_t VolumeExtend (uint64_t offset, uint64_t length)

Defined at line 110 of file ../../src/storage/lib/block_client/cpp/fake_block_device.h

zx_status_t VolumeShrink (uint64_t offset, uint64_t length)

Defined at line 114 of file ../../src/storage/lib/block_client/cpp/fake_block_device.h

void Wipe ()

Wipes the device to a zeroed state.

Defined at line 215 of file ../../src/storage/lib/block_client/cpp/fake_block_device.cc

zx_status_t FifoTransaction (BlockFifoRequest * requests, size_t count)

Defined at line 113 of file ../../src/storage/lib/block_client/cpp/fake_block_device.cc

zx_status_t BlockGetInfo (fuchsia_storage_block::wire::BlockInfo * out_info)

Defined at line 206 of file ../../src/storage/lib/block_client/cpp/fake_block_device.cc

zx_status_t BlockAttachVmo (const zx::vmo & vmo, storage::Vmoid * out_vmoid)

Defined at line 221 of file ../../src/storage/lib/block_client/cpp/fake_block_device.cc

Protected Methods

void ResizeDeviceToAtLeast (uint64_t new_size)

Resizes the block device to be at least |new_size| bytes.

Defined at line 95 of file ../../src/storage/lib/block_client/cpp/fake_block_device.cc

Records