37 TRACE(
"Entering process_metadata_block(%p, %p)", ctx, entry);
39 size_t read_bytes = 0;
44 FATAL(
"Invalid context or image stream.");
45 TRACE(
"Exiting process_metadata_block()");
50 TRACE(
"Seeking to metadata block at position %" PRIu64, entry->
offset);
54 FATAL(
"Could not seek to %" PRIu64
" as indicated by index entry...", entry->
offset);
56 TRACE(
"Exiting process_metadata_block()");
61 TRACE(
"Reading metadata block header at position %" PRIu64, entry->
offset);
67 FATAL(
"Could not read metadata block header, continuing...");
69 TRACE(
"Exiting process_metadata_block()");
76 TRACE(
"Incorrect identifier for data block at position %" PRIu64
"", entry->
offset);
78 TRACE(
"Exiting process_metadata_block()");
89 FATAL(
"Could not allocate memory for metadata block, continuing...");
91 TRACE(
"Exiting process_metadata_block()");
103 FATAL(
"Could not read metadata block, continuing...");
235 TRACE(
"Exiting process_metadata_block()");
248 TRACE(
"Entering process_geometry_block(%p, %p)", ctx, entry);
249 size_t read_bytes = 0;
254 FATAL(
"Invalid context or image stream.");
256 TRACE(
"Exiting process_geometry_block()");
263 FATAL(
"Could not seek to %" PRIu64
" as indicated by index entry...", entry->
offset);
265 TRACE(
"Exiting process_geometry_block()");
269 TRACE(
"Reading geometry block header at position %" PRIu64, entry->
offset);
275 TRACE(
"Could not read geometry block header, continuing...");
282 TRACE(
"Incorrect identifier for geometry block at position %" PRIu64
"", entry->
offset);
295 TRACE(
"Exiting process_geometry_block()");
308 TRACE(
"Entering process_cicm_block(%p, %p)", ctx, entry);
310 size_t read_bytes = 0;
315 FATAL(
"Invalid context or image stream.");
317 TRACE(
"Exiting process_cicm_block()");
322 TRACE(
"Seeking to CICM XML metadata block at position %" PRIu64, entry->
offset);
326 FATAL(
"Could not seek to %" PRIu64
" as indicated by index entry...", entry->
offset);
328 TRACE(
"Exiting process_cicm_block()");
333 TRACE(
"Reading CICM XML metadata block header at position %" PRIu64, entry->
offset);
339 TRACE(
"Could not read CICM XML metadata header, continuing...");
346 TRACE(
"Incorrect identifier for data block at position %" PRIu64
"", entry->
offset);
356 TRACE(
"Could not allocate memory for CICM XML metadata block, continuing...");
358 TRACE(
"Exiting process_cicm_block()");
370 TRACE(
"Could not read CICM XML metadata block, continuing...");
373 TRACE(
"Found CICM XML metadata block %" PRIu64
".", entry->
offset);
375 TRACE(
"Exiting process_cicm_block()");
472 TRACE(
"Entering process_aaru_metadata_json_block(%p, %p)", ctx, entry);
474 size_t read_bytes = 0;
479 FATAL(
"Invalid context or image stream.");
481 TRACE(
"Exiting process_aaru_metadata_json_block()");
486 TRACE(
"Seeking to Aaru metadata JSON block at position %" PRIu64, entry->
offset);
490 FATAL(
"Could not seek to %" PRIu64
" as indicated by index entry...", entry->
offset);
492 TRACE(
"Exiting process_aaru_metadata_json_block()");
497 TRACE(
"Reading Aaru metadata JSON block header at position %" PRIu64, entry->
offset);
503 TRACE(
"Could not read Aaru metadata JSON header, continuing...");
510 TRACE(
"Incorrect identifier for data block at position %" PRIu64
"", entry->
offset);
520 TRACE(
"Could not allocate memory for Aaru metadata JSON block, continuing...");
522 TRACE(
"Exiting process_aaru_metadata_json_block()");
534 TRACE(
"Could not read Aaru metadata JSON block, continuing...");
537 TRACE(
"Found Aaru metadata JSON block %" PRIu64
".", entry->
offset);
539 TRACE(
"Exiting process_aaru_metadata_json_block()");
620 TRACE(
"Entering aaruf_get_readable_sector_tags(%p, %p, %zu)", context, buffer, (length ? *length : 0));
625 FATAL(
"Invalid context");
627 TRACE(
"Exiting aaruf_get_readable_sector_tags() = AARUF_ERROR_NOT_AARUFORMAT");
636 FATAL(
"Invalid context");
638 TRACE(
"Exiting aaruf_get_readable_sector_tags() = AARUF_ERROR_NOT_AARUFORMAT");
644 FATAL(
"Image contains no readable sector tags");
646 TRACE(
"Exiting aaruf_get_readable_sector_tags() = AARUF_ERROR_METADATA_NOT_PRESENT");
650 size_t required_length =
sizeof(bool) * (
MaxSectorTag + 1);
652 if(buffer == NULL || length == NULL || *length < required_length)
654 if(length) *length = required_length;
655 TRACE(
"Buffer too small for readable sector tags, required %zu bytes", required_length);
657 TRACE(
"Exiting aaruf_get_readable_sector_tags() = AARUF_ERROR_BUFFER_TOO_SMALL");
662 *length = required_length;
664 TRACE(
"Exiting aaruf_get_readable_sector_tags(%p, %p, %zu) = AARUF_STATUS_OK", context, buffer, *length);
708 TRACE(
"Entering aaruf_get_readable_media_tags(%p, %p, %zu)", context, buffer, (length ? *length : 0));
713 FATAL(
"Invalid context");
715 TRACE(
"Exiting aaruf_get_readable_media_tags() = AARUF_ERROR_NOT_AARUFORMAT");
724 FATAL(
"Invalid context");
726 TRACE(
"Exiting aaruf_get_readable_media_tags() = AARUF_ERROR_NOT_AARUFORMAT");
733 if(buffer == NULL || length == NULL || *length < required_length)
735 if(length) *length = required_length;
736 TRACE(
"Buffer too small for readable media tags, required %zu bytes", required_length);
738 TRACE(
"Exiting aaruf_get_readable_media_tags() = AARUF_ERROR_BUFFER_TOO_SMALL");
743 memset(buffer, 0, required_length);
746 for(int32_t tag_type = 0; tag_type <=
MaxMediaTag; tag_type++)
749 HASH_FIND_INT(ctx->
mediaTags, &tag_type, item);
753 buffer[tag_type] = 1;
754 TRACE(
"Media tag type %d is present", tag_type);
758 *length = required_length;
760 TRACE(
"Exiting aaruf_get_readable_media_tags(%p, %p, %zu) = AARUF_STATUS_OK", context, buffer, *length);
#define AARU_MAGIC
Magic identifier for AaruFormat container (ASCII "AARUFRMT").
@ GeometryBlock
Block containing logical geometry.
@ AaruMetadataJsonBlock
Block containing JSON version of Aaru Metadata.
@ CicmBlock
Block containing CICM XML metadata.
#define AARUF_STATUS_OK
Sector present and read without uncorrectable errors.
#define AARUF_ERROR_METADATA_NOT_PRESENT
Requested metadata not present in image.
#define AARUF_ERROR_NOT_AARUFORMAT
Input file/stream failed magic or structural validation.
#define AARUF_ERROR_BUFFER_TOO_SMALL
Caller-supplied buffer insufficient for data.
uint64_t ImageSize
Size of the image payload in bytes (excludes headers/metadata)
Single index entry describing a block's type, (optional) data classification, and file offset.
uint32_t blockType
Block identifier of the referenced block (value from BlockType).
uint64_t offset
Absolute byte offset in the image where the referenced block header begins.
Master context representing an open or in‑creation Aaru image.
uint8_t * media_barcode
Barcode of the media represented by the image.
uint8_t * creator
Who (person) created the image?
uint8_t * cicm_block
CICM XML payload.
uint32_t cylinders
Cylinders of the media represented by the image.
uint8_t * drive_firmware_revision
Firmware revision of the drive used to read the media represented by the image.
uint8_t * media_serial_number
Serial number of the media represented by the image.
MetadataBlockHeader metadata_block_header
Metadata block header.
int32_t media_sequence
Number in sequence for the media represented by the image.
uint8_t * media_model
Model of the media represented by the image.
uint8_t * drive_serial_number
Serial number of the drive used to read the media represented by the image.
uint8_t * drive_manufacturer
Manufacturer of the drive used to read the media represented by the image.
CicmMetadataBlock cicm_block_header
CICM metadata header (if present).
uint8_t * drive_model
Model of the drive used to read the media represented by the image.
uint64_t magic
File magic (AARU_MAGIC) post-open.
mediaTagEntry * mediaTags
Hash table of extra media tags (uthash root).
GeometryBlockHeader geometry_block
Logical geometry block (if present).
uint8_t * json_block
JSON metadata block payload (UTF-8).
uint8_t * media_part_number
Part number of the media represented by the image.
AaruMetadataJsonBlockHeader json_block_header
JSON metadata block header (if present).
uint32_t sectors_per_track
Sectors per track of the media represented by the image (for variable image, the smallest)
uint8_t * comments
Image comments.
uint32_t heads
Heads of the media represented by the image.
FILE * imageStream
Underlying FILE* stream (binary mode).
ImageInfo image_info
Exposed high-level image info summary.
bool * readableSectorTags
Per-sector boolean array (optical tags read successfully?).
uint8_t * metadata_block
Raw metadata UTF-16LE concatenated strings.
uint8_t * media_title
Title of the media represented by the image.
int32_t last_media_sequence
Last media of the sequence the media represented by the image corresponds to.
uint8_t * media_manufacturer
Manufacturer of the media represented by the image.
Hash table entry for an arbitrary media tag (e.g., proprietary drive/medium descriptor).