int startBlock = 1 + burnedBlocksBeforeVH;
int blockCount = (int) bitmapBlocks;
HfsPlusForkData forkdata =
new HfsPlusForkData(CatalogNodeId.HFSPLUS_ALLOC_CNID, allocationClumpSize, (int) allocationClumpSize,
(int) bitmapBlocks);
ExtentDescriptor desc = new ExtentDescriptor(startBlock, blockCount);
forkdata.addDescriptor(0, desc);
forkdata.write(data, 112);
// Journal creation
long nextBlock = 0;
if (params.isJournaled()) {
this.setFileCount(2);
this.setAttribute(HFSPLUS_VOL_JOURNALED_BIT);
this.setNextCatalogId(this.getNextCatalogId() + 2);
this.setJournalInfoBlock(desc.getNext());
blockUsed = blockUsed + 1 + (params.getJournalSize() / blockSize);
} else {
this.setJournalInfoBlock(0);
nextBlock = desc.getNext();
}
// Extent B-Tree initialization
log.info("Init extent file.");
forkdata =
new HfsPlusForkData(CatalogNodeId.HFSPLUS_EXT_CNID, params.getExtentClumpSize(),
params.getExtentClumpSize(), (params.getExtentClumpSize() / blockSize));
desc = new ExtentDescriptor(nextBlock, forkdata.getTotalBlocks());
forkdata.addDescriptor(0, desc);
forkdata.write(data, 192);
blockUsed += forkdata.getTotalBlocks();
nextBlock = desc.getNext();
// Catalog B-Tree initialization
log.info("Init catalog file.");
int totalBlocks = params.getCatalogClumpSize() / blockSize;
forkdata =
new HfsPlusForkData(CatalogNodeId.HFSPLUS_CAT_CNID, params.getCatalogClumpSize(),
params.getCatalogClumpSize(), totalBlocks);
desc = new ExtentDescriptor(nextBlock, totalBlocks);
forkdata.addDescriptor(0, desc);
forkdata.write(data, 272);
blockUsed += totalBlocks;
this.setFreeBlocks(this.getFreeBlocks() - (int) blockUsed);