cbmimage
Loading...
Searching...
No Matches
Function to validate a disk

Functions

static int cbmimage_i_d1m_d2m_d4m_set_bam (cbmimage_image_settings *settings)
 occupy the blocks for the partition table of a CMD disk
 
static int cbmimage_i_mark_global_and_local (cbmimage_fileimage *image, cbmimage_loop *loop_detector, cbmimage_blockaddress block_start, cbmimage_blockaddress block_current, cbmimage_blockaddress block_target)
 
static int cbmimage_i_validate_follow_chain (cbmimage_fileimage *image, cbmimage_blockaddress block_start, size_t *count_blocks)
 
int cbmimage_i_validate_1581_partition (cbmimage_fileimage *image, cbmimage_blockaddress block_start, int count)
 
static int cbmimage_i_bam_check_equality (cbmimage_fileimage *image)
 
static int cbmimage_i_validate_super_sidesector_plausibility (cbmimage_chain *chain)
 
static int cbmimage_i_validate_super_sidesector_end (cbmimage_chain *chain, uint8_t offset)
 
static int cbmimage_i_validate_sidesector_plausibility (cbmimage_chain *chain_sidesector, uint8_t *first_sidesector, uint8_t count_sidesector, int recordlength)
 
static int cbmimage_i_validate_sidesector_chain (cbmimage_chain *chain_sidesector, cbmimage_chain *chain_file)
 
static int cbmimage_i_validate_rel_file (cbmimage_fileimage *image, cbmimage_dir_entry *dir_entry, size_t *count_blocks)
 
static int cbmimage_i_validate_geos_file (cbmimage_fileimage *image, cbmimage_dir_entry *dir_entry, size_t *count_blocks)
 
int cbmimage_i_validate_process_file (cbmimage_fileimage *image, cbmimage_dir_entry *dir_entry)
 validate a specific file
 
int cbmimage_validate (cbmimage_fileimage *image)
 validate the disk (and the bam)
 

Detailed Description

Function Documentation

◆ cbmimage_i_bam_check_equality()

static int cbmimage_i_bam_check_equality ( cbmimage_fileimage * image)
static

check if the loop detector and the BAM are identical

Parameters
[in]imagepointer to the image data
Returns
  • 0 if the BAM and the loop detector are identical
  • != 0 if not
Remarks
  • this function goes through all blocks and tests if the BAM is free and not marked in the loop detector, or not free and marked in the loop detector. If there is an unequality, it reports an error.

◆ cbmimage_i_d1m_d2m_d4m_set_bam()

static int cbmimage_i_d1m_d2m_d4m_set_bam ( cbmimage_image_settings * settings)
static

occupy the blocks for the partition table of a CMD disk

Parameters
[in]settingspointer to the image data
Returns
  • 0 if no error occurred
  • != 0 if an error occurred
Remarks
  • special handling for validating D1M, D2M and D4M partition tables
  • the blocks of a partition are treated as single file

◆ cbmimage_i_mark_global_and_local()

static int cbmimage_i_mark_global_and_local ( cbmimage_fileimage * image,
cbmimage_loop * loop_detector,
cbmimage_blockaddress block_start,
cbmimage_blockaddress block_current,
cbmimage_blockaddress block_target )
static

mark blocks as used

This function marks a block in to loop detectors.

There is a first, global loop detector. It is used to find out if files (or other link chains) "overlap" each other, that is, one link chain and another link chain end in the same blocks. Thus, it is not really a loop, but some chain error that is detected.

The second, local loop detector, is used to find out if a link chain has an intertial loop. This loop detector has to be newly initialized for each link chain.

Parameters
[in]imagepointer to the image data
[in]loop_detectorpointer to the local loop detector
[in]block_startThe starting block of this chain. This data is not used internally. It is helpful in the output, telling what went wrong and where a loop was detected.
[in]block_currentThe current block of this chain. This block is marked as used.
[in]block_targetThe next block/the target of the current block in this chain. This block is set as target for the current block
Returns
  • 0 if there is no loop or sharing of links.
  • != 0 if not

◆ cbmimage_i_validate_1581_partition()

int cbmimage_i_validate_1581_partition ( cbmimage_fileimage * image,
cbmimage_blockaddress block_start,
int count )

check a 1581 partition

A 1581 partition is just a contiguous area of the disk, without any implied structure.
Thus, this function just marks all the blocks in the partition, nothing more.

Parameters
[in]imagepointer to the image data
[in]block_startThe starting block of this partion. From this block, the chain is followed and all blocks are marked as used.
[in]countThe count of blocks that are occupied by this partition
Returns
  • 0 if everything is ok
  • != 0 if not

◆ cbmimage_i_validate_follow_chain()

static int cbmimage_i_validate_follow_chain ( cbmimage_fileimage * image,
cbmimage_blockaddress block_start,
size_t * count_blocks )
static

follow a chain and check if it is consistent

This function follows a link chain. Doing this, it determines if there is a loop, or if this link chain shares blocks with another link chain. If any of this occurrs, this function reports an error.

