Loading...
Searching...
No Matches
open.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 <errno.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <aaruformat.h>
#include "internal.h"
#include "log.h"
#include "utarray.h"
static void cleanup_open_failure(aaruformat_context *ctx)
{
if(ctx == NULL) return;
if(ctx->imageStream != NULL)
{
fclose(ctx->imageStream);
ctx->imageStream = NULL;
}
free(ctx->readableSectorTags);
ctx->readableSectorTags = NULL;
free(ctx);
}
AARU_EXPORT void AARU_CALL *aaruf_open(const char *filepath, const bool resume_mode,
const char *options) // NOLINT(readability-function-size)
{
aaruformat_context *ctx = NULL;
int error_no = 0;
size_t read_bytes = 0;
long pos = 0;
int i = 0;
uint32_t signature = 0;
UT_array *index_entries = NULL;
#ifdef USE_SLOG
#include "slog.h"
slog_init("aaruformat.log", SLOG_FLAGS_ALL, 0);
#endif
TRACE("Logging initialized");
TRACE("Entering aaruf_open(%s)", filepath);
TRACE("Allocating memory for context");
ctx = (aaruformat_context *)malloc(sizeof(aaruformat_context));
if(ctx == NULL)
{
FATAL("Not enough memory to create context");
errno = AARUF_ERROR_NOT_ENOUGH_MEMORY;
TRACE("Exiting aaruf_open() = NULL");
return NULL;
}
memset(ctx, 0, sizeof(aaruformat_context));
TRACE("Opening file %s", filepath);
if(resume_mode)
ctx->imageStream = fopen(filepath, "r+b");
else
ctx->imageStream = fopen(filepath, "rb");
if(ctx->imageStream == NULL)
{
FATAL("Error %d opening file %s for reading", errno, filepath);
error_no = errno;
cleanup_open_failure(ctx);
errno = error_no;
TRACE("Exiting aaruf_open() = NULL");
return NULL;
}
TRACE("Reading header at position 0");
fseek(ctx->imageStream, 0, SEEK_SET);
read_bytes = fread(&ctx->header, 1, sizeof(AaruHeader), ctx->imageStream);
if(read_bytes != sizeof(AaruHeader))
{
FATAL("Could not read header");
cleanup_open_failure(ctx);
errno = AARUF_ERROR_FILE_TOO_SMALL;
TRACE("Exiting aaruf_open() = NULL");
return NULL;
}
if(ctx->header.identifier != DIC_MAGIC && ctx->header.identifier != AARU_MAGIC)
{
FATAL("Incorrect identifier for AaruFormat file: %8.8s", (char *)&ctx->header.identifier);
cleanup_open_failure(ctx);
errno = AARUF_ERROR_NOT_AARUFORMAT;
TRACE("Exiting aaruf_open() = NULL");
return NULL;
}
if(ctx->header.imageMajorVersion < AARUF_VERSION_V2 && resume_mode)
{
TRACE("Cannot write to old images");
cleanup_open_failure(ctx);
errno = AARUF_ERROR_INCOMPATIBLE_VERSION;
TRACE("Exiting aaruf_open() = NULL");
return NULL;
}
// Read new header version
if(ctx->header.imageMajorVersion >= AARUF_VERSION_V2)
{
TRACE("Reading new header version at position 0");
fseek(ctx->imageStream, 0, SEEK_SET);
read_bytes = fread(&ctx->header, 1, sizeof(AaruHeaderV2), ctx->imageStream);
if(read_bytes != sizeof(AaruHeaderV2))
{
cleanup_open_failure(ctx);
errno = AARUF_ERROR_FILE_TOO_SMALL;
return NULL;
}
}
if(ctx->header.imageMajorVersion > AARUF_VERSION)
{
FATAL("Incompatible AaruFormat version %d.%d found, maximum supported is %d.%d", ctx->header.imageMajorVersion,
ctx->header.imageMinorVersion, AARUF_VERSION_V2, 0);
cleanup_open_failure(ctx);
errno = AARUF_ERROR_INCOMPATIBLE_VERSION;
TRACE("Exiting aaruf_open() = NULL");
return NULL;
}
TRACE("Opening image version %d.%d", ctx->header.imageMajorVersion, ctx->header.imageMinorVersion);
TRACE("Allocating memory for readable sector tags bitmap");
ctx->readableSectorTags = (bool *)malloc(sizeof(bool) * MaxSectorTag);
if(ctx->readableSectorTags == NULL)
{
FATAL("Could not allocate memory for readable sector tags bitmap");
cleanup_open_failure(ctx);
errno = AARUF_ERROR_NOT_ENOUGH_MEMORY;
TRACE("Exiting aaruf_open() = NULL");
return NULL;
}
memset(ctx->readableSectorTags, 0, sizeof(bool) * MaxSectorTag);
TRACE("Setting up image info");
// Handle application name based on image version
memset(ctx->image_info.Application, 0, 64);
if(ctx->header.imageMajorVersion >= AARUF_VERSION_V2)
{
// Version 2+: application name is UTF-8, direct copy
TRACE("Converting application name (v2+): UTF-8 direct copy");
size_t copy_len = AARU_HEADER_APP_NAME_LEN < 63 ? AARU_HEADER_APP_NAME_LEN : 63;
memcpy(ctx->image_info.Application, ctx->header.application, copy_len);
ctx->image_info.Application[63] = '\0';
}
else
{
// Version 1: application name is UTF-16LE, convert by taking every other byte
TRACE("Converting application name (v1): UTF-16LE to ASCII");
int dest_idx = 0;
for(int j = 0; j < AARU_HEADER_APP_NAME_LEN && dest_idx < 63; j += 2)
// Take the low byte, skip the high byte (assuming it's 0x00 for ASCII)
if(ctx->header.application[j] != 0)
ctx->image_info.Application[dest_idx++] = ctx->header.application[j];
else
// Stop at null terminator
break;
ctx->image_info.Application[dest_idx] = '\0';
}
// Set application version string directly in the fixed-size array
memset(ctx->image_info.ApplicationVersion, 0, 32);
sprintf(ctx->image_info.ApplicationVersion, "%d.%d", ctx->header.applicationMajorVersion,
ctx->header.applicationMinorVersion);
// Set image version string directly in the fixed-size array
memset(ctx->image_info.Version, 0, 32);
sprintf(ctx->image_info.Version, "%d.%d", ctx->header.imageMajorVersion, ctx->header.imageMinorVersion);
ctx->image_info.MediaType = ctx->header.mediaType;
// Read the index header
TRACE("Reading index header at position %" PRIu64, ctx->header.indexOffset);
pos = fseek(ctx->imageStream, ctx->header.indexOffset, SEEK_SET);
if(pos < 0)
{
cleanup_open_failure(ctx);
errno = AARUF_ERROR_CANNOT_READ_INDEX;
return NULL;
}
pos = ftell(ctx->imageStream);
if(pos != ctx->header.indexOffset)
{
cleanup_open_failure(ctx);
errno = AARUF_ERROR_CANNOT_READ_INDEX;
return NULL;
}
read_bytes = fread(&signature, 1, sizeof(uint32_t), ctx->imageStream);
if(read_bytes != sizeof(uint32_t) ||
(signature != IndexBlock && signature != IndexBlock2 && signature != IndexBlock3))
{
FATAL("Could not read index header or incorrect identifier %4.4s", (char *)&signature);
cleanup_open_failure(ctx);
errno = AARUF_ERROR_CANNOT_READ_INDEX;
TRACE("Exiting aaruf_open() = NULL");
return NULL;
}
if(signature == IndexBlock)
index_entries = process_index_v1(ctx);
else if(signature == IndexBlock2)
index_entries = process_index_v2(ctx);
else if(signature == IndexBlock3)
index_entries = process_index_v3(ctx);
if(index_entries == NULL)
{
FATAL("Could not process index.");
utarray_free(index_entries);
cleanup_open_failure(ctx);
errno = AARUF_ERROR_CANNOT_READ_INDEX;
TRACE("Exiting aaruf_open() = NULL");
return NULL;
}
TRACE("Index at %" PRIu64 " contains %d entries", ctx->header.indexOffset, utarray_len(index_entries));
for(i = 0; i < utarray_len(index_entries); i++)
{
IndexEntry *entry = utarray_eltptr(index_entries, i);
TRACE("Block type %4.4s with data type %d is indexed to be at %" PRIu64 "", (char *)&entry->blockType,
entry->dataType, entry->offset);
}
bool found_user_data_ddt = false;
ctx->image_info.ImageSize = 0;
for(i = 0; i < utarray_len(index_entries); i++)
{
IndexEntry *entry = utarray_eltptr(index_entries, i);
pos = fseek(ctx->imageStream, entry->offset, SEEK_SET);
if(pos < 0 || ftell(ctx->imageStream) != entry->offset)
{
TRACE("Could not seek to %" PRIu64 " as indicated by index entry %d, continuing...", entry->offset, i);
continue;
}
TRACE("Processing block type %4.4s with data type %d at position %" PRIu64 "", (char *)&entry->blockType,
entry->dataType, entry->offset);
switch(entry->blockType)
{
case DataBlock:
if(entry->dataType == UserData && ctx->header.biggestSectorSize > 0)
break;
error_no = process_data_block(ctx, entry);
if(error_no != AARUF_STATUS_OK)
{
utarray_free(index_entries);
cleanup_open_failure(ctx);
errno = error_no;
return NULL;
}
break;
case DeDuplicationTable:
error_no = process_ddt_v1(ctx, entry, &found_user_data_ddt);
if(error_no != AARUF_STATUS_OK)
{
utarray_free(index_entries);
cleanup_open_failure(ctx);
errno = error_no;
return NULL;
}
break;
case DeDuplicationTable2:
error_no = process_ddt_v2(ctx, entry, &found_user_data_ddt);
if(error_no != AARUF_STATUS_OK)
{
utarray_free(index_entries);
cleanup_open_failure(ctx);
errno = error_no;
return NULL;
}
break;
case GeometryBlock:
process_geometry_block(ctx, entry);
break;
case MetadataBlock:
process_metadata_block(ctx, entry);
break;
case TracksBlock:
process_tracks_block(ctx, entry);
break;
case CicmBlock:
process_cicm_block(ctx, entry);
break;
case AaruMetadataJsonBlock:
process_aaru_metadata_json_block(ctx, entry);
break;
// Dump hardware block
case DumpHardwareBlock:
process_dumphw_block(ctx, entry);
break;
case ChecksumBlock:
process_checksum_block(ctx, entry);
break;
case TapeFileBlock:
process_tape_files_block(ctx, entry);
break;
case TapePartitionBlock:
process_tape_partitions_block(ctx, entry);
break;
case FluxDataBlock:
// Store the FluxDataBlock offset for lazy loading
// Don't read flux entries during open - load them on-demand when actually needed
// This avoids unnecessary I/O if flux data is never accessed
break;
default:
TRACE("Unhandled block type %4.4s with data type %d is indexed to be at %" PRIu64 "",
(char *)&entry->blockType, entry->dataType, entry->offset);
break;
}
}
ctx->index_entries = index_entries;
if(!found_user_data_ddt)
{
FATAL("Could not find user data deduplication table, aborting...");
aaruf_close(ctx);
TRACE("Exiting aaruf_open() = NULL");
return NULL;
}
if(ctx->header.biggestSectorSize != 0)
{
TRACE("Setting sector size to %u bytes", ctx->header.biggestSectorSize);
ctx->image_info.SectorSize = ctx->header.biggestSectorSize;
}
ctx->image_info.CreationTime = ctx->header.creationTime;
ctx->image_info.LastModificationTime = ctx->header.lastWrittenTime;
ctx->image_info.MetadataMediaType = aaruf_get_xml_mediatype(ctx->header.mediaType);
if(ctx->geometry_block.identifier != GeometryBlock && ctx->image_info.MetadataMediaType == BlockMedia)
{
ctx->cylinders = (uint32_t)(ctx->image_info.Sectors / 16 / 63);
ctx->heads = 16;
ctx->sectors_per_track = 63;
}
// Initialize caches
TRACE("Initializing caches");
ctx->block_header_cache.cache = NULL;
ctx->block_cache.cache = NULL;
// Set free functions for cached values (both cache malloc'd data)
ctx->block_header_cache.free_func = free;
ctx->block_cache.free_func = free;
const uint64_t cache_divisor = (uint64_t)ctx->image_info.SectorSize * (1ULL << ctx->shift);
if(cache_divisor == 0)
{
ctx->block_header_cache.max_items = 0;
ctx->block_cache.max_items = 0;
}
else
{
ctx->block_header_cache.max_items = MAX_CACHE_SIZE / cache_divisor;
ctx->block_cache.max_items = ctx->block_header_cache.max_items;
}
// TODO: Cache tracks and sessions?
// Initialize ECC for Compact Disc
TRACE("Initializing ECC for Compact Disc");
ctx->ecc_cd_context = (CdEccContext *)aaruf_ecc_cd_init();
ctx->magic = AARU_MAGIC;
ctx->library_major_version = LIBAARUFORMAT_MAJOR_VERSION;
ctx->library_minor_version = LIBAARUFORMAT_MINOR_VERSION;
if(!resume_mode)
{
TRACE("Exiting aaruf_open() = %p", ctx);
return ctx;
}
// Parse the options
TRACE("Parsing options");
bool table_shift_found = false;
const aaru_options parsed_options = parse_options(options, &table_shift_found);
ctx->header.lastWrittenTime = get_filetime_uint64();
ctx->image_info.LastModificationTime = ctx->header.lastWrittenTime;
// Calculate aligned next block position
fseek(ctx->imageStream, 0, SEEK_END);
const uint64_t alignment_mask = (1ULL << ctx->user_data_ddt_header.blockAlignmentShift) - 1;
ctx->next_block_position = ftell(ctx->imageStream); // Start just after the header
ctx->next_block_position = ctx->next_block_position + alignment_mask & ~alignment_mask;
TRACE("Data blocks will start at position %" PRIu64, ctx->next_block_position);
// Position file pointer at the data start position
if(fseek(ctx->imageStream, ctx->next_block_position, SEEK_SET) != 0)
{
FATAL("Could not seek to data start position");
errno = AARUF_ERROR_CANNOT_CREATE_FILE;
TRACE("Exiting aaruf_open() = NULL");
cleanup_open_failure(ctx);
return NULL;
}
// Apply applicable options (we cannot change table or alignment options resuming)
ctx->compression_enabled = parsed_options.compress;
ctx->lzma_dict_size = parsed_options.dictionary;
ctx->deduplicate = parsed_options.deduplicate;
if(ctx->deduplicate)
ctx->sector_hash_map = create_map(ctx->user_data_ddt_header.blocks * 25 / 100); // 25% of total sectors
// Cannot checksum a resumed file
ctx->rewinded = true;
// Is writing
ctx->is_writing = true;
TRACE("Exiting aaruf_open() = %p", ctx);
// Return context
return ctx;
}
aaruformat.h
LIBAARUFORMAT_MAJOR_VERSION
#define LIBAARUFORMAT_MAJOR_VERSION
Definition aaruformat.h:22
LIBAARUFORMAT_MINOR_VERSION
#define LIBAARUFORMAT_MINOR_VERSION
Definition aaruformat.h:23
DIC_MAGIC
#define DIC_MAGIC
Magic identifier for legacy DiscImageChef container (ASCII "DICMFRMT").
Definition consts.h:61
AARU_MAGIC
#define AARU_MAGIC
Magic identifier for AaruFormat container (ASCII "AARUFRMT").
Definition consts.h:64
MAX_CACHE_SIZE
#define MAX_CACHE_SIZE
Maximum read cache size (bytes).
Definition consts.h:79
AARUF_VERSION_V2
#define AARUF_VERSION_V2
Second on‑disk version (C implementation).
Definition consts.h:75
AARUF_VERSION
#define AARUF_VERSION
Current image format major version (incompatible changes bump this).
Definition consts.h:68
AARU_CALL
#define AARU_CALL
Definition decls.h:46
aaruf_close
int aaruf_close(void *context)
Close an Aaru image context, flushing pending data structures and releasing resources.
Definition close.c:5011
AARU_EXPORT
#define AARU_EXPORT
Definition decls.h:55
aaruf_ecc_cd_init
void * aaruf_ecc_cd_init()
Initializes a Compact Disc ECC context.
Definition ecc_cd.c:35
aaruf_get_xml_mediatype
int32_t aaruf_get_xml_mediatype(int32_t type)
Definition helpers.c:351
IndexBlock3
@ IndexBlock3
Block containing the index v3.
Definition enums.h:151
ChecksumBlock
@ ChecksumBlock
Block containing contents checksums.
Definition enums.h:156
DataBlock
@ DataBlock
Block containing data.
Definition enums.h:144
TapePartitionBlock
@ TapePartitionBlock
Block containing list of partitions for a tape image.
Definition enums.h:162
IndexBlock2
@ IndexBlock2
Block containing the index v2.
Definition enums.h:150
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
IndexBlock
@ IndexBlock
Block containing the index (v1).
Definition enums.h:149
DeDuplicationTable2
@ DeDuplicationTable2
Block containing a deduplication table v2.
Definition enums.h:146
TapeFileBlock
@ TapeFileBlock
Block containing list of files for a tape image.
Definition enums.h:161
DeDuplicationTable
@ DeDuplicationTable
Block containing a deduplication table (v1).
Definition enums.h:145
DumpHardwareBlock
@ DumpHardwareBlock
Block containing an array of hardware used to create the image.
Definition enums.h:160
MetadataBlock
@ MetadataBlock
Block containing metadata.
Definition enums.h:153
TracksBlock
@ TracksBlock
Block containing optical disc tracks.
Definition enums.h:154
FluxDataBlock
@ FluxDataBlock
Block containing flux data metadata.
Definition enums.h:164
BlockMedia
@ BlockMedia
Media that is physically block-based or abstracted like that.
Definition enums.h:225
UserData
@ UserData
User (main) data.
Definition enums.h:46
AARUF_ERROR_CANNOT_CREATE_FILE
#define AARUF_ERROR_CANNOT_CREATE_FILE
Output file could not be created / opened for write.
Definition errors.h:58
AARUF_STATUS_OK
#define AARUF_STATUS_OK
Sector present and read without uncorrectable errors.
Definition errors.h:77
AARUF_ERROR_NOT_ENOUGH_MEMORY
#define AARUF_ERROR_NOT_ENOUGH_MEMORY
Memory allocation failure (critical).
Definition errors.h:48
AARUF_ERROR_INCOMPATIBLE_VERSION
#define AARUF_ERROR_INCOMPATIBLE_VERSION
Image uses a newer incompatible on-disk version.
Definition errors.h:42
AARUF_ERROR_CANNOT_READ_INDEX
#define AARUF_ERROR_CANNOT_READ_INDEX
Index block unreadable / truncated / bad identifier.
Definition errors.h:43
AARUF_ERROR_NOT_AARUFORMAT
#define AARUF_ERROR_NOT_AARUFORMAT
Input file/stream failed magic or structural validation.
Definition errors.h:40
AARUF_ERROR_FILE_TOO_SMALL
#define AARUF_ERROR_FILE_TOO_SMALL
File size insufficient for mandatory header / structures.
Definition errors.h:41
MaxSectorTag
@ MaxSectorTag
Definition aaru.h:980
create_map
hash_map_t * create_map(size_t size)
Creates a new hash map with the specified initial size.
Definition hash_map.c:51
AARU_HEADER_APP_NAME_LEN
#define AARU_HEADER_APP_NAME_LEN
Size in bytes (UTF-16LE) of application name field (32 UTF-16 code units).
Definition header.h:59
internal.h
process_dumphw_block
void process_dumphw_block(aaruformat_context *ctx, const IndexEntry *entry)
Processes a dump hardware block from the image stream.
Definition dump.c:107
process_index_v2
UT_array * process_index_v2(aaruformat_context *ctx)
Processes an index block (version 2) from the image stream.
Definition index_v2.c:81
process_ddt_v2
int32_t process_ddt_v2(aaruformat_context *ctx, IndexEntry *entry, bool *found_user_data_ddt)
Processes a DDT v2 block from the image stream.
Definition ddt_v2.c:96
process_data_block
int32_t process_data_block(aaruformat_context *ctx, IndexEntry *entry)
Processes a data block from the image stream.
Definition data.c:71
get_filetime_uint64
uint64_t get_filetime_uint64()
Gets the current time as a 64-bit FILETIME value.
Definition time.c:45
process_tracks_block
void process_tracks_block(aaruformat_context *ctx, const IndexEntry *entry)
Parse and integrate a Tracks block from the image stream into the context.
Definition optical.c:111
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_checksum_block
void process_checksum_block(aaruformat_context *ctx, const IndexEntry *entry)
Processes a checksum block from the image stream.
Definition checksum.c:39
process_index_v1
UT_array * process_index_v1(aaruformat_context *ctx)
Processes an index block (version 1) from the image stream.
Definition index_v1.c:79
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_tape_files_block
void process_tape_files_block(aaruformat_context *ctx, const IndexEntry *entry)
Processes a tape file metadata block from the image stream.
Definition tape.c:126
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
process_tape_partitions_block
void process_tape_partitions_block(aaruformat_context *ctx, const IndexEntry *entry)
Processes a tape partition metadata block from the image stream.
Definition tape.c:347
process_ddt_v1
int32_t process_ddt_v1(aaruformat_context *ctx, IndexEntry *entry, bool *found_user_data_ddt)
Processes a DDT v1 block from the image stream.
Definition ddt_v1.c:85
parse_options
aaru_options parse_options(const char *options, bool *table_shift_found)
Parses the options string for AaruFormat image creation/opening.
Definition options.c:38
process_index_v3
UT_array * process_index_v3(aaruformat_context *ctx)
Processes an index block (version 3) from the image stream.
Definition index_v3.c:98
log.h
FATAL
#define FATAL(fmt,...)
Definition log.h:40
TRACE
#define TRACE(fmt,...)
Definition log.h:25
cleanup_open_failure
static void cleanup_open_failure(aaruformat_context *ctx)
Definition open.c:31
aaruf_open
void * aaruf_open(const char *filepath, const bool resume_mode, const char *options)
Opens an existing AaruFormat image file.
Definition open.c:223
AaruHeaderV2
Version 2 container header with GUID, alignment shifts, and feature negotiation bitmaps.
Definition header.h:107
AaruHeaderV2::application
uint8_t application[64]
UTF-8 creator application name (fixed 64 bytes).
Definition header.h:109
AaruHeaderV2::applicationMajorVersion
uint8_t applicationMajorVersion
Creator application major version.
Definition header.h:112
AaruHeaderV2::identifier
uint64_t identifier
File magic (AARU_MAGIC).
Definition header.h:108
AaruHeaderV2::lastWrittenTime
int64_t lastWrittenTime
Last modification FILETIME (100 ns since 1601-01-01 UTC).
Definition header.h:117
AaruHeaderV2::indexOffset
uint64_t indexOffset
Absolute byte offset to primary index block (MUST be > 0; 0 => corrupt/unreadable).
Definition header.h:115
AaruHeaderV2::applicationMinorVersion
uint8_t applicationMinorVersion
Creator application minor / patch version.
Definition header.h:113
AaruHeaderV2::mediaType
uint32_t mediaType
Media type enumeration (value from MediaType).
Definition header.h:114
AaruHeaderV2::biggestSectorSize
uint16_t biggestSectorSize
size of biggest sector in the image (in bytes).
Definition header.h:120
AaruHeaderV2::imageMinorVersion
uint8_t imageMinorVersion
Container format minor version.
Definition header.h:111
AaruHeaderV2::creationTime
int64_t creationTime
Creation FILETIME (100 ns since 1601-01-01 UTC).
Definition header.h:116
AaruHeaderV2::imageMajorVersion
uint8_t imageMajorVersion
Container format major version.
Definition header.h:110
AaruHeader
Version 1 container header placed at offset 0 for legacy / initial format.
Definition header.h:77
CacheHeader::cache
struct CacheEntry * cache
Hash root (uthash). NULL when empty.
Definition lru.h:48
CacheHeader::max_items
uint64_t max_items
Hard limit for number of entries (policy: enforce/ignore depends on implementation).
Definition lru.h:47
CacheHeader::free_func
void(* free_func)(void *)
Optional callback to free cached values. NULL if values don't need freeing.
Definition lru.h:49
CdEccContext
Lookup tables and state for Compact Disc EDC/ECC (P/Q) regeneration / verification.
Definition context.h:89
DdtHeader2::blocks
uint64_t blocks
Total internal span (negative + usable + overflow) in logical sectors.
Definition ddt.h:150
DdtHeader2::blockAlignmentShift
uint8_t blockAlignmentShift
2^blockAlignmentShift = block alignment boundary in bytes.
Definition ddt.h:154
GeometryBlockHeader::identifier
uint32_t identifier
Block identifier, must be BlockType::GeometryBlock.
Definition data.h:92
ImageInfo::MediaType
uint32_t MediaType
Media type identifier (see MediaType enum; 0=Unknown).
Definition aaru.h:943
ImageInfo::MetadataMediaType
uint8_t MetadataMediaType
Media type for sidecar generation (internal archival use).
Definition aaru.h:944
ImageInfo::SectorSize
uint32_t SectorSize
Size of each logical sector in bytes (512, 2048, 2352, 4096, etc.).
Definition aaru.h:937
ImageInfo::Application
char Application[64]
Name of application that created the image (NUL-terminated).
Definition aaru.h:939
ImageInfo::ImageSize
uint64_t ImageSize
Size of the image payload in bytes (excludes headers/metadata).
Definition aaru.h:935
ImageInfo::CreationTime
int64_t CreationTime
Image creation timestamp (Windows FILETIME: 100ns since 1601-01-01 UTC).
Definition aaru.h:941
ImageInfo::LastModificationTime
int64_t LastModificationTime
Last modification timestamp (Windows FILETIME format).
Definition aaru.h:942
ImageInfo::Version
char Version[32]
Image format version string (NUL-terminated, e.g., "6.0").
Definition aaru.h:938
ImageInfo::Sectors
uint64_t Sectors
Total count of addressable logical sectors/blocks.
Definition aaru.h:936
ImageInfo::ApplicationVersion
char ApplicationVersion[32]
Version of the creating application (NUL-terminated).
Definition aaru.h:940
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
IndexEntry::dataType
uint16_t dataType
Data classification (value from DataType) or unused for untyped blocks.
Definition index.h:111
aaru_options
Parsed user-specified tunables controlling compression, deduplication, hashing and DDT geometry.
Definition options.h:217
aaru_options::deduplicate
bool deduplicate
Storage dedup flag (DDT always exists).
Definition options.h:219
aaru_options::dictionary
uint32_t dictionary
LZMA dictionary size in bytes (>= 4096 recommended). Default: 33554432 (32 MiB).
Definition options.h:221
aaru_options::compress
bool compress
Enable adaptive compression (LZMA for data blocks, FLAC for audio). Default: true.
Definition options.h:218
aaruformat_context
Master context representing an open or in‑creation Aaru image.
Definition context.h:175
aaruformat_context::user_data_ddt_header
DdtHeader2 user_data_ddt_header
Active user data DDT v2 header (primary table meta).
Definition context.h:192
aaruformat_context::library_major_version
uint8_t library_major_version
Linked library major version.
Definition context.h:180
aaruformat_context::deduplicate
bool deduplicate
Storage deduplication active (duplicates coalesce).
Definition context.h:302
aaruformat_context::compression_enabled
bool compression_enabled
True if block compression enabled (writing path).
Definition context.h:303
aaruformat_context::sector_hash_map
hash_map_t * sector_hash_map
Deduplication hash map (fingerprint->entry mapping).
Definition context.h:256
aaruformat_context::cylinders
uint32_t cylinders
Cylinders of the media represented by the image.
Definition context.h:237
aaruformat_context::block_header_cache
struct CacheHeader block_header_cache
LRU/Cache header for block headers.
Definition context.h:259
aaruformat_context::shift
uint8_t shift
Legacy overall shift (deprecated by data_shift/table_shift).
Definition context.h:198
aaruformat_context::ecc_cd_context
CdEccContext * ecc_cd_context
CD ECC/EDC helper tables (allocated on demand).
Definition context.h:251
aaruformat_context::rewinded
bool rewinded
True if stream has been rewound after open (write path).
Definition context.h:296
aaruformat_context::block_cache
struct CacheHeader block_cache
LRU/Cache header for block payloads.
Definition context.h:260
aaruformat_context::header
AaruHeaderV2 header
Parsed container header (v2).
Definition context.h:178
aaruformat_context::is_writing
bool is_writing
True if context opened/created for writing.
Definition context.h:295
aaruformat_context::magic
uint64_t magic
File magic (AARU_MAGIC) post-open.
Definition context.h:177
aaruformat_context::library_minor_version
uint8_t library_minor_version
Linked library minor version;.
Definition context.h:181
aaruformat_context::next_block_position
uint64_t next_block_position
Absolute file offset where next block will be written.
Definition context.h:285
aaruformat_context::geometry_block
GeometryBlockHeader geometry_block
Logical geometry block (if present).
Definition context.h:232
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::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::index_entries
UT_array * index_entries
Flattened index entries (UT_array of IndexEntry).
Definition context.h:255
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::lzma_dict_size
uint32_t lzma_dict_size
LZMA dictionary size (writing path).
Definition context.h:301