mirror of
https://github.com/aaru-dps/libaaruformat.git
synced 2025-12-16 19:24:40 +00:00
Use heuristics to setup table shift.
This commit is contained in:
13
src/create.c
13
src/create.c
@@ -231,10 +231,21 @@ void *aaruf_create(const char *filepath, const uint32_t media_type, const uint32
|
||||
ctx->userDataDdtHeader.start = 0;
|
||||
ctx->userDataDdtHeader.blockAlignmentShift = parsed_options.block_alignment;
|
||||
ctx->userDataDdtHeader.dataShift = parsed_options.data_shift;
|
||||
ctx->userDataDdtHeader.tableShift = parsed_options.table_shift;
|
||||
ctx->userDataDdtHeader.sizeType = 1;
|
||||
ctx->userDataDdtHeader.entries = ctx->userDataDdtHeader.blocks / (1 << ctx->userDataDdtHeader.tableShift);
|
||||
|
||||
if(parsed_options.table_shift == -1)
|
||||
{
|
||||
uint64_t total_sectors = user_sectors + overflow_sectors + negative_sectors;
|
||||
|
||||
if(total_sectors < 0x8388608ULL)
|
||||
ctx->userDataDdtHeader.tableShift = 0;
|
||||
else
|
||||
ctx->userDataDdtHeader.tableShift = 22;
|
||||
}
|
||||
else
|
||||
ctx->userDataDdtHeader.tableShift = parsed_options.table_shift;
|
||||
|
||||
if(ctx->userDataDdtHeader.blocks % (1 << ctx->userDataDdtHeader.tableShift) != 0) ctx->userDataDdtHeader.entries++;
|
||||
|
||||
TRACE("Initializing primary/single DDT");
|
||||
|
||||
Reference in New Issue
Block a user