Parameters
[in]imagepointer to the image data
[in]block_startThe starting block of this chain. From this block, the chain is followed and all blocks are marked as used.
[in,out]count_blocksPointer to a variable. On return, this function will add the number of blocks it followed in the chain.
Can be NULL; in this case, nothing will be returned.
Returns
  • 0 if there is no loop or sharing of links.
  • != 0 if not

◆ cbmimage_i_validate_geos_file()

static int cbmimage_i_validate_geos_file ( cbmimage_fileimage * image,
cbmimage_dir_entry * dir_entry,
size_t * count_blocks )
static

validate the specialities of a GEOS file

This functions checks that the info block and the chains from the VLIR table (if it is a VLIR file) do not share blocks with other files or structures.

Parameters
[in]imagepointer to the image data
[in]dir_entryThe directory entry of this file
[in,out]count_blocksPointer to a variable. On return, this function will add the number of blocks it followed in the chain.
Can be NULL; in this case, nothing will be returned.
Returns
  • 0 if there is no loop or sharing of links.
  • != 0 if not

◆ cbmimage_i_validate_process_file()

int cbmimage_i_validate_process_file ( cbmimage_fileimage * image,
cbmimage_dir_entry * dir_entry )

validate a specific file

Parameters
[in]imagepointer to the image data
[in]dir_entrypointer to the directory entry of the file to validate
Returns
  • 0 if the file is consistent
  • != 0 if not
Remarks
A file is consistent if the following applies:
  • the file chain does not conflict with any other file chain that was processed before this file
Todo
implement GEOS support
Bug
GEOS is not supported yet!
Todo
implement CMD native partition
Todo
Bug
CMD native partition not yet implemented

◆ cbmimage_i_validate_rel_file()

static int cbmimage_i_validate_rel_file ( cbmimage_fileimage * image,
cbmimage_dir_entry * dir_entry,
size_t * count_blocks )
static

validate the side sector block of a REL file

This function checks if the link chain of a REL file is represented correctly by the side-sector block(s) of it.

Additionally, it also checks if the side-sector blocks are consistent and do not share blocks with other files or structures.

Parameters
[in]imagepointer to the image data
[in]dir_entryThe directory entry of this file
[in,out]count_blocksPointer to a variable. On return, this function will add the number of blocks it followed in the chain.
Can be NULL; in this case, nothing will be returned.
Returns
  • 0 if there is no loop or sharing of links.
  • != 0 if not

◆ cbmimage_i_validate_sidesector_chain()

static int cbmimage_i_validate_sidesector_chain ( cbmimage_chain * chain_sidesector,
cbmimage_chain * chain_file )
static

validate the side-sector chain

Parameters
[in]chain_sidesectorpointer to a link chain that points to the side-sector
[in]chain_filepointer to a link chain that points to the file contents
Returns
  • 0 if the side-sector chain is correct
  • != 0 if not
Remarks
This function goes through all the links in the side-sector block and checks that it matches the corresponding block in the file chain.

◆ cbmimage_i_validate_sidesector_plausibility()

static int cbmimage_i_validate_sidesector_plausibility ( cbmimage_chain * chain_sidesector,
uint8_t * first_sidesector,
uint8_t count_sidesector,
int recordlength )
static

check plausibility of a (non-super) side-sector

Parameters
[in]chain_sidesectorpointer to a link chain that points to the side-sector
[in]first_sidesectorpointer to a buffer that contains the data of the first side-sector in this side-sector group
[in]count_sidesectorthe number of this side-sector
[in]recordlength
Returns
  • 0 if the side-sector is plausible
  • != 0 if not
Remarks
The side-sector is plausible if the following applies:
  • the addresses of all side-sectors in this side-sector group are identical to the first side-sector of this group.
  • the address of this side-sector is at the right place
  • the recordlength is the same as the record-length in the directory

◆ cbmimage_i_validate_super_sidesector_end()

static int cbmimage_i_validate_super_sidesector_end ( cbmimage_chain * chain,
uint8_t offset )
static

check if the super side-sector does not contain extra data

Parameters
[in]chainpointer to a link chain that points to the super side-sector
[in]offsetthe offset from which to check if the super side-sector is empty
Returns
  • 0 if the super side-sector is empty after the offset
  • != 0 if not

◆ cbmimage_i_validate_super_sidesector_plausibility()

static int cbmimage_i_validate_super_sidesector_plausibility ( cbmimage_chain * chain)
static

check plausibility of a super side-sector

Parameters
[in]chainpointer to a link chain that points to the super side-sector
Returns
  • 0 if the super side-sector is plausible
  • != 0 if not
Remarks
The super side-sector is plausible if the following applies:
  • the link chain and the first side-sector group are identical
  • the number of the side-sector block is 0xFE.

◆ cbmimage_validate()

int cbmimage_validate ( cbmimage_fileimage * image)

validate the disk (and the bam)

Parameters
[in]imagepointer to the image data
Returns
  • 0 if the BAM is consistent
  • != 0 if not
Remarks
A BAM is consistent if the following applies:
Todo
How should details be given to the caller?
Todo
Implement GEOS support
Bug
GEOS is not supported yet!