logo.gif (6996 bytes)
Block header

Block header

Below is the standard block header. This header is found before EVERY type of block used in the filesystem, except data blocks.  The id field is used to check if the block is of the correct type when it is being referred to using a BLCK pointer.   The checksum field is the SUM of all LONGs in a block plus one, and then negated. When applying a checksum the checksum field itself should be set to zero. The checking a checksum the checksum is okay if the result of the checksum equals zero.  The ownblock BLCK pointer points to the block itself. This field is an extra safety check to ensure we are using a valid block.

Field Type Description
id ULONG The id field is used to identify the type of block we are dealing with.   It is used to make sure that when referencing a block we got a block of the correct type.  The id consist of 4 bytes and each blocktype has its own unique foure letter code.
checksum ULONG This field contains the sum of all longs in this block, plus one and then negated.  The checksum can be used to check if the block hasn't been corrupted in any way.
ownblock BLCK Points to itself, or in other words, this field contains the block number of this block.  This is yet another way to check whether or not a block is valid.
struct fsBlockHeader {
    ULONG id;
    ULONG checksum;
    BLCK ownblock;

The algorithm to calculate the checksum of a block:

ULONG calcchecksum(struct fsBlockHeader *block, LONG blocksize} {
    ULONG *data=(ULONG *)block;
    ULONG checksum=1;


    while(blocksize>0) {


All rights reserved.
For comments, problems or questions regarding this page contact John Hendrikx.
Last updated: 17 oktober 1998.