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,
108 FATAL(
"Could not read metadata block, continuing...");
242 TRACE(
"Exiting process_metadata_block()");
255 TRACE(
"Entering process_geometry_block(%p, %p)", ctx, entry);
256 size_t read_bytes = 0;
261 FATAL(
"Invalid context or image stream.");
263 TRACE(
"Exiting process_geometry_block()");
270 FATAL(
"Could not seek to %" PRIu64
" as indicated by index entry...", entry->
offset);
272 TRACE(
"Exiting process_geometry_block()");
276 TRACE(
"Reading geometry block header at position %" PRIu64, entry->
offset);
282 TRACE(
"Could not read geometry block header, continuing...");
289 TRACE(
"Incorrect identifier for geometry block at position %" PRIu64
"", entry->
offset);
302 TRACE(
"Exiting process_geometry_block()");
315 TRACE(
"Entering process_cicm_block(%p, %p)", ctx, entry);
317 size_t read_bytes = 0;
322 FATAL(
"Invalid context or image stream.");
324 TRACE(
"Exiting process_cicm_block()");
329 TRACE(
"Seeking to CICM XML metadata block at position %" PRIu64, entry->
offset);
333 FATAL(
"Could not seek to %" PRIu64
" as indicated by index entry...", entry->
offset);
335 TRACE(
"Exiting process_cicm_block()");
340 TRACE(
"Reading CICM XML metadata block header at position %" PRIu64, entry->
offset);
346 TRACE(
"Could not read CICM XML metadata header, continuing...");
353 TRACE(
"Incorrect identifier for data block at position %" PRIu64
"", entry->
offset);
363 TRACE(
"Could not allocate memory for CICM XML metadata block, continuing...");
365 TRACE(
"Exiting process_cicm_block()");
378 TRACE(
"Could not read CICM XML metadata block, continuing...");
381 TRACE(
"Found CICM XML metadata block %" PRIu64
".", entry->
offset);
383 TRACE(
"Exiting process_cicm_block()");
480 TRACE(
"Entering process_aaru_metadata_json_block(%p, %p)", ctx, entry);
482 size_t read_bytes = 0;
487 FATAL(
"Invalid context or image stream.");
489 TRACE(
"Exiting process_aaru_metadata_json_block()");
494 TRACE(
"Seeking to Aaru metadata JSON block at position %" PRIu64, entry->
offset);
498 FATAL(
"Could not seek to %" PRIu64
" as indicated by index entry...", entry->
offset);
500 TRACE(
"Exiting process_aaru_metadata_json_block()");
505 TRACE(
"Reading Aaru metadata JSON block header at position %" PRIu64, entry->
offset);
511 TRACE(
"Could not read Aaru metadata JSON header, continuing...");
518 TRACE(
"Incorrect identifier for data block at position %" PRIu64
"", entry->
offset);
528 TRACE(
"Could not allocate memory for Aaru metadata JSON block, continuing...");
530 TRACE(
"Exiting process_aaru_metadata_json_block()");
543 TRACE(
"Could not read Aaru metadata JSON block, continuing...");
546 TRACE(
"Found Aaru metadata JSON block %" PRIu64
".", entry->
offset);
548 TRACE(
"Exiting process_aaru_metadata_json_block()");
629 TRACE(
"Entering aaruf_get_readable_sector_tags(%p, %p, %zu)", context, buffer, (length ? *length : 0));
634 FATAL(
"Invalid context");
636 TRACE(
"Exiting aaruf_get_readable_sector_tags() = AARUF_ERROR_NOT_AARUFORMAT");
645 FATAL(
"Invalid context");
647 TRACE(
"Exiting aaruf_get_readable_sector_tags() = AARUF_ERROR_NOT_AARUFORMAT");
653 FATAL(
"Image contains no readable sector tags");
655 TRACE(
"Exiting aaruf_get_readable_sector_tags() = AARUF_ERROR_METADATA_NOT_PRESENT");
659 size_t required_length =
sizeof(bool) * (
MaxSectorTag + 1);
661 if(buffer == NULL || length == NULL || *length < required_length)
663 if(length) *length = required_length;
664 TRACE(
"Buffer too small for readable sector tags, required %zu bytes", required_length);
666 TRACE(
"Exiting aaruf_get_readable_sector_tags() = AARUF_ERROR_BUFFER_TOO_SMALL");
671 *length = required_length;
673 TRACE(
"Exiting aaruf_get_readable_sector_tags(%p, %p, %zu) = AARUF_STATUS_OK", context, buffer, *length);
717 TRACE(
"Entering aaruf_get_readable_media_tags(%p, %p, %zu)", context, buffer, (length ? *length : 0));
722 FATAL(
"Invalid context");
724 TRACE(
"Exiting aaruf_get_readable_media_tags() = AARUF_ERROR_NOT_AARUFORMAT");
733 FATAL(
"Invalid context");
735 TRACE(
"Exiting aaruf_get_readable_media_tags() = AARUF_ERROR_NOT_AARUFORMAT");
742 if(buffer == NULL || length == NULL || *length < required_length)
744 if(length) *length = required_length;
745 TRACE(
"Buffer too small for readable media tags, required %zu bytes", required_length);
747 TRACE(
"Exiting aaruf_get_readable_media_tags() = AARUF_ERROR_BUFFER_TOO_SMALL");
752 memset(buffer, 0, required_length);
755 for(int32_t tag_type = 0; tag_type <=
MaxMediaTag; tag_type++)
758 HASH_FIND_INT(ctx->
mediaTags, &tag_type, item);
762 buffer[tag_type] = 1;
763 TRACE(
"Media tag type %d is present", tag_type);
767 *length = required_length;
769 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").
int32_t aaruf_get_readable_media_tags(const void *context, uint8_t *buffer, size_t *length)
Retrieves which media tags are present in the AaruFormat image.
int32_t aaruf_get_readable_sector_tags(const void *context, uint8_t *buffer, size_t *length)
Retrieves which sector tags are readable in the AaruFormat image.
@ 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.
void process_metadata_block(aaruformat_context *ctx, const IndexEntry *entry)
Processes a metadata block from the image stream.
void process_cicm_block(aaruformat_context *ctx, const IndexEntry *entry)
Processes a CICM XML metadata block from the image stream.
static int aaruf_fseek(FILE *stream, aaru_off_t offset, int origin)
static aaru_off_t aaruf_ftell(FILE *stream)
void process_geometry_block(aaruformat_context *ctx, const IndexEntry *entry)
Processes a logical geometry block from the image stream.
void process_aaru_metadata_json_block(aaruformat_context *ctx, const IndexEntry *entry)
Processes an Aaru metadata JSON block from the image stream during image opening.
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).