mirror of
https://github.com/aaru-dps/libaaruformat.git
synced 2025-12-16 19:24:40 +00:00
Implement processing of DDT v2.
This commit is contained in:
43
src/open.c
43
src/open.c
@@ -35,7 +35,7 @@ void *aaruf_open(const char *filepath)
|
||||
long pos = 0;
|
||||
int i = 0;
|
||||
uint32_t signature = 0;
|
||||
UT_array *index_entries = NULL;
|
||||
UT_array * index_entries = NULL;
|
||||
|
||||
ctx = (aaruformatContext *)malloc(sizeof(aaruformatContext));
|
||||
memset(ctx, 0, sizeof(aaruformatContext));
|
||||
@@ -151,8 +151,8 @@ void *aaruf_open(const char *filepath)
|
||||
|
||||
readBytes = fread(&signature, 1, sizeof(uint32_t), ctx->imageStream);
|
||||
|
||||
if(readBytes != sizeof(uint32_t) ||
|
||||
(signature != IndexBlock && signature != IndexBlock2 && signature != IndexBlock3))
|
||||
if(readBytes != sizeof(uint32_t) || (signature != IndexBlock && signature != IndexBlock2 && signature !=
|
||||
IndexBlock3))
|
||||
{
|
||||
free(ctx);
|
||||
errno = AARUF_ERROR_CANNOT_READ_INDEX;
|
||||
@@ -160,12 +160,9 @@ void *aaruf_open(const char *filepath)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(signature == IndexBlock)
|
||||
index_entries = process_index_v1(ctx);
|
||||
else if(signature == IndexBlock2)
|
||||
index_entries = process_index_v2(ctx);
|
||||
else if(signature == IndexBlock3)
|
||||
index_entries = process_index_v3(ctx);
|
||||
if(signature == IndexBlock) index_entries = process_index_v1(ctx);
|
||||
else if(signature == IndexBlock2) index_entries = process_index_v2(ctx);
|
||||
else if(signature == IndexBlock3) index_entries = process_index_v3(ctx);
|
||||
|
||||
if(index_entries == NULL)
|
||||
{
|
||||
@@ -196,9 +193,9 @@ void *aaruf_open(const char *filepath)
|
||||
|
||||
if(pos < 0 || ftell(ctx->imageStream) != entry->offset)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"libaaruformat: Could not seek to %" PRIu64 " as indicated by index entry %d, continuing...\n",
|
||||
entry->offset, i);
|
||||
fprintf(
|
||||
stderr, "libaaruformat: Could not seek to %" PRIu64 " as indicated by index entry %d, continuing...\n",
|
||||
entry->offset, i);
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -231,6 +228,19 @@ void *aaruf_open(const char *filepath)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
break;
|
||||
case DeDuplicationTable2:
|
||||
errorNo = process_ddt_v2(ctx, entry, &foundUserDataDdt);
|
||||
|
||||
if(errorNo != AARUF_STATUS_OK)
|
||||
{
|
||||
utarray_free(index_entries);
|
||||
free(ctx);
|
||||
errno = errorNo;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
break;
|
||||
case GeometryBlock:
|
||||
process_geometry_block(ctx, entry);
|
||||
@@ -248,7 +258,7 @@ void *aaruf_open(const char *filepath)
|
||||
process_cicm_block(ctx, entry);
|
||||
|
||||
break;
|
||||
// Dump hardware block
|
||||
// Dump hardware block
|
||||
case DumpHardwareBlock:
|
||||
process_dumphw_block(ctx, entry);
|
||||
|
||||
@@ -258,9 +268,10 @@ void *aaruf_open(const char *filepath)
|
||||
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,
|
||||
"libaaruformat: Unhandled block type %4.4s with data type %d is indexed to be at %" PRIu64 "\n",
|
||||
(char *)&entry->blockType, entry->dataType, entry->offset);
|
||||
fprintf(
|
||||
stderr,
|
||||
"libaaruformat: Unhandled block type %4.4s with data type %d is indexed to be at %" PRIu64 "\n",
|
||||
(char *)&entry->blockType, entry->dataType, entry->offset);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user