Loading...
Searching...
No Matches
metadata.c
Go to the documentation of this file.
/*
* This file is part of the Aaru Data Preservation Suite.
* Copyright (c) 2019-2026 Natalia Portillo.
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of the
* License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "aaruformat.h"
#include "log.h"
void process_metadata_block(aaruformat_context *ctx, const IndexEntry *entry)
{
TRACE("Entering process_metadata_block(%p, %p)", ctx, entry);
int pos = 0;
size_t read_bytes = 0;
// Check if the context and image stream are valid
if(ctx == NULL || ctx->imageStream == NULL)
{
FATAL("Invalid context or image stream.");
TRACE("Exiting process_metadata_block()");
return;
}
// Seek to block
TRACE("Seeking to metadata block at position %" PRIu64, entry->offset);
pos = fseek(ctx->imageStream, entry->offset, SEEK_SET);
if(pos < 0 || ftell(ctx->imageStream) != entry->offset)
{
FATAL("Could not seek to %" PRIu64 " as indicated by index entry...", entry->offset);
TRACE("Exiting process_metadata_block()");
return;
}
// Even if those two checks shall have been done before
TRACE("Reading metadata block header at position %" PRIu64, entry->offset);
read_bytes = fread(&ctx->metadata_block_header, 1, sizeof(MetadataBlockHeader), ctx->imageStream);
if(read_bytes != sizeof(MetadataBlockHeader))
{
memset(&ctx->metadata_block_header, 0, sizeof(MetadataBlockHeader));
FATAL("Could not read metadata block header, continuing...");
TRACE("Exiting process_metadata_block()");
return;
}
if(ctx->metadata_block_header.identifier != entry->blockType)
{
memset(&ctx->metadata_block_header, 0, sizeof(MetadataBlockHeader));
TRACE("Incorrect identifier for data block at position %" PRIu64 "", entry->offset);
TRACE("Exiting process_metadata_block()");
return;
}
ctx->image_info.ImageSize += ctx->metadata_block_header.blockSize;
ctx->metadata_block = (uint8_t *)malloc(ctx->metadata_block_header.blockSize + sizeof(MetadataBlockHeader));
if(ctx->metadata_block == NULL)
{
memset(&ctx->metadata_block_header, 0, sizeof(MetadataBlockHeader));
FATAL("Could not allocate memory for metadata block, continuing...");
TRACE("Exiting process_metadata_block()");
return;
}
TRACE("Reading metadata block of size %u at position %" PRIu64,
ctx->metadata_block_header.blockSize + sizeof(MetadataBlockHeader), entry->offset);
fseek(ctx->imageStream, entry->offset, SEEK_SET);
read_bytes = fread(ctx->metadata_block, 1, ctx->metadata_block_header.blockSize + sizeof(MetadataBlockHeader),
ctx->imageStream);
if(read_bytes != ctx->metadata_block_header.blockSize + sizeof(MetadataBlockHeader))
{
memset(&ctx->metadata_block_header, 0, sizeof(MetadataBlockHeader));
free(ctx->metadata_block);
FATAL("Could not read metadata block, continuing...");
return;
}
if(ctx->metadata_block_header.mediaSequence > 0 && ctx->metadata_block_header.lastMediaSequence > 0)
{
ctx->media_sequence = ctx->metadata_block_header.mediaSequence;
ctx->last_media_sequence = ctx->metadata_block_header.lastMediaSequence;
TRACE("Setting media sequence as %d of %d", ctx->media_sequence, ctx->last_media_sequence);
}
if(ctx->metadata_block_header.creatorLength > 0 &&
ctx->metadata_block_header.creatorOffset + ctx->metadata_block_header.creatorLength <=
ctx->metadata_block_header.blockSize)
{
ctx->creator = (uint8_t *)malloc(ctx->metadata_block_header.creatorLength);
if(ctx->creator != NULL)
memcpy(ctx->creator, ctx->metadata_block + ctx->metadata_block_header.creatorOffset,
ctx->metadata_block_header.creatorLength);
}
if(ctx->metadata_block_header.commentsLength > 0 &&
ctx->metadata_block_header.commentsOffset + ctx->metadata_block_header.commentsLength <=
ctx->metadata_block_header.blockSize)
{
ctx->comments = (uint8_t *)malloc(ctx->metadata_block_header.commentsLength);
if(ctx->comments != NULL)
memcpy(ctx->comments, ctx->metadata_block + ctx->metadata_block_header.commentsOffset,
ctx->metadata_block_header.commentsLength);
}
if(ctx->metadata_block_header.mediaTitleLength > 0 &&
ctx->metadata_block_header.mediaTitleOffset + ctx->metadata_block_header.mediaTitleLength <=
ctx->metadata_block_header.blockSize)
{
ctx->media_title = (uint8_t *)malloc(ctx->metadata_block_header.mediaTitleLength);
if(ctx->media_title != NULL)
memcpy(ctx->media_title, ctx->metadata_block + ctx->metadata_block_header.mediaTitleOffset,
ctx->metadata_block_header.mediaTitleLength);
}
if(ctx->metadata_block_header.mediaManufacturerLength > 0 &&
ctx->metadata_block_header.mediaManufacturerOffset + ctx->metadata_block_header.mediaManufacturerLength <=
ctx->metadata_block_header.blockSize)
{
ctx->media_manufacturer = (uint8_t *)malloc(ctx->metadata_block_header.mediaManufacturerLength);
if(ctx->media_manufacturer != NULL)
memcpy(ctx->media_manufacturer, ctx->metadata_block + ctx->metadata_block_header.mediaManufacturerOffset,
ctx->metadata_block_header.mediaManufacturerLength);
}
if(ctx->metadata_block_header.mediaModelLength > 0 &&
ctx->metadata_block_header.mediaModelOffset + ctx->metadata_block_header.mediaModelLength <=
ctx->metadata_block_header.blockSize)
{
ctx->media_model = (uint8_t *)malloc(ctx->metadata_block_header.mediaModelLength);
if(ctx->media_model != NULL)
memcpy(ctx->media_model, ctx->metadata_block + ctx->metadata_block_header.mediaModelOffset,
ctx->metadata_block_header.mediaModelLength);
}
if(ctx->metadata_block_header.mediaSerialNumberLength > 0 &&
ctx->metadata_block_header.mediaSerialNumberOffset + ctx->metadata_block_header.mediaSerialNumberLength <=
ctx->metadata_block_header.blockSize)
{
ctx->media_serial_number = (uint8_t *)malloc(ctx->metadata_block_header.mediaSerialNumberLength);
if(ctx->media_serial_number != NULL)
memcpy(ctx->media_serial_number, ctx->metadata_block + ctx->metadata_block_header.mediaSerialNumberOffset,
ctx->metadata_block_header.mediaSerialNumberLength);
}
if(ctx->metadata_block_header.mediaBarcodeLength > 0 &&
ctx->metadata_block_header.mediaBarcodeOffset + ctx->metadata_block_header.mediaBarcodeLength <=
ctx->metadata_block_header.blockSize)
{
ctx->media_barcode = (uint8_t *)malloc(ctx->metadata_block_header.mediaBarcodeLength);
if(ctx->media_barcode != NULL)
memcpy(ctx->media_barcode, ctx->metadata_block + ctx->metadata_block_header.mediaBarcodeOffset,
ctx->metadata_block_header.mediaBarcodeLength);
}
if(ctx->metadata_block_header.mediaPartNumberLength > 0 &&
ctx->metadata_block_header.mediaPartNumberOffset + ctx->metadata_block_header.mediaPartNumberLength <=
ctx->metadata_block_header.blockSize)
{
ctx->media_part_number = (uint8_t *)malloc(ctx->metadata_block_header.mediaPartNumberLength);
if(ctx->media_part_number != NULL)
memcpy(ctx->media_part_number, ctx->metadata_block + ctx->metadata_block_header.mediaPartNumberOffset,
ctx->metadata_block_header.mediaPartNumberLength);
}
if(ctx->metadata_block_header.driveManufacturerLength > 0 &&
ctx->metadata_block_header.driveManufacturerOffset + ctx->metadata_block_header.driveManufacturerLength <=
ctx->metadata_block_header.blockSize)
{
ctx->drive_manufacturer = (uint8_t *)malloc(ctx->metadata_block_header.driveManufacturerLength);
if(ctx->drive_manufacturer != NULL)
memcpy(ctx->drive_manufacturer, ctx->metadata_block + ctx->metadata_block_header.driveManufacturerOffset,
ctx->metadata_block_header.driveManufacturerLength);
}
if(ctx->metadata_block_header.driveModelLength > 0 &&
ctx->metadata_block_header.driveModelOffset + ctx->metadata_block_header.driveModelLength <=
ctx->metadata_block_header.blockSize)
{
ctx->drive_model = (uint8_t *)malloc(ctx->metadata_block_header.driveModelLength);
if(ctx->drive_model != NULL)
memcpy(ctx->drive_model, ctx->metadata_block + ctx->metadata_block_header.driveModelOffset,
ctx->metadata_block_header.driveModelLength);
}
if(ctx->metadata_block_header.driveSerialNumberLength > 0 &&
ctx->metadata_block_header.driveSerialNumberOffset + ctx->metadata_block_header.driveSerialNumberLength <=
ctx->metadata_block_header.blockSize)
{
ctx->drive_serial_number = (uint8_t *)malloc(ctx->metadata_block_header.driveSerialNumberLength);
if(ctx->drive_serial_number != NULL)
memcpy(ctx->drive_serial_number, ctx->metadata_block + ctx->metadata_block_header.driveSerialNumberOffset,
ctx->metadata_block_header.driveSerialNumberLength);
}
if(ctx->metadata_block_header.driveFirmwareRevisionLength > 0 &&
ctx->metadata_block_header.driveFirmwareRevisionOffset +
ctx->metadata_block_header.driveFirmwareRevisionLength <=
ctx->metadata_block_header.blockSize)
{
ctx->drive_firmware_revision = (uint8_t *)malloc(ctx->metadata_block_header.driveFirmwareRevisionLength);
if(ctx->drive_firmware_revision != NULL)
memcpy(ctx->drive_firmware_revision,
ctx->metadata_block + ctx->metadata_block_header.driveFirmwareRevisionOffset,
ctx->metadata_block_header.driveFirmwareRevisionLength);
}
TRACE("Exiting process_metadata_block()");
}
void process_geometry_block(aaruformat_context *ctx, const IndexEntry *entry)
{
TRACE("Entering process_geometry_block(%p, %p)", ctx, entry);
size_t read_bytes = 0;
// Check if the context and image stream are valid
if(ctx == NULL || ctx->imageStream == NULL)
{
FATAL("Invalid context or image stream.");
TRACE("Exiting process_geometry_block()");
return;
}
// Seek to block
if(fseek(ctx->imageStream, entry->offset, SEEK_SET) != 0)
{
FATAL("Could not seek to %" PRIu64 " as indicated by index entry...", entry->offset);
TRACE("Exiting process_geometry_block()");
return;
}
TRACE("Reading geometry block header at position %" PRIu64, entry->offset);
read_bytes = fread(&ctx->geometry_block, 1, sizeof(GeometryBlockHeader), ctx->imageStream);
if(read_bytes != sizeof(GeometryBlockHeader))
{
memset(&ctx->geometry_block, 0, sizeof(GeometryBlockHeader));
TRACE("Could not read geometry block header, continuing...");
return;
}
if(ctx->geometry_block.identifier != GeometryBlock)
{
memset(&ctx->geometry_block, 0, sizeof(GeometryBlockHeader));
TRACE("Incorrect identifier for geometry block at position %" PRIu64 "", entry->offset);
return;
}
ctx->image_info.ImageSize += sizeof(GeometryBlockHeader);
TRACE("Geometry set to %d cylinders %d heads %d sectors per track", ctx->geometry_block.cylinders,
ctx->geometry_block.heads, ctx->geometry_block.sectorsPerTrack);
ctx->cylinders = ctx->geometry_block.cylinders;
ctx->heads = ctx->geometry_block.heads;
ctx->sectors_per_track = ctx->geometry_block.sectorsPerTrack;
TRACE("Exiting process_geometry_block()");
}
void process_cicm_block(aaruformat_context *ctx, const IndexEntry *entry)
{
TRACE("Entering process_cicm_block(%p, %p)", ctx, entry);
int pos = 0;
size_t read_bytes = 0;
// Check if the context and image stream are valid
if(ctx == NULL || ctx->imageStream == NULL)
{
FATAL("Invalid context or image stream.");
TRACE("Exiting process_cicm_block()");
return;
}
// Seek to block
TRACE("Seeking to CICM XML metadata block at position %" PRIu64, entry->offset);
pos = fseek(ctx->imageStream, entry->offset, SEEK_SET);
if(pos < 0 || ftell(ctx->imageStream) != entry->offset)
{
FATAL("Could not seek to %" PRIu64 " as indicated by index entry...", entry->offset);
TRACE("Exiting process_cicm_block()");
return;
}
// Even if those two checks shall have been done before
TRACE("Reading CICM XML metadata block header at position %" PRIu64, entry->offset);
read_bytes = fread(&ctx->cicm_block_header, 1, sizeof(CicmMetadataBlock), ctx->imageStream);
if(read_bytes != sizeof(CicmMetadataBlock))
{
memset(&ctx->cicm_block_header, 0, sizeof(CicmMetadataBlock));
TRACE("Could not read CICM XML metadata header, continuing...");
return;
}
if(ctx->cicm_block_header.identifier != CicmBlock)
{
memset(&ctx->cicm_block_header, 0, sizeof(CicmMetadataBlock));
TRACE("Incorrect identifier for data block at position %" PRIu64 "", entry->offset);
}
ctx->image_info.ImageSize += ctx->cicm_block_header.length;
ctx->cicm_block = (uint8_t *)malloc(ctx->cicm_block_header.length);
if(ctx->cicm_block == NULL)
{
memset(&ctx->cicm_block_header, 0, sizeof(CicmMetadataBlock));
TRACE("Could not allocate memory for CICM XML metadata block, continuing...");
TRACE("Exiting process_cicm_block()");
return;
}
TRACE("Reading CICM XML metadata block of size %u at position %" PRIu64, ctx->cicm_block_header.length,
entry->offset + sizeof(CicmMetadataBlock));
read_bytes = fread(ctx->cicm_block, 1, ctx->cicm_block_header.length, ctx->imageStream);
if(read_bytes != ctx->cicm_block_header.length)
{
memset(&ctx->cicm_block_header, 0, sizeof(CicmMetadataBlock));
free(ctx->cicm_block);
TRACE("Could not read CICM XML metadata block, continuing...");
}
TRACE("Found CICM XML metadata block %" PRIu64 ".", entry->offset);
TRACE("Exiting process_cicm_block()");
}
void process_aaru_metadata_json_block(aaruformat_context *ctx, const IndexEntry *entry)
{
TRACE("Entering process_aaru_metadata_json_block(%p, %p)", ctx, entry);
int pos = 0;
size_t read_bytes = 0;
// Check if the context and image stream are valid
if(ctx == NULL || ctx->imageStream == NULL)
{
FATAL("Invalid context or image stream.");
TRACE("Exiting process_aaru_metadata_json_block()");
return;
}
// Seek to block
TRACE("Seeking to Aaru metadata JSON block at position %" PRIu64, entry->offset);
pos = fseek(ctx->imageStream, entry->offset, SEEK_SET);
if(pos < 0 || ftell(ctx->imageStream) != entry->offset)
{
FATAL("Could not seek to %" PRIu64 " as indicated by index entry...", entry->offset);
TRACE("Exiting process_aaru_metadata_json_block()");
return;
}
// Even if those two checks shall have been done before
TRACE("Reading Aaru metadata JSON block header at position %" PRIu64, entry->offset);
read_bytes = fread(&ctx->json_block_header, 1, sizeof(AaruMetadataJsonBlockHeader), ctx->imageStream);
if(read_bytes != sizeof(AaruMetadataJsonBlockHeader))
{
memset(&ctx->json_block_header, 0, sizeof(AaruMetadataJsonBlockHeader));
TRACE("Could not read Aaru metadata JSON header, continuing...");
return;
}
if(ctx->json_block_header.identifier != AaruMetadataJsonBlock)
{
memset(&ctx->json_block_header, 0, sizeof(AaruMetadataJsonBlockHeader));
TRACE("Incorrect identifier for data block at position %" PRIu64 "", entry->offset);
}
ctx->image_info.ImageSize += ctx->json_block_header.length;
ctx->json_block = (uint8_t *)malloc(ctx->json_block_header.length);
if(ctx->json_block == NULL)
{
memset(&ctx->json_block_header, 0, sizeof(AaruMetadataJsonBlockHeader));
TRACE("Could not allocate memory for Aaru metadata JSON block, continuing...");
TRACE("Exiting process_aaru_metadata_json_block()");
return;
}
TRACE("Reading Aaru metadata JSON block of size %u at position %" PRIu64, ctx->json_block_header.length,
entry->offset + sizeof(AaruMetadataJsonBlockHeader));
read_bytes = fread(ctx->json_block, 1, ctx->json_block_header.length, ctx->imageStream);
if(read_bytes != ctx->json_block_header.length)
{
memset(&ctx->json_block_header, 0, sizeof(AaruMetadataJsonBlockHeader));
free(ctx->json_block);
TRACE("Could not read Aaru metadata JSON block, continuing...");
}
TRACE("Found Aaru metadata JSON block %" PRIu64 ".", entry->offset);
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;
}
AARU_EXPORT int32_t AARU_CALL aaruf_get_readable_media_tags(const void *context, uint8_t *buffer, size_t *length)
{
TRACE("Entering aaruf_get_readable_media_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_media_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_media_tags() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
// Required size: one byte for each MediaTagType (0 to MaxMediaTag)
size_t required_length = MaxMediaTag + 1;
if(buffer == NULL || length == NULL || *length < required_length)
{
if(length) *length = required_length;
TRACE("Buffer too small for readable media tags, required %zu bytes", required_length);
TRACE("Exiting aaruf_get_readable_media_tags() = AARUF_ERROR_BUFFER_TOO_SMALL");
return AARUF_ERROR_BUFFER_TOO_SMALL;
}
// Initialize all bytes to false (0)
memset(buffer, 0, required_length);
// Iterate through all media tag types and mark present ones as true
for(int32_t tag_type = 0; tag_type <= MaxMediaTag; tag_type++)
{
mediaTagEntry *item = NULL;
HASH_FIND_INT(ctx->mediaTags, &tag_type, item);
if(item != NULL)
{
buffer[tag_type] = 1;
TRACE("Media tag type %d is present", tag_type);
}
}
*length = required_length;
TRACE("Exiting aaruf_get_readable_media_tags(%p, %p, %zu) = AARUF_STATUS_OK", context, buffer, *length);
return AARUF_STATUS_OK;
}
aaruformat.h
process_metadata_block
void process_metadata_block(aaruformat_context *ctx, const IndexEntry *entry)
Processes a metadata block from the image stream.
Definition metadata.c:35
process_cicm_block
void process_cicm_block(aaruformat_context *ctx, const IndexEntry *entry)
Processes a CICM XML metadata block from the image stream.
Definition metadata.c:311
process_geometry_block
void process_geometry_block(aaruformat_context *ctx, const IndexEntry *entry)
Processes a logical geometry block from the image stream.
Definition metadata.c:251
process_aaru_metadata_json_block
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.
Definition metadata.c:475
aaruf_get_readable_media_tags
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.
Definition metadata.c:711
aaruf_get_readable_sector_tags
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.
Definition metadata.c:623
AARU_MAGIC
#define AARU_MAGIC
Magic identifier for AaruFormat container (ASCII "AARUFRMT").
Definition consts.h:64
AARU_CALL
#define AARU_CALL
Definition decls.h:46
AARU_EXPORT
#define AARU_EXPORT
Definition decls.h:55
GeometryBlock
@ GeometryBlock
Block containing logical geometry.
Definition enums.h:152
AaruMetadataJsonBlock
@ AaruMetadataJsonBlock
Block containing JSON version of Aaru Metadata.
Definition enums.h:163
CicmBlock
@ CicmBlock
Block containing CICM XML metadata.
Definition enums.h:155
AARUF_STATUS_OK
#define AARUF_STATUS_OK
Sector present and read without uncorrectable errors.
Definition errors.h:77
AARUF_ERROR_METADATA_NOT_PRESENT
#define AARUF_ERROR_METADATA_NOT_PRESENT
Requested metadata not present in image.
Definition errors.h:69
AARUF_ERROR_NOT_AARUFORMAT
#define AARUF_ERROR_NOT_AARUFORMAT
Input file/stream failed magic or structural validation.
Definition errors.h:40
AARUF_ERROR_BUFFER_TOO_SMALL
#define AARUF_ERROR_BUFFER_TOO_SMALL
Caller-supplied buffer insufficient for data.
Definition errors.h:49
MaxMediaTag
@ MaxMediaTag
Definition aaru.h:1074
MaxSectorTag
@ MaxSectorTag
Definition aaru.h:980
log.h
FATAL
#define FATAL(fmt,...)
Definition log.h:40
TRACE
#define TRACE(fmt,...)
Definition log.h:25
AaruMetadataJsonBlockHeader
Header for an Aaru metadata JSON block (identifier == BlockType::AaruMetadataJsonBlock).
Definition metadata.h:120
AaruMetadataJsonBlockHeader::identifier
uint32_t identifier
Block identifier, must be BlockType::AaruMetadataJsonBlock.
Definition metadata.h:121
AaruMetadataJsonBlockHeader::length
uint32_t length
Length in bytes of the Aaru metadata JSON payload that follows.
Definition metadata.h:122
CicmMetadataBlock
Header for a CICM XML metadata block (identifier == BlockType::CicmBlock).
Definition metadata.h:108
CicmMetadataBlock::length
uint32_t length
Length in bytes of the CICM metadata payload that follows.
Definition metadata.h:110
CicmMetadataBlock::identifier
uint32_t identifier
Block identifier, must be BlockType::CicmBlock.
Definition metadata.h:109
GeometryBlockHeader
Legacy CHS style logical geometry metadata (BlockType::GeometryBlock).
Definition data.h:91
GeometryBlockHeader::identifier
uint32_t identifier
Block identifier, must be BlockType::GeometryBlock.
Definition data.h:92
GeometryBlockHeader::cylinders
uint32_t cylinders
Number of cylinders.
Definition data.h:93
GeometryBlockHeader::heads
uint32_t heads
Number of heads (tracks per cylinder).
Definition data.h:94
GeometryBlockHeader::sectorsPerTrack
uint32_t sectorsPerTrack
Number of sectors per track.
Definition data.h:95
ImageInfo::ImageSize
uint64_t ImageSize
Size of the image payload in bytes (excludes headers/metadata).
Definition aaru.h:935
IndexEntry
Single index entry describing a block's type, (optional) data classification, and file offset.
Definition index.h:109
IndexEntry::blockType
uint32_t blockType
Block identifier of the referenced block (value from BlockType).
Definition index.h:110
IndexEntry::offset
uint64_t offset
Absolute byte offset in the image where the referenced block header begins.
Definition index.h:112
MetadataBlockHeader
Header for a metadata block containing offsets and lengths to UTF-16LE descriptive strings.
Definition metadata.h:69
MetadataBlockHeader::commentsLength
uint32_t commentsLength
Length in bytes (including null) of comments string.
Definition metadata.h:78
MetadataBlockHeader::mediaSequence
int32_t mediaSequence
Sequence number within a multi-disc / multi-volume set (0-based or 1-based as producer defines).
Definition metadata.h:72
MetadataBlockHeader::identifier
uint32_t identifier
Block identifier, must be BlockType::MetadataBlock.
Definition metadata.h:70
MetadataBlockHeader::mediaTitleOffset
uint32_t mediaTitleOffset
Offset to UTF-16LE media title string.
Definition metadata.h:79
MetadataBlockHeader::driveModelLength
uint32_t driveModelLength
Length in bytes (including null) of drive model string.
Definition metadata.h:94
MetadataBlockHeader::driveManufacturerLength
uint32_t driveManufacturerLength
Length in bytes (including null) of drive manufacturer string.
Definition metadata.h:92
MetadataBlockHeader::blockSize
uint32_t blockSize
Total size in bytes of the entire metadata block (header + strings).
Definition metadata.h:71
MetadataBlockHeader::driveModelOffset
uint32_t driveModelOffset
Offset to UTF-16LE drive model string.
Definition metadata.h:93
MetadataBlockHeader::mediaModelOffset
uint32_t mediaModelOffset
Offset to UTF-16LE media model string.
Definition metadata.h:83
MetadataBlockHeader::creatorOffset
uint32_t creatorOffset
Offset to UTF-16LE creator string (or undefined if creatorLength==0).
Definition metadata.h:75
MetadataBlockHeader::mediaTitleLength
uint32_t mediaTitleLength
Length in bytes (including null) of media title string.
Definition metadata.h:80
MetadataBlockHeader::mediaManufacturerOffset
uint32_t mediaManufacturerOffset
Offset to UTF-16LE media manufacturer string.
Definition metadata.h:81
MetadataBlockHeader::driveSerialNumberLength
uint32_t driveSerialNumberLength
Length in bytes (including null) of drive serial number string.
Definition metadata.h:96
MetadataBlockHeader::driveSerialNumberOffset
uint32_t driveSerialNumberOffset
Offset to UTF-16LE drive serial number string.
Definition metadata.h:95
MetadataBlockHeader::mediaManufacturerLength
uint32_t mediaManufacturerLength
Length in bytes (including null) of media manufacturer string.
Definition metadata.h:82
MetadataBlockHeader::mediaModelLength
uint32_t mediaModelLength
Length in bytes (including null) of media model string.
Definition metadata.h:84
MetadataBlockHeader::driveFirmwareRevisionOffset
uint32_t driveFirmwareRevisionOffset
Offset to UTF-16LE drive firmware revision string.
Definition metadata.h:97
MetadataBlockHeader::lastMediaSequence
int32_t lastMediaSequence
Total number of media in the set; 0 or 1 if single item.
Definition metadata.h:74
MetadataBlockHeader::commentsOffset
uint32_t commentsOffset
Offset to UTF-16LE comments string.
Definition metadata.h:77
MetadataBlockHeader::driveManufacturerOffset
uint32_t driveManufacturerOffset
Offset to UTF-16LE drive manufacturer string.
Definition metadata.h:91
MetadataBlockHeader::mediaSerialNumberOffset
uint32_t mediaSerialNumberOffset
Offset to UTF-16LE media serial number string.
Definition metadata.h:85
MetadataBlockHeader::mediaSerialNumberLength
uint32_t mediaSerialNumberLength
Length in bytes (including null) of media serial number string.
Definition metadata.h:86
MetadataBlockHeader::mediaPartNumberOffset
uint32_t mediaPartNumberOffset
Offset to UTF-16LE media part number string.
Definition metadata.h:89
MetadataBlockHeader::mediaPartNumberLength
uint32_t mediaPartNumberLength
Length in bytes (including null) of media part number string.
Definition metadata.h:90
MetadataBlockHeader::mediaBarcodeLength
uint32_t mediaBarcodeLength
Length in bytes (including null) of media barcode string.
Definition metadata.h:88
MetadataBlockHeader::creatorLength
uint32_t creatorLength
Length in bytes (including null) of creator string (0 if absent).
Definition metadata.h:76
MetadataBlockHeader::driveFirmwareRevisionLength
uint32_t driveFirmwareRevisionLength
Length in bytes (including null) of drive firmware revision string.
Definition metadata.h:98
MetadataBlockHeader::mediaBarcodeOffset
uint32_t mediaBarcodeOffset
Offset to UTF-16LE media barcode string.
Definition metadata.h:87
aaruformat_context
Master context representing an open or in‑creation Aaru image.
Definition context.h:175
aaruformat_context::media_barcode
uint8_t * media_barcode
Barcode of the media represented by the image.
Definition context.h:225
aaruformat_context::creator
uint8_t * creator
Who (person) created the image?
Definition context.h:219
aaruformat_context::cicm_block
uint8_t * cicm_block
CICM XML payload.
Definition context.h:217
aaruformat_context::cylinders
uint32_t cylinders
Cylinders of the media represented by the image.
Definition context.h:237
aaruformat_context::drive_firmware_revision
uint8_t * drive_firmware_revision
Firmware revision of the drive used to read the media represented by the image.
Definition context.h:231
aaruformat_context::media_serial_number
uint8_t * media_serial_number
Serial number of the media represented by the image.
Definition context.h:224
aaruformat_context::metadata_block_header
MetadataBlockHeader metadata_block_header
Metadata block header.
Definition context.h:233
aaruformat_context::media_sequence
int32_t media_sequence
Number in sequence for the media represented by the image.
Definition context.h:241
aaruformat_context::media_model
uint8_t * media_model
Model of the media represented by the image.
Definition context.h:223
aaruformat_context::drive_serial_number
uint8_t * drive_serial_number
Serial number of the drive used to read the media represented by the image.
Definition context.h:229
aaruformat_context::drive_manufacturer
uint8_t * drive_manufacturer
Manufacturer of the drive used to read the media represented by the image.
Definition context.h:227
aaruformat_context::cicm_block_header
CicmMetadataBlock cicm_block_header
CICM metadata header (if present).
Definition context.h:234
aaruformat_context::drive_model
uint8_t * drive_model
Model of the drive used to read the media represented by the image.
Definition context.h:228
aaruformat_context::magic
uint64_t magic
File magic (AARU_MAGIC) post-open.
Definition context.h:177
aaruformat_context::mediaTags
mediaTagEntry * mediaTags
Hash table of extra media tags (uthash root).
Definition context.h:267
aaruformat_context::geometry_block
GeometryBlockHeader geometry_block
Logical geometry block (if present).
Definition context.h:232
aaruformat_context::json_block
uint8_t * json_block
JSON metadata block payload (UTF-8).
Definition context.h:218
aaruformat_context::media_part_number
uint8_t * media_part_number
Part number of the media represented by the image.
Definition context.h:226
aaruformat_context::json_block_header
AaruMetadataJsonBlockHeader json_block_header
JSON metadata block header (if present).
Definition context.h:236
aaruformat_context::sectors_per_track
uint32_t sectors_per_track
Sectors per track of the media represented by the image (for variable image, the smallest).
Definition context.h:239
aaruformat_context::comments
uint8_t * comments
Image comments.
Definition context.h:221
aaruformat_context::heads
uint32_t heads
Heads of the media represented by the image.
Definition context.h:238
aaruformat_context::imageStream
FILE * imageStream
Underlying FILE* stream (binary mode).
Definition context.h:179
aaruformat_context::image_info
ImageInfo image_info
Exposed high-level image info summary.
Definition context.h:263
aaruformat_context::readableSectorTags
bool * readableSectorTags
Per-sector boolean array (optical tags read successfully?).
Definition context.h:266
aaruformat_context::metadata_block
uint8_t * metadata_block
Raw metadata UTF-16LE concatenated strings.
Definition context.h:216
aaruformat_context::media_title
uint8_t * media_title
Title of the media represented by the image.
Definition context.h:220
aaruformat_context::last_media_sequence
int32_t last_media_sequence
Last media of the sequence the media represented by the image corresponds to.
Definition context.h:242
aaruformat_context::media_manufacturer
uint8_t * media_manufacturer
Manufacturer of the media represented by the image.
Definition context.h:222
mediaTagEntry
Hash table entry for an arbitrary media tag (e.g., proprietary drive/medium descriptor).
Definition context.h:122