38 TRACE(
"Entering process_metadata_block(%p, %p)", ctx, entry);
40 size_t read_bytes = 0;
45 FATAL(
"Invalid context or image stream.");
46 TRACE(
"Exiting process_metadata_block()");
51 TRACE(
"Seeking to metadata block at position %" PRIu64, entry->
offset);
55 FATAL(
"Could not seek to %" PRIu64
" as indicated by index entry...", entry->
offset);
57 TRACE(
"Exiting process_metadata_block()");
62 TRACE(
"Reading metadata block header at position %" PRIu64, entry->
offset);
68 FATAL(
"Could not read metadata block header, continuing...");
70 TRACE(
"Exiting process_metadata_block()");
77 TRACE(
"Incorrect identifier for data block at position %" PRIu64
"", entry->
offset);
79 TRACE(
"Exiting process_metadata_block()");
90 FATAL(
"Could not allocate memory for metadata block, continuing...");
92 TRACE(
"Exiting process_metadata_block()");
96 TRACE(
"Reading metadata block of size %u at position %" PRIu64,
107 FATAL(
"Could not read metadata block, continuing...");
241 TRACE(
"Exiting process_metadata_block()");
254 TRACE(
"Entering process_geometry_block(%p, %p)", ctx, entry);
255 size_t read_bytes = 0;
260 FATAL(
"Invalid context or image stream.");
262 TRACE(
"Exiting process_geometry_block()");
269 FATAL(
"Could not seek to %" PRIu64
" as indicated by index entry...", entry->
offset);
271 TRACE(
"Exiting process_geometry_block()");
275 TRACE(
"Reading geometry block header at position %" PRIu64, entry->
offset);
281 TRACE(
"Could not read geometry block header, continuing...");
288 TRACE(
"Incorrect identifier for geometry block at position %" PRIu64
"", entry->
offset);
301 TRACE(
"Exiting process_geometry_block()");
314 TRACE(
"Entering process_cicm_block(%p, %p)", ctx, entry);
316 size_t read_bytes = 0;
321 FATAL(
"Invalid context or image stream.");
323 TRACE(
"Exiting process_cicm_block()");
328 TRACE(
"Seeking to CICM XML metadata block at position %" PRIu64, entry->
offset);
332 FATAL(
"Could not seek to %" PRIu64
" as indicated by index entry...", entry->
offset);
334 TRACE(
"Exiting process_cicm_block()");
339 TRACE(
"Reading CICM XML metadata block header at position %" PRIu64, entry->
offset);
345 TRACE(
"Could not read CICM XML metadata header, continuing...");
352 TRACE(
"Incorrect identifier for data block at position %" PRIu64
"", entry->
offset);
362 TRACE(
"Could not allocate memory for CICM XML metadata block, continuing...");
364 TRACE(
"Exiting process_cicm_block()");
376 TRACE(
"Could not read CICM XML metadata block, continuing...");
379 TRACE(
"Found CICM XML metadata block %" PRIu64
".", entry->
offset);
381 TRACE(
"Exiting process_cicm_block()");
478 TRACE(
"Entering process_aaru_metadata_json_block(%p, %p)", ctx, entry);
480 size_t read_bytes = 0;
485 FATAL(
"Invalid context or image stream.");
487 TRACE(
"Exiting process_aaru_metadata_json_block()");
492 TRACE(
"Seeking to Aaru metadata JSON block at position %" PRIu64, entry->
offset);
496 FATAL(
"Could not seek to %" PRIu64
" as indicated by index entry...", entry->
offset);
498 TRACE(
"Exiting process_aaru_metadata_json_block()");
503 TRACE(
"Reading Aaru metadata JSON block header at position %" PRIu64, entry->
offset);
509 TRACE(
"Could not read Aaru metadata JSON header, continuing...");
516 TRACE(
"Incorrect identifier for data block at position %" PRIu64
"", entry->
offset);
526 TRACE(
"Could not allocate memory for Aaru metadata JSON block, continuing...");
528 TRACE(
"Exiting process_aaru_metadata_json_block()");
540 TRACE(
"Could not read Aaru metadata JSON block, continuing...");
543 TRACE(
"Found Aaru metadata JSON block %" PRIu64
".", entry->
offset);
545 TRACE(
"Exiting process_aaru_metadata_json_block()");
626 TRACE(
"Entering aaruf_get_readable_sector_tags(%p, %p, %zu)", context, buffer, (length ? *length : 0));
631 FATAL(
"Invalid context");
633 TRACE(
"Exiting aaruf_get_readable_sector_tags() = AARUF_ERROR_NOT_AARUFORMAT");
642 FATAL(
"Invalid context");
644 TRACE(
"Exiting aaruf_get_readable_sector_tags() = AARUF_ERROR_NOT_AARUFORMAT");
650 FATAL(
"Image contains no readable sector tags");
652 TRACE(
"Exiting aaruf_get_readable_sector_tags() = AARUF_ERROR_METADATA_NOT_PRESENT");
656 size_t required_length =
sizeof(bool) * (
MaxSectorTag + 1);
658 if(buffer == NULL || length == NULL || *length < required_length)
660 if(length) *length = required_length;
661 TRACE(
"Buffer too small for readable sector tags, required %zu bytes", required_length);
663 TRACE(
"Exiting aaruf_get_readable_sector_tags() = AARUF_ERROR_BUFFER_TOO_SMALL");
668 *length = required_length;
670 TRACE(
"Exiting aaruf_get_readable_sector_tags(%p, %p, %zu) = AARUF_STATUS_OK", context, buffer, *length);
714 TRACE(
"Entering aaruf_get_readable_media_tags(%p, %p, %zu)", context, buffer, (length ? *length : 0));
719 FATAL(
"Invalid context");
721 TRACE(
"Exiting aaruf_get_readable_media_tags() = AARUF_ERROR_NOT_AARUFORMAT");
730 FATAL(
"Invalid context");
732 TRACE(
"Exiting aaruf_get_readable_media_tags() = AARUF_ERROR_NOT_AARUFORMAT");
739 if(buffer == NULL || length == NULL || *length < required_length)
741 if(length) *length = required_length;
742 TRACE(
"Buffer too small for readable media tags, required %zu bytes", required_length);
744 TRACE(
"Exiting aaruf_get_readable_media_tags() = AARUF_ERROR_BUFFER_TOO_SMALL");
749 memset(buffer, 0, required_length);
752 for(int32_t tag_type = 0; tag_type <=
MaxMediaTag; tag_type++)
755 HASH_FIND_INT(ctx->
mediaTags, &tag_type, item);
759 buffer[tag_type] = 1;
760 TRACE(
"Media tag type %d is present", tag_type);
764 *length = required_length;
766 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.
static int aaruf_fseek(FILE *stream, aaru_off_t offset, int origin)
static aaru_off_t aaruf_ftell(FILE *stream)
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).