Skip to content

File SolidSyslogBlockDevice.h

FileList > Core > Interface > SolidSyslogBlockDevice.h

  • #include "SolidSyslogExternC.h"
  • #include <stdbool.h>
  • #include <stddef.h>

Detailed Description

The block-device role: block-indexed storage (Acquire / Dispose / Exists / Read / Append / WriteAt / Size / GetBlockSize) beneath a BlockStore.

These calls dispatch to the injected device's vtable, so behaviour is that device's.

Public Functions Documentation

SolidSyslogBlockDevice_Acquire

Make blockIndex ready for fresh writes, leaving it empty (file drivers create-or-truncate, flash drivers erase).

bool SolidSyslogBlockDevice_Acquire (
    struct SolidSyslogBlockDevice * device,
    size_t blockIndex
) 

Not for a block whose content is to be kept: use Exists + Size to detect and resume a populated block.

Return value:

  • false the block could not be made ready; the caller does not write to it.

SolidSyslogBlockDevice_Append

Write count bytes frombuf at the current end ofblockIndex , growing it.

bool SolidSyslogBlockDevice_Append (
    struct SolidSyslogBlockDevice * device,
    size_t blockIndex,
    const void * buf,
    size_t count
) 

Records are laid down with Append; the offset is implicit. Contrast WriteAt.

Return value:

  • false the bytes were not stored.

SolidSyslogBlockDevice_Dispose

Release blockIndex , freeing its storage (file drivers delete the backing file).

bool SolidSyslogBlockDevice_Dispose (
    struct SolidSyslogBlockDevice * device,
    size_t blockIndex
) 

Return value:

  • false the block could not be released; the caller does not treat it as gone (a stale block must be Disposed before it is Acquired again for reuse).

SolidSyslogBlockDevice_Exists

bool SolidSyslogBlockDevice_Exists (
    struct SolidSyslogBlockDevice * device,
    size_t blockIndex
) 

Return value:

  • true blockIndex is present (Acquired and not yet Disposed). Drives crash recovery: a BlockStore scans the index space with Exists to find the run of blocks left by a previous run before deciding where to resume.

SolidSyslogBlockDevice_GetBlockSize

The device-wide per-block capacity in bytes: how large each block may grow.

size_t SolidSyslogBlockDevice_GetBlockSize (
    struct SolidSyslogBlockDevice * device
) 

Distinct from Size(blockIndex), the current occupancy of one block. The device is the single source of truth; a BlockStore reads this at construction rather than taking a separately configured size. Fixed for the device's lifetime.


SolidSyslogBlockDevice_Read

Read count bytes fromblockIndex starting atoffset into caller-ownedbuf .

bool SolidSyslogBlockDevice_Read (
    struct SolidSyslogBlockDevice * device,
    size_t blockIndex,
    size_t offset,
    void * buf,
    size_t count
) 

Return value:

  • false nothing usable was read (missing block or short read); buf is undefined.

SolidSyslogBlockDevice_Size

Current occupancy of blockIndex in bytes: how far Append has filled it, and the offset at which the next Append lands.

size_t SolidSyslogBlockDevice_Size (
    struct SolidSyslogBlockDevice * device,
    size_t blockIndex
) 

Contrast GetBlockSize (the fixed capacity).

Return value:

  • 0 the block is empty or absent.

SolidSyslogBlockDevice_WriteAt

Overwrite count bytes atoffset withinblockIndex frombuf , in place.

bool SolidSyslogBlockDevice_WriteAt (
    struct SolidSyslogBlockDevice * device,
    size_t blockIndex,
    size_t offset,
    const void * buf,
    size_t count
) 

Used to patch bytes already present (e.g. flip a stored record's sent flag), not to extend the block. Contrast Append.

Return value:

  • false the bytes were not stored.


The documentation for this class was generated from the following file Core/Interface/SolidSyslogBlockDevice.h