cbmimage
Loading...
Searching...
No Matches
block accessor functions

Classes

struct  cbmimage_blockaccessor_s
 cbmimage block accessor data structure More...
 

Typedefs

typedef struct cbmimage_blockaccessor_s cbmimage_blockaccessor
 cbmimage block accessor data structure
 

Functions

cbmimage_blockaccessorcbmimage_blockaccessor_create (cbmimage_fileimage *image, cbmimage_blockaddress block)
 create a block accessor for a specific block
 
cbmimage_blockaccessorcbmimage_blockaccessor_create_from_ts (cbmimage_fileimage *image, uint8_t track, uint8_t sector)
 create a block accessor for a specific T/S
 
cbmimage_blockaccessorcbmimage_blockaccessor_create_from_lba (cbmimage_fileimage *image, uint16_t lba)
 create a block accessor for a specific LBA
 
void cbmimage_blockaccessor_close (cbmimage_blockaccessor *accessor)
 close a block accessor, freeing its resources
 
int cbmimage_blockaccessor_set_to (cbmimage_blockaccessor *accessor, cbmimage_blockaddress block)
 set a block accessor for a specific block
 
int cbmimage_blockaccessor_set_to_ts (cbmimage_blockaccessor *accessor, uint8_t track, uint8_t sector)
 set a block accessor for a specific T/S
 
int cbmimage_blockaccessor_set_to_lba (cbmimage_blockaccessor *accessor, uint16_t lba)
 set a block accessor for a specific LBA
 
int cbmimage_blockaccessor_advance (cbmimage_blockaccessor *accessor)
 advance a block accessor to the next block
 
int cbmimage_blockaccessor_get_next_block (cbmimage_blockaccessor *accessor, cbmimage_blockaddress *block_next)
 get the next block of this accessor if we follow the chain
 
int cbmimage_blockaccessor_follow (cbmimage_blockaccessor *accessor)
 follow the block chain of a block accessor to the next block
 
int cbmimage_i_blockaccessor_release (cbmimage_blockaccessor *accessor)
 

Detailed Description

Typedef Documentation

◆ cbmimage_blockaccessor

cbmimage block accessor data structure

In order to access blocks, this data structure can be used. For small images, it gives back pointers to the in-memory copy of a block.

For bigger images, it accesses the on-disk image and gives a copy of it somewhere in memory.

Function Documentation

◆ cbmimage_blockaccessor_advance()

int cbmimage_blockaccessor_advance ( cbmimage_blockaccessor * accessor)

advance a block accessor to the next block

Parameters
[in]accessorpointer to the block accessor
Returns
  • 0 on success
  • != 0 if an error occurred
Remarks
  • If you want to follow the chain of the block as given by the first two byte, use cbmimage_blockaccessor_follow() instead.
  • The block is changed to the next block on the current track.
  • If it is the last block of this track, the first block of the next track is used.
  • If this is the last block of this image, an error results and no block is returned. In this case, the return value is != 0.

◆ cbmimage_blockaccessor_close()

void cbmimage_blockaccessor_close ( cbmimage_blockaccessor * accessor)

close a block accessor, freeing its resources

Parameters
[in]accessorpointer to the block accessor

◆ cbmimage_blockaccessor_create()

cbmimage_blockaccessor * cbmimage_blockaccessor_create ( cbmimage_fileimage * image,
cbmimage_blockaddress block )

create a block accessor for a specific block

Parameters
[in]imagepointer to the image data
[in]blockthe block address which we want to access
Returns
  • the block accessor structure for this accessor
  • NULL if an error occurred
Remarks

◆ cbmimage_blockaccessor_create_from_lba()

cbmimage_blockaccessor * cbmimage_blockaccessor_create_from_lba ( cbmimage_fileimage * image,
uint16_t lba )

create a block accessor for a specific LBA

Parameters
[in]imagepointer to the image data
[in]lbathe LBA of the block which we want to access
Returns
  • the block accessor structure for this accessor
  • NULL if an error occurred
Remarks

◆ cbmimage_blockaccessor_create_from_ts()

cbmimage_blockaccessor * cbmimage_blockaccessor_create_from_ts ( cbmimage_fileimage * image,
uint8_t track,
uint8_t sector )

create a block accessor for a specific T/S

Parameters
[in]imagepointer to the image data
[in]trackthe track of the block which we want to access
[in]sectorthe sector of the block which we want to access
Returns
  • the block accessor structure for this accessor
  • NULL if an error occurred
Remarks

◆ cbmimage_blockaccessor_follow()

int cbmimage_blockaccessor_follow ( cbmimage_blockaccessor * accessor)

follow the block chain of a block accessor to the next block

Parameters
[in]accessorpointer to the block accessor
Returns
  • 0 on success
  • != 0 if an error occurred
Remarks
  • If order to advance to the next hardware block of this image, use cbmimage_blockaccessor_advance() instead.
  • This function follows the chain of the block as give by the first two byte of the current block.
  • If this is the last block of this chain, return value is != 0. In this case, the accessor cannot be used to access any data anymore.

◆ cbmimage_blockaccessor_get_next_block()

int cbmimage_blockaccessor_get_next_block ( cbmimage_blockaccessor * accessor,
cbmimage_blockaddress * block_next )

get the next block of this accessor if we follow the chain

Parameters
[in]accessorpointer to the block accessor
[in,out]block_nextpointer to a valid block address. On termination, it will contain the next block address.
Returns
  • 0 on success
  • > 0: this is the last block, the return gives the number of valid byte in this block. This is, if the link of this last block is (0,x), it will return the value x.
  • -1 if an error occurred
Remarks
  • If this is the last block of this chain, return value is != 0. In this case, the parameter block is not modified.

◆ cbmimage_blockaccessor_set_to()

int cbmimage_blockaccessor_set_to ( cbmimage_blockaccessor * accessor,
cbmimage_blockaddress block )

set a block accessor for a specific block

Parameters
[in]accessorpointer to the block accessor
[in]blockthe block address which we want to access
Returns
  • 0 on success
  • != 0 if an error occurred

◆ cbmimage_blockaccessor_set_to_lba()

int cbmimage_blockaccessor_set_to_lba ( cbmimage_blockaccessor * accessor,
uint16_t lba )

set a block accessor for a specific LBA

Parameters
[in]accessorpointer to the block accessor
[in]lbathe LBA of the block which we want to access
Returns
  • 0 on success
  • != 0 if an error occurred

◆ cbmimage_blockaccessor_set_to_ts()

int cbmimage_blockaccessor_set_to_ts ( cbmimage_blockaccessor * accessor,
uint8_t track,
uint8_t sector )

set a block accessor for a specific T/S

Parameters
[in]accessorpointer to the block accessor
[in]trackthe track of the block which we want to access
[in]sectorthe sector of the block which we want to access
Returns
  • 0 on success
  • != 0 if an error occurred

◆ cbmimage_i_blockaccessor_release()

int cbmimage_i_blockaccessor_release ( cbmimage_blockaccessor * accessor)

release a block accessor, allowing to re-use it or to close it

Parameters
[in]accessorpointer to the block accessor
Returns
  • 0 on success
  • != 0 if an error occurred
Remarks
This function releases the block that was accessed by the block accessor. Afterwards, the accessor can be re-used for another block, or it can be closed.