Implement read_track_sector().

This commit is contained in:
2019-03-23 23:31:04 +00:00
parent 6ed23b6616
commit 3be40f84fe
4 changed files with 64 additions and 11 deletions

View File

@@ -154,4 +154,33 @@ int32_t read_sector(void *context, uint64_t sectorAddress, uint8_t *data, uint32
*length = blockHeader.sectorSize;
free(block);
return DICF_STATUS_OK;
}
}
int32_t read_track_sector(void *context, uint8_t *data, uint64_t sectorAddress, uint32_t *length, uint8_t track)
{
dicformatContext *ctx;
int i;
if(context == NULL)
return DICF_ERROR_NOT_DICFORMAT;
ctx = context;
// TODO: Cast this field without casting the whole structure, as this can buffer overflow
// Not a libdicformat context
if(ctx->magic != DIC_MAGIC)
return DICF_ERROR_NOT_DICFORMAT;
if(ctx->imageInfo.XmlMediaType != OpticalDisc)
return DICF_ERROR_INCORRECT_MEDIA_TYPE;
for(i = 0; i < ctx->numberOfDataTracks; i++)
{
if(ctx->dataTracks[i].sequence == track)
{
return read_sector(context, ctx->dataTracks[i].start + sectorAddress, data, length);
}
}
return DICF_ERROR_TRACK_NOT_FOUND;
}