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()");
95 TRACE(
"Reading metadata block of size %u at position %" PRIu64,
106 FATAL(
"Could not read metadata block, continuing...");
240 TRACE(
"Exiting process_metadata_block()");
253 TRACE(
"Entering process_geometry_block(%p, %p)", ctx, entry);
254 size_t read_bytes = 0;
259 FATAL(
"Invalid context or image stream.");
261 TRACE(
"Exiting process_geometry_block()");
268 FATAL(
"Could not seek to %" PRIu64
" as indicated by index entry...", entry->
offset);
270 TRACE(
"Exiting process_geometry_block()");
274 TRACE(
"Reading geometry block header at position %" PRIu64, entry->
offset);
280 TRACE(
"Could not read geometry block header, continuing...");
287 TRACE(
"Incorrect identifier for geometry block at position %" PRIu64
"", entry->
offset);
300 TRACE(
"Exiting process_geometry_block()");
313 TRACE(
"Entering process_cicm_block(%p, %p)", ctx, entry);
315 size_t read_bytes = 0;
320 FATAL(
"Invalid context or image stream.");
322 TRACE(
"Exiting process_cicm_block()");
327 TRACE(
"Seeking to CICM XML metadata block at position %" PRIu64, entry->
offset);
331 FATAL(
"Could not seek to %" PRIu64
" as indicated by index entry...", entry->
offset);
333 TRACE(
"Exiting process_cicm_block()");
338 TRACE(
"Reading CICM XML metadata block header at position %" PRIu64, entry->
offset);
344 TRACE(
"Could not read CICM XML metadata header, continuing...");
351 TRACE(
"Incorrect identifier for data block at position %" PRIu64
"", entry->
offset);
361 TRACE(
"Could not allocate memory for CICM XML metadata block, continuing...");
363 TRACE(
"Exiting process_cicm_block()");
375 TRACE(
"Could not read CICM XML metadata block, continuing...");
378 TRACE(
"Found CICM XML metadata block %" PRIu64
".", entry->
offset);
380 TRACE(
"Exiting process_cicm_block()");
477 TRACE(
"Entering process_aaru_metadata_json_block(%p, %p)", ctx, entry);
479 size_t read_bytes = 0;
484 FATAL(
"Invalid context or image stream.");
486 TRACE(
"Exiting process_aaru_metadata_json_block()");
491 TRACE(
"Seeking to Aaru metadata JSON block at position %" PRIu64, entry->
offset);
495 FATAL(
"Could not seek to %" PRIu64
" as indicated by index entry...", entry->
offset);
497 TRACE(
"Exiting process_aaru_metadata_json_block()");
502 TRACE(
"Reading Aaru metadata JSON block header at position %" PRIu64, entry->
offset);
508 TRACE(
"Could not read Aaru metadata JSON header, continuing...");
515 TRACE(
"Incorrect identifier for data block at position %" PRIu64
"", entry->
offset);
525 TRACE(
"Could not allocate memory for Aaru metadata JSON block, continuing...");
527 TRACE(
"Exiting process_aaru_metadata_json_block()");
539 TRACE(
"Could not read Aaru metadata JSON block, continuing...");
542 TRACE(
"Found Aaru metadata JSON block %" PRIu64
".", entry->
offset);
544 TRACE(
"Exiting process_aaru_metadata_json_block()");
625 TRACE(
"Entering aaruf_get_readable_sector_tags(%p, %p, %zu)", context, buffer, (length ? *length : 0));
630 FATAL(
"Invalid context");
632 TRACE(
"Exiting aaruf_get_readable_sector_tags() = AARUF_ERROR_NOT_AARUFORMAT");
641 FATAL(
"Invalid context");
643 TRACE(
"Exiting aaruf_get_readable_sector_tags() = AARUF_ERROR_NOT_AARUFORMAT");
649 FATAL(
"Image contains no readable sector tags");
651 TRACE(
"Exiting aaruf_get_readable_sector_tags() = AARUF_ERROR_METADATA_NOT_PRESENT");
655 size_t required_length =
sizeof(bool) * (
MaxSectorTag + 1);
657 if(buffer == NULL || length == NULL || *length < required_length)
659 if(length) *length = required_length;
660 TRACE(
"Buffer too small for readable sector tags, required %zu bytes", required_length);
662 TRACE(
"Exiting aaruf_get_readable_sector_tags() = AARUF_ERROR_BUFFER_TOO_SMALL");
667 *length = required_length;
669 TRACE(
"Exiting aaruf_get_readable_sector_tags(%p, %p, %zu) = AARUF_STATUS_OK", context, buffer, *length);
713 TRACE(
"Entering aaruf_get_readable_media_tags(%p, %p, %zu)", context, buffer, (length ? *length : 0));
718 FATAL(
"Invalid context");
720 TRACE(
"Exiting aaruf_get_readable_media_tags() = AARUF_ERROR_NOT_AARUFORMAT");
729 FATAL(
"Invalid context");
731 TRACE(
"Exiting aaruf_get_readable_media_tags() = AARUF_ERROR_NOT_AARUFORMAT");
738 if(buffer == NULL || length == NULL || *length < required_length)
740 if(length) *length = required_length;
741 TRACE(
"Buffer too small for readable media tags, required %zu bytes", required_length);
743 TRACE(
"Exiting aaruf_get_readable_media_tags() = AARUF_ERROR_BUFFER_TOO_SMALL");
748 memset(buffer, 0, required_length);
751 for(int32_t tag_type = 0; tag_type <=
MaxMediaTag; tag_type++)
754 HASH_FIND_INT(ctx->
mediaTags, &tag_type, item);
758 buffer[tag_type] = 1;
759 TRACE(
"Media tag type %d is present", tag_type);
763 *length = required_length;
765 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).