The structure of block could be(data field not included):
#pragma pack(push)
#pragma pack(2) // Make sure the data aligning at 2bytes boundary
typedef struct {
u128 key;
u32 cookie;
u16 tag;
u16 flag;
u32 size;
u32 checkSum;
} block_info_t;
#pragma pack(pop)
And the element of index hash looks like:
typedef struct {
u128 key;
u32 cookie;
u16 tag;
u16 flag;
u32 size;
u64 pos;
} block_index_value_t;
using blk_idx_val_t = block_index_value_t;
using block_index_map_t = unordered_map<std::string, blk_idx_val_t>;
using bidx_map_t = block_index_map_t;
Some crucial constants:
const u32 MAX_ERROR = 128; /*!< Max errors can be tolerated. */
const size_t PARSE_QUEUE_LEN = 8192; /*!< Quele length for paseing blocks. */
const size_t READ_BUFFER_SIZE = 128 * 1024 * 1024; /*!< Read buffer size. */
const static bfs::fstream::openmode FILE_MODE= bfs::fstream::in | bfs::fstream::out | bfs::fstream::binary; /*!< Default open mode for volume. */
// File magic numbers
static const u64 MAGIC_NUM_VOLUME = 0x6b63617453796148; //!< Magic number of volume, equals { 'H', 'a', 'y', 'S', 't', 'a', 'c', 'k' };
static const u32 MAGIC_NUM_HEADER = 0x53796148; //!< Magic number of block header, equals { 'H', 'a', 'y', 'S' };
static const u32 MAGIC_NUM_FOOTER = 0x6b636174; //!< Magic number of block footer, equals { 't', 'a', 'c', 'k' };
const u16 FLAG_NORMAL = 0x0000; //!< Flag value for normal block.
const u16 FLAG_REMOVE = 0x0001; //!< Falg value for deleted block.
const u8 PADDING_VALUE[7] = { 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC }; //!< Bytes for padding filling.