mirror of
https://github.com/aaru-dps/libaaruformat.git
synced 2025-12-16 19:24:40 +00:00
Read CompactDisc deduplication tables.
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef struct dicformatContext
|
||||
{
|
||||
@@ -50,10 +51,13 @@ typedef struct dicformatContext
|
||||
unsigned char *sectorSuffixCorrected;
|
||||
unsigned char *sectorSubchannel;
|
||||
unsigned char *mode2Subheaders;
|
||||
byte shift;
|
||||
unsigned char shift;
|
||||
bool inMemoryDdt;
|
||||
uint64_t *userDataDdt;
|
||||
size_t mappedMemoryDdtSize;
|
||||
uint32_t *sectorPrefixDdt;
|
||||
uint32_t *sectorSuffixDdt;
|
||||
|
||||
} dicformatContext;
|
||||
|
||||
typedef struct dataLinkedList
|
||||
|
||||
@@ -87,6 +87,10 @@ int close(void *context)
|
||||
{
|
||||
munmap(ctx->userDataDdt, ctx->mappedMemoryDdtSize);
|
||||
}
|
||||
|
||||
free(ctx->sectorPrefixDdt);
|
||||
free(ctx->sectorSuffixDdt);
|
||||
|
||||
free(context);
|
||||
|
||||
return 0;
|
||||
|
||||
36
src/open.c
36
src/open.c
@@ -36,7 +36,6 @@
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
// TODO: Check CRC64 on structures
|
||||
@@ -423,6 +422,41 @@ void *open(const char *filepath)
|
||||
|
||||
}
|
||||
}
|
||||
else if(idxEntries[i].dataType == CdSectorPrefixCorrected ||
|
||||
idxEntries[i].dataType == CdSectorSuffixCorrected)
|
||||
{
|
||||
switch(ddtHeader.compression)
|
||||
{
|
||||
case None:data = malloc(ddtHeader.entries * sizeof(uint32_t));
|
||||
|
||||
if(mediaTag == NULL)
|
||||
{
|
||||
fprintf(stderr, "libdicformat: Cannot allocate memory for deduplication table.");
|
||||
break;
|
||||
}
|
||||
|
||||
readBytes = fread(data, ddtHeader.entries * sizeof(uint32_t), 1, ctx->imageStream);
|
||||
|
||||
if(readBytes != ddtHeader.entries * sizeof(uint32_t))
|
||||
{
|
||||
free(data);
|
||||
fprintf(stderr, "Could not read deduplication table, continuing...");
|
||||
break;
|
||||
}
|
||||
|
||||
if(idxEntries[i].dataType == CdSectorPrefixCorrected)
|
||||
ctx->sectorPrefixCorrected = data;
|
||||
else if(idxEntries[i].dataType == CdSectorSuffixCorrected)
|
||||
ctx->sectorPrefixCorrected = data;
|
||||
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,
|
||||
"libdicformat: Found unknown compression type %d, continuing...",
|
||||
blockHeader.compression);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GeometryBlock:
|
||||
// TODO
|
||||
|
||||
Reference in New Issue
Block a user