public BlockAllocationTableReader(int block_count,
int[] block_array,
int xbat_count,
int xbat_index,
BlockList raw_block_list) throws IOException {
this();
if (block_count < = 0)
{
throw new IOException(
"Illegal block count; minimum count is 1, got " + block_count
+ " instead");
}
// acquire raw data blocks containing the BAT block data
RawDataBlock blocks[] = new RawDataBlock[ block_count ];
int limit = Math.min(block_count, block_array.length);
int block_index;
for (block_index = 0; block_index < limit; block_index++)
{
blocks[ block_index ] =
( RawDataBlock ) raw_block_list
.remove(block_array[ block_index ]);
}
if (block_index < block_count)
{
// must have extended blocks
if (xbat_index < 0)
{
throw new IOException(
"BAT count exceeds limit, yet XBAT index indicates no valid entries");
}
int chain_index = xbat_index;
int max_entries_per_block = BATBlock.entriesPerXBATBlock();
int chain_index_offset = BATBlock.getXBATChainOffset();
for (int j = 0; j < xbat_count; j++)
{
limit = Math.min(block_count - block_index,
max_entries_per_block);
byte[] data = raw_block_list.remove(chain_index).getData();
int offset = 0;
for (int k = 0; k < limit; k++)
{
blocks[ block_index++ ] =
( RawDataBlock ) raw_block_list
.remove(LittleEndian.getInt(data, offset));
offset += LittleEndianConsts.INT_SIZE;
}
chain_index = LittleEndian.getInt(data, chain_index_offset);
if (chain_index == POIFSConstants.END_OF_CHAIN)
{
break;
}
}
}
if (block_index != block_count)
{
throw new IOException("Could not find all blocks");
}
// now that we have all of the raw data blocks, go through and
// create the indices
setEntries(blocks, raw_block_list);
}
create a BlockAllocationTableReader for an existing filesystem. Side
effect: when this method finishes, the BAT blocks will have
been removed from the raw block list, and any blocks labeled as
'unused' in the block allocation table will also have been
removed from the raw block list. Parameters:
block_count - the number of BAT blocks making up the block
allocation table
block_array - the array of BAT block indices from the
filesystem's header
xbat_count - the number of XBAT blocks
xbat_index - the index of the first XBAT block
raw_block_list - the list of RawDataBlocks
Throws:
IOException - if, in trying to create the table, we
encounter logic errors
- exception:
IOException - if, in trying to create the table, we
encounter logic errors
|