mirror of
https://github.com/aaru-dps/libaaruformat.git
synced 2025-12-16 19:24:40 +00:00
Add function to retrieve readable sector tags
This commit is contained in:
@@ -915,7 +915,7 @@ typedef enum
|
|||||||
DvdSectorEdcAaru = 19, ///< DVD sector EDC, 4 bytes
|
DvdSectorEdcAaru = 19, ///< DVD sector EDC, 4 bytes
|
||||||
AppleProfileTagAaru = 20, ///< Apple's Profile sector tags, 20 bytes
|
AppleProfileTagAaru = 20, ///< Apple's Profile sector tags, 20 bytes
|
||||||
PriamDataTowerTagAaru = 21, ///< Priam DataTower sector tags, 24 bytes
|
PriamDataTowerTagAaru = 21, ///< Priam DataTower sector tags, 24 bytes
|
||||||
MaxSectorTag = DvdSectorEdcAaru
|
MaxSectorTag = PriamDataTowerTagAaru
|
||||||
} SectorTagType;
|
} SectorTagType;
|
||||||
|
|
||||||
/** @} */ /* end of SectorTags group */
|
/** @} */ /* end of SectorTags group */
|
||||||
|
|||||||
@@ -195,6 +195,7 @@ AARU_EXPORT int32_t AARU_CALL aaruf_clear_drive_manufacturer(void *context);
|
|||||||
AARU_EXPORT int32_t AARU_CALL aaruf_clear_drive_model(void *context);
|
AARU_EXPORT int32_t AARU_CALL aaruf_clear_drive_model(void *context);
|
||||||
AARU_EXPORT int32_t AARU_CALL aaruf_clear_drive_serial_number(void *context);
|
AARU_EXPORT int32_t AARU_CALL aaruf_clear_drive_serial_number(void *context);
|
||||||
AARU_EXPORT int32_t AARU_CALL aaruf_clear_drive_firmware_revision(void *context);
|
AARU_EXPORT int32_t AARU_CALL aaruf_clear_drive_firmware_revision(void *context);
|
||||||
|
AARU_EXPORT int32_t AARU_CALL aaruf_get_readable_sector_tags(const void *context, uint8_t *buffer, size_t *length);
|
||||||
|
|
||||||
AARU_EXPORT int32_t AARU_CALL aaruf_get_tape_file(const void *context, uint8_t partition, uint32_t file,
|
AARU_EXPORT int32_t AARU_CALL aaruf_get_tape_file(const void *context, uint8_t partition, uint32_t file,
|
||||||
uint64_t *starting_block, uint64_t *ending_block);
|
uint64_t *starting_block, uint64_t *ending_block);
|
||||||
|
|||||||
@@ -537,4 +537,54 @@ void process_aaru_metadata_json_block(aaruformat_context *ctx, const IndexEntry
|
|||||||
TRACE("Found Aaru metadata JSON block %" PRIu64 ".", entry->offset);
|
TRACE("Found Aaru metadata JSON block %" PRIu64 ".", entry->offset);
|
||||||
|
|
||||||
TRACE("Exiting process_aaru_metadata_json_block()");
|
TRACE("Exiting process_aaru_metadata_json_block()");
|
||||||
|
}
|
||||||
|
|
||||||
|
AARU_EXPORT int32_t AARU_CALL aaruf_get_readable_sector_tags(const void *context, uint8_t *buffer, size_t *length)
|
||||||
|
{
|
||||||
|
TRACE("Entering aaruf_get_readable_sector_tags(%p, %p, %zu)", context, buffer, (length ? *length : 0));
|
||||||
|
|
||||||
|
// Check context is correct AaruFormat context
|
||||||
|
if(context == NULL)
|
||||||
|
{
|
||||||
|
FATAL("Invalid context");
|
||||||
|
|
||||||
|
TRACE("Exiting aaruf_get_readable_sector_tags() = AARUF_ERROR_NOT_AARUFORMAT");
|
||||||
|
return AARUF_ERROR_NOT_AARUFORMAT;
|
||||||
|
}
|
||||||
|
|
||||||
|
const aaruformat_context *ctx = context;
|
||||||
|
|
||||||
|
// Not a libaaruformat context
|
||||||
|
if(ctx->magic != AARU_MAGIC)
|
||||||
|
{
|
||||||
|
FATAL("Invalid context");
|
||||||
|
|
||||||
|
TRACE("Exiting aaruf_get_readable_sector_tags() = AARUF_ERROR_NOT_AARUFORMAT");
|
||||||
|
return AARUF_ERROR_NOT_AARUFORMAT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ctx->readableSectorTags == NULL)
|
||||||
|
{
|
||||||
|
FATAL("Image contains no readable sector tags");
|
||||||
|
|
||||||
|
TRACE("Exiting aaruf_get_readable_sector_tags() = AARUF_ERROR_METADATA_NOT_PRESENT");
|
||||||
|
return AARUF_ERROR_METADATA_NOT_PRESENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t required_length = sizeof(bool) * (MaxSectorTag + 1);
|
||||||
|
|
||||||
|
if(buffer == NULL || length == NULL || *length < required_length)
|
||||||
|
{
|
||||||
|
if(length) *length = required_length;
|
||||||
|
|
||||||
|
TRACE("Buffer too small for readable sector tags, required %zu bytes", required_length);
|
||||||
|
TRACE("Exiting aaruf_get_readable_sector_tags() = AARUF_ERROR_BUFFER_TOO_SMALL");
|
||||||
|
return AARUF_ERROR_BUFFER_TOO_SMALL;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(buffer, ctx->readableSectorTags, required_length);
|
||||||
|
*length = required_length;
|
||||||
|
|
||||||
|
TRACE("Exiting aaruf_get_readable_sector_tags(%p, %p, %zu) = AARUF_STATUS_OK", context, buffer, *length);
|
||||||
|
return AARUF_STATUS_OK;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user