libaaruformat 1.0
Aaru Data Preservation Suite - Format Library
Loading...
Searching...
No Matches
create.c
Go to the documentation of this file.
1/*
2 * This file is part of the Aaru Data Preservation Suite.
3 * Copyright (c) 2019-2026 Natalia Portillo.
4 *
5 * This library is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as
7 * published by the Free Software Foundation; either version 2.1 of the
8 * License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
17 */
18#include <errno.h>
19#include <stdbool.h>
20#include <stdint.h>
21#include <stdio.h>
22#include <stdlib.h>
23#include <string.h>
24
25#include "aaruformat.h"
26#include "enums.h"
27#include "internal.h"
28#include "log.h"
29
31{
32 if(ctx == NULL) return;
33
34 if(ctx->sector_hash_map != NULL)
35 {
37 ctx->sector_hash_map = NULL;
38 }
39
40 if(ctx->index_entries != NULL)
41 {
42 utarray_free(ctx->index_entries);
43 ctx->index_entries = NULL;
44 }
45
46 if(ctx->user_data_ddt2 != NULL)
47 {
48 free(ctx->user_data_ddt2);
49 ctx->user_data_ddt2 = NULL;
50 }
51
52 if(ctx->spamsum_context != NULL)
53 {
55 ctx->spamsum_context = NULL;
56 }
57
58 if(ctx->blake3_context != NULL)
59 {
60 free(ctx->blake3_context);
61 ctx->blake3_context = NULL;
62 }
63
64 if(ctx->ecc_cd_context != NULL)
65 {
66 free(ctx->ecc_cd_context);
67 ctx->ecc_cd_context = NULL;
68 }
69
70 if(ctx->readableSectorTags != NULL)
71 {
72 free(ctx->readableSectorTags);
73 ctx->readableSectorTags = NULL;
74 }
75
76 // ApplicationVersion and Version are fixed-size arrays, not pointers - no need to free
77
78 if(ctx->imageStream != NULL)
79 {
80 fclose(ctx->imageStream);
81 ctx->imageStream = NULL;
82 }
83
84 free(ctx);
85}
86
279AARU_EXPORT void AARU_CALL *aaruf_create(const char *filepath, const uint32_t media_type, const uint32_t sector_size,
280 const uint64_t user_sectors, const uint64_t negative_sectors,
281 const uint64_t overflow_sectors, const char *options,
282 const uint8_t *application_name, const uint8_t application_name_length,
283 const uint8_t application_major_version,
284 const uint8_t application_minor_version, const bool is_tape)
285{
286 TRACE("Entering aaruf_create(%s, %u, %u, %llu, %llu, %llu, %s, %s, %u, %u, %u, %d)", filepath, media_type,
287 sector_size, user_sectors, negative_sectors, overflow_sectors, options,
288 application_name ? (const char *)application_name : "NULL", application_name_length,
289 application_major_version, application_minor_version, is_tape);
290
291 // Parse the options
292 TRACE("Parsing options");
293 bool table_shift_found = false;
294 const aaru_options parsed_options = parse_options(options, &table_shift_found);
295
296 // Allocate context
297 TRACE("Allocating memory for context");
298 aaruformat_context *ctx = malloc(sizeof(aaruformat_context));
299 if(ctx == NULL)
300 {
301 FATAL("Not enough memory to create context");
303
304 TRACE("Exiting aaruf_create() = NULL");
305 return NULL;
306 }
307
308 memset(ctx, 0, sizeof(aaruformat_context));
309
310 // Create the image file
311 TRACE("Creating image file %s", filepath);
312 ctx->imageStream = fopen(filepath, "wb+");
313 if(ctx->imageStream == NULL)
314 {
315 FATAL("Error %d opening file %s for writing", errno, filepath);
317
318 TRACE("Exiting aaruf_create() = NULL");
320 return NULL;
321 }
322
323 if(application_name_length > AARU_HEADER_APP_NAME_LEN)
324 {
325 FATAL("Application name too long (%u bytes, maximum %u bytes)", application_name_length,
328
329 TRACE("Exiting aaruf_create() = NULL");
331 return NULL;
332 }
333
334 // Initialize header
335 TRACE("Initializing header");
337 memcpy(ctx->header.application, application_name, application_name_length);
339 ctx->header.imageMinorVersion = 0;
340 ctx->header.applicationMajorVersion = application_major_version;
341 ctx->header.applicationMinorVersion = application_minor_version;
342 ctx->header.mediaType = media_type;
343 ctx->header.indexOffset = 0;
346
347 // Generate random GUID for the image
348 TRACE("Generating random GUID");
350
351 ctx->readableSectorTags = (bool *)malloc(sizeof(bool) * MaxSectorTag);
352
353 if(ctx->readableSectorTags == NULL)
354 {
356
357 TRACE("Exiting aaruf_create() = NULL");
359 return NULL;
360 }
361
362 memset(ctx->readableSectorTags, 0, sizeof(bool) * MaxSectorTag);
363
364 // Initialize image info
365 TRACE("Initializing image info");
366
367 // Copy application name (UTF-8) to image_info
368 memset(ctx->image_info.Application, 0, 64);
369 size_t copy_len = application_name_length < 63 ? application_name_length : 63;
370 memcpy(ctx->image_info.Application, application_name, copy_len);
371 ctx->image_info.Application[63] = '\0';
372
373 // Set application version string directly in the fixed-size array
374 memset(ctx->image_info.ApplicationVersion, 0, 32);
377
378 // Set image version string directly in the fixed-size array
379 memset(ctx->image_info.Version, 0, 32);
380 sprintf(ctx->image_info.Version, "%d.%d", ctx->header.imageMajorVersion, ctx->header.imageMinorVersion);
381
383 ctx->image_info.ImageSize = 0;
387 ctx->image_info.SectorSize = sector_size;
388 ctx->image_info.Sectors = user_sectors;
389
390 // Initialize caches
391 TRACE("Initializing caches");
392 ctx->block_header_cache.cache = NULL;
393 const uint64_t cache_divisor = (uint64_t)ctx->image_info.SectorSize * (1ULL << ctx->shift);
394 ctx->block_header_cache.max_items = cache_divisor == 0 ? 0 : MAX_CACHE_SIZE / cache_divisor;
395 ctx->block_cache.cache = NULL;
397
398 // TODO: Cache tracks and sessions?
399
400 // Initialize ECC for Compact Disc
401 TRACE("Initializing Compact Disc ECC");
403
404 ctx->magic = AARU_MAGIC;
407
408 if(!is_tape)
409 { // Initialize DDT2
410 TRACE("Initializing DDT2");
411 ctx->in_memory_ddt = true;
417 ctx->user_data_ddt_header.negative = negative_sectors;
418 ctx->user_data_ddt_header.blocks = user_sectors + overflow_sectors + negative_sectors;
419 ctx->user_data_ddt_header.overflow = overflow_sectors;
422 ctx->user_data_ddt_header.dataShift = parsed_options.data_shift;
423
424 if(parsed_options.table_shift == -1 || !table_shift_found)
425 {
426 const uint64_t total_sectors = user_sectors + overflow_sectors + negative_sectors;
427
428 if(total_sectors < 8388608ULL)
430 else
432 }
433 else
435 parsed_options.table_shift > 0 ? (uint8_t)parsed_options.table_shift : 0;
436
438
439 uint8_t effective_table_shift = ctx->user_data_ddt_header.tableShift;
440 if(effective_table_shift >= 63)
441 {
442 TRACE("Clamping table shift from %u to 62 to avoid overflow", effective_table_shift);
443 effective_table_shift = 62;
444 ctx->user_data_ddt_header.tableShift = effective_table_shift;
445 }
446
447 const uint64_t sectors_per_entry = 1ULL << effective_table_shift;
448 ctx->user_data_ddt_header.entries = ctx->user_data_ddt_header.blocks / sectors_per_entry;
449 if(ctx->user_data_ddt_header.blocks % sectors_per_entry != 0 || ctx->user_data_ddt_header.entries == 0)
451
452 TRACE("Initializing primary/single DDT");
453 ctx->user_data_ddt2 =
454 (uint64_t *)calloc(ctx->user_data_ddt_header.entries, sizeof(uint64_t)); // All entries to zero
455 if(ctx->user_data_ddt2 == NULL)
456 {
457 FATAL("Not enough memory to allocate primary DDT (big)");
459 TRACE("Exiting aaruf_create() = NULL");
461 return NULL;
462 }
463
464 // Set the primary DDT offset (just after the header, block aligned)
465 ctx->primary_ddt_offset = sizeof(AaruHeaderV2); // Start just after the header
466 const uint64_t alignment_mask = (1ULL << ctx->user_data_ddt_header.blockAlignmentShift) - 1;
467 ctx->primary_ddt_offset = ctx->primary_ddt_offset + alignment_mask & ~alignment_mask;
468
469 TRACE("Primary DDT will be placed at offset %" PRIu64, ctx->primary_ddt_offset);
470
471 // Calculate size of primary DDT table
472 const uint64_t primary_table_size = ctx->user_data_ddt_header.entries * sizeof(uint64_t);
473
474 // Calculate where data blocks can start (after primary DDT + header)
476 {
477 const uint64_t data_start_position = ctx->primary_ddt_offset + sizeof(DdtHeader2) + primary_table_size;
478 ctx->next_block_position = data_start_position + alignment_mask & ~alignment_mask;
479 }
480 else
481 ctx->next_block_position = ctx->primary_ddt_offset; // Single-level DDT can start anywhere
482 }
483 else
484 {
485 // Fill needed values
487 ctx->header.blockAlignmentShift = parsed_options.block_alignment;
488 ctx->user_data_ddt_header.dataShift = parsed_options.data_shift;
489
490 // Calculate aligned next block position
491 const uint64_t alignment_mask = (1ULL << parsed_options.block_alignment) - 1;
492 ctx->next_block_position = sizeof(AaruHeaderV2); // Start just after the header
493 ctx->next_block_position = ctx->next_block_position + alignment_mask & ~alignment_mask;
494 ctx->is_tape = 1;
495 ctx->tape_ddt = NULL;
496 }
497
498 TRACE("Data blocks will start at position %" PRIu64, ctx->next_block_position);
499
500 // Position file pointer at the data start position
501 if(fseek(ctx->imageStream, ctx->next_block_position, SEEK_SET) != 0)
502 {
503 FATAL("Could not seek to data start position");
505 TRACE("Exiting aaruf_create() = NULL");
507 return NULL;
508 }
509
510 // Initialize index entries array
511 TRACE("Initializing index entries array");
512 const UT_icd index_entry_icd = {sizeof(IndexEntry), NULL, NULL, NULL};
513 utarray_new(ctx->index_entries, &index_entry_icd);
514
515 if(ctx->index_entries == NULL)
516 {
517 FATAL("Not enough memory to create index entries array");
519
520 TRACE("Exiting aaruf_create() = NULL");
522 return NULL;
523 }
524
525 ctx->compression_enabled = parsed_options.compress;
526 ctx->lzma_dict_size = parsed_options.dictionary;
527 ctx->deduplicate = parsed_options.deduplicate;
528 if(ctx->deduplicate)
529 ctx->sector_hash_map = create_map(ctx->user_data_ddt_header.blocks * 25 / 100); // 25% of total sectors
530
531 ctx->rewinded = false;
532 ctx->last_written_block = 0;
533
534 if(parsed_options.md5)
535 {
536 ctx->calculating_md5 = true;
538 }
539 if(parsed_options.sha1)
540 {
541 ctx->calculating_sha1 = true;
543 }
544 if(parsed_options.sha256)
545 {
546 ctx->calculating_sha256 = true;
548 }
549 if(parsed_options.spamsum)
550 {
551 ctx->calculating_spamsum = true;
553 }
554 if(parsed_options.blake3)
555 {
556 ctx->blake3_context = calloc(1, sizeof(blake3_hasher));
557 if(ctx->blake3_context != NULL)
558 {
559 ctx->calculating_blake3 = true;
560 blake3_hasher_init(ctx->blake3_context);
561 }
562 }
563
564 // Is writing
565 ctx->is_writing = true;
566
567 // Initialize dirty flags - all true by default for new images
568 ctx->dirty_secondary_ddt = true;
569 ctx->dirty_primary_ddt = true;
570 ctx->dirty_single_level_ddt = true;
571 ctx->dirty_checksum_block = true;
572 ctx->dirty_tracks_block = true;
574 ctx->dirty_sector_prefix_block = true;
575 ctx->dirty_sector_prefix_ddt = true;
576 ctx->dirty_sector_suffix_block = true;
577 ctx->dirty_sector_suffix_ddt = true;
581 ctx->dirty_media_tags = true;
582 ctx->dirty_tape_ddt = true;
583 ctx->dirty_tape_file_block = true;
584 ctx->dirty_tape_partition_block = true;
585 ctx->dirty_geometry_block = true;
586 ctx->dirty_metadata_block = true;
587 ctx->dirty_dumphw_block = true;
588 ctx->dirty_cicm_block = true;
589 ctx->dirty_json_block = true;
590 ctx->dirty_flux_block = true;
591 ctx->dirty_index_block = true;
592
593 TRACE("Exiting aaruf_create() = %p", ctx);
594 // Return context
595 return ctx;
596}
#define LIBAARUFORMAT_MAJOR_VERSION
Definition aaruformat.h:22
#define LIBAARUFORMAT_MINOR_VERSION
Definition aaruformat.h:23
#define AARU_MAGIC
Magic identifier for AaruFormat container (ASCII "AARUFRMT").
Definition consts.h:64
#define MAX_CACHE_SIZE
Maximum read cache size (bytes).
Definition consts.h:79
#define AARUF_VERSION_V2
Second on‑disk version (C implementation).
Definition consts.h:75
void * aaruf_create(const char *filepath, const uint32_t media_type, const uint32_t sector_size, const uint64_t user_sectors, const uint64_t negative_sectors, const uint64_t overflow_sectors, const char *options, const uint8_t *application_name, const uint8_t application_name_length, const uint8_t application_major_version, const uint8_t application_minor_version, const bool is_tape)
Creates a new AaruFormat image file.
Definition create.c:279
static void cleanup_failed_create(aaruformat_context *ctx)
Definition create.c:30
#define AARU_CALL
Definition decls.h:46
void aaruf_sha256_init(sha256_ctx *ctx)
Definition sha256.c:76
void aaruf_md5_init(md5_ctx *ctx)
Definition md5.c:436
void aaruf_spamsum_free(spamsum_ctx *ctx)
Frees a spamsum (fuzzy hash) context.
Definition spamsum.c:75
spamsum_ctx * aaruf_spamsum_init(void)
Definition spamsum.c:37
#define AARU_EXPORT
Definition decls.h:55
void aaruf_sha1_init(sha1_ctx *ctx)
Definition sha1.c:34
void * aaruf_ecc_cd_init()
Initializes a Compact Disc ECC context.
Definition ecc_cd.c:35
int32_t aaruf_get_xml_mediatype(int32_t type)
Definition helpers.c:351
@ DeDuplicationTable2
Block containing a deduplication table v2.
Definition enums.h:146
@ UserData
User (main) data.
Definition enums.h:46
@ None
Not compressed.
Definition enums.h:33
#define AARUF_ERROR_CANNOT_CREATE_FILE
Output file could not be created / opened for write.
Definition errors.h:58
#define AARUF_ERROR_INVALID_APP_NAME_LENGTH
Application name field length invalid (sanity limit).
Definition errors.h:59
#define AARUF_ERROR_NOT_ENOUGH_MEMORY
Memory allocation failure (critical).
Definition errors.h:48
@ MaxSectorTag
Definition aaru.h:980
hash_map_t * create_map(size_t size)
Creates a new hash map with the specified initial size.
Definition hash_map.c:51
void free_map(hash_map_t *map)
Frees all memory associated with a hash map.
Definition hash_map.c:78
#define GUID_SIZE
Size in bytes of GUID / UUID-like binary identifier.
Definition header.h:60
#define AARU_HEADER_APP_NAME_LEN
Size in bytes (UTF-16LE) of application name field (32 UTF-16 code units).
Definition header.h:59
uint64_t get_filetime_uint64()
Gets the current time as a 64-bit FILETIME value.
Definition time.c:45
void generate_random_bytes(uint8_t *buffer, size_t length)
Generates cryptographically strong random bytes.
Definition helpers.c:484
aaru_options parse_options(const char *options, bool *table_shift_found)
Parses the options string for AaruFormat image creation/opening.
Definition options.c:38
#define FATAL(fmt,...)
Definition log.h:40
#define TRACE(fmt,...)
Definition log.h:25
Version 2 container header with GUID, alignment shifts, and feature negotiation bitmaps.
Definition header.h:107
uint8_t application[64]
UTF-8 creator application name (fixed 64 bytes).
Definition header.h:109
uint8_t applicationMajorVersion
Creator application major version.
Definition header.h:112
uint64_t identifier
File magic (AARU_MAGIC).
Definition header.h:108
int64_t lastWrittenTime
Last modification FILETIME (100 ns since 1601-01-01 UTC).
Definition header.h:117
uint64_t indexOffset
Absolute byte offset to primary index block (MUST be > 0; 0 => corrupt/unreadable).
Definition header.h:115
uint8_t applicationMinorVersion
Creator application minor / patch version.
Definition header.h:113
uint8_t guid[16]
128-bit image GUID (binary, not text); stable across children.
Definition header.h:118
uint32_t mediaType
Media type enumeration (value from MediaType).
Definition header.h:114
uint8_t blockAlignmentShift
log2 block alignment (block size alignment = 2^blockAlignmentShift bytes).
Definition header.h:119
uint8_t imageMinorVersion
Container format minor version.
Definition header.h:111
int64_t creationTime
Creation FILETIME (100 ns since 1601-01-01 UTC).
Definition header.h:116
uint8_t imageMajorVersion
Container format major version.
Definition header.h:110
struct CacheEntry * cache
Hash root (uthash). NULL when empty.
Definition lru.h:48
uint64_t max_items
Hard limit for number of entries (policy: enforce/ignore depends on implementation).
Definition lru.h:47
Lookup tables and state for Compact Disc EDC/ECC (P/Q) regeneration / verification.
Definition context.h:89
Header preceding a version 2 hierarchical deduplication table.
Definition ddt.h:142
uint16_t type
Data classification (DataType) for sectors referenced by this table.
Definition ddt.h:144
uint64_t start
Base internal index covered by this table (used for secondary tables; currently informational).
Definition ddt.h:153
uint64_t entries
Number of entries contained in (uncompressed) table payload.
Definition ddt.h:158
uint8_t levels
Total number of hierarchy levels (root depth); > 0.
Definition ddt.h:146
uint32_t identifier
Block identifier, must be BlockType::DeDuplicationTable2.
Definition ddt.h:143
uint8_t tableShift
2^tableShift = number of logical sectors per primary entry (multi-level only; 0 for single-level or s...
Definition ddt.h:156
uint64_t blocks
Total internal span (negative + usable + overflow) in logical sectors.
Definition ddt.h:150
uint8_t blockAlignmentShift
2^blockAlignmentShift = block alignment boundary in bytes.
Definition ddt.h:154
uint32_t overflow
Trailing dumped sectors beyond user area (overflow range), still mapped with entries.
Definition ddt.h:151
uint32_t negative
Leading negative LBA count; added to external L to build internal index.
Definition ddt.h:149
uint8_t tableLevel
Zero-based level index of this table (0 = root, increases downward).
Definition ddt.h:147
uint16_t compression
Compression algorithm for this table body (CompressionType).
Definition ddt.h:145
uint8_t dataShift
2^dataShift = sectors represented per increment in blockIndex field.
Definition ddt.h:155
uint64_t previousLevelOffset
Absolute byte offset of the parent (previous) level table; 0 if root.
Definition ddt.h:148
uint32_t MediaType
Media type identifier (see MediaType enum; 0=Unknown).
Definition aaru.h:943
uint8_t MetadataMediaType
Media type for sidecar generation (internal archival use).
Definition aaru.h:944
uint32_t SectorSize
Size of each logical sector in bytes (512, 2048, 2352, 4096, etc.).
Definition aaru.h:937
char Application[64]
Name of application that created the image (NUL-terminated).
Definition aaru.h:939
uint64_t ImageSize
Size of the image payload in bytes (excludes headers/metadata).
Definition aaru.h:935
int64_t CreationTime
Image creation timestamp (Windows FILETIME: 100ns since 1601-01-01 UTC).
Definition aaru.h:941
int64_t LastModificationTime
Last modification timestamp (Windows FILETIME format).
Definition aaru.h:942
char Version[32]
Image format version string (NUL-terminated, e.g., "6.0").
Definition aaru.h:938
uint64_t Sectors
Total count of addressable logical sectors/blocks.
Definition aaru.h:936
char ApplicationVersion[32]
Version of the creating application (NUL-terminated).
Definition aaru.h:940
Single index entry describing a block's type, (optional) data classification, and file offset.
Definition index.h:109
Parsed user-specified tunables controlling compression, deduplication, hashing and DDT geometry.
Definition options.h:217
bool deduplicate
Storage dedup flag (DDT always exists).
Definition options.h:219
uint8_t data_shift
Global data shift: low bits encode sector offset inside a block (2^data_shift span).
Definition options.h:223
uint32_t dictionary
LZMA dictionary size in bytes (>= 4096 recommended). Default: 33554432 (32 MiB).
Definition options.h:221
bool compress
Enable adaptive compression (LZMA for data blocks, FLAC for audio). Default: true.
Definition options.h:218
bool sha256
Generate SHA-256 checksum (ChecksumAlgorithm::Sha256) when finalizing image.
Definition options.h:227
bool spamsum
Generate SpamSum fuzzy hash (ChecksumAlgorithm::SpamSum) if enabled.
Definition options.h:229
int8_t table_shift
DDT table shift (multi-level fan-out exponent). Default: heuristically calculated.
Definition options.h:222
bool md5
Generate MD5 checksum (ChecksumAlgorithm::Md5) when finalizing image.
Definition options.h:225
bool blake3
Generate BLAKE3 checksum if supported (not stored if algorithm unavailable).
Definition options.h:228
bool sha1
Generate SHA-1 checksum (ChecksumAlgorithm::Sha1) when finalizing image.
Definition options.h:226
uint8_t block_alignment
log2 underlying block alignment (2^n bytes). Default: 9 (512 bytes).
Definition options.h:224
Master context representing an open or in‑creation Aaru image.
Definition context.h:175
DdtHeader2 user_data_ddt_header
Active user data DDT v2 header (primary table meta).
Definition context.h:192
uint8_t library_major_version
Linked library major version.
Definition context.h:180
bool dirty_checksum_block
True if checksum block should be written during close.
Definition context.h:320
bool deduplicate
Storage deduplication active (duplicates coalesce).
Definition context.h:302
bool compression_enabled
True if block compression enabled (writing path).
Definition context.h:303
uint64_t last_written_block
Last written block number (write path).
Definition context.h:286
bool dirty_media_tags
True if media tags should be written during close.
Definition context.h:330
hash_map_t * sector_hash_map
Deduplication hash map (fingerprint->entry mapping).
Definition context.h:256
sha256_ctx sha256_context
Opaque SHA-256 context for streaming updates.
Definition context.h:275
bool calculating_sha256
True if whole-image SHA-256 being calculated on-the-fly.
Definition context.h:278
bool dirty_primary_ddt
True if primary DDT table should be written during close.
Definition context.h:318
struct CacheHeader block_header_cache
LRU/Cache header for block headers.
Definition context.h:259
md5_ctx md5_context
Opaque MD5 context for streaming updates.
Definition context.h:273
bool dirty_sector_suffix_block
True if sector suffix block should be written during close.
Definition context.h:325
uint64_t * user_data_ddt2
DDT entries (big variant) primary/secondary current.
Definition context.h:190
uint8_t shift
Legacy overall shift (deprecated by data_shift/table_shift).
Definition context.h:198
bool dirty_dvd_title_key_decrypted_block
True if decrypted title key block should be written during close.
Definition context.h:329
bool dirty_mode2_subheaders_block
True if MODE2 subheader block should be written during close.
Definition context.h:322
bool dirty_tape_partition_block
True if tape partition block should be written during close.
Definition context.h:333
bool dirty_cicm_block
True if CICM metadata block should be written during close.
Definition context.h:337
bool is_tape
True if the image is a tape image.
Definition context.h:308
bool calculating_sha1
True if whole-image SHA-1 being calculated on-the-fly.
Definition context.h:277
bool dirty_tracks_block
True if tracks block should be written during close.
Definition context.h:321
CdEccContext * ecc_cd_context
CD ECC/EDC helper tables (allocated on demand).
Definition context.h:251
bool rewinded
True if stream has been rewound after open (write path).
Definition context.h:296
struct CacheHeader block_cache
LRU/Cache header for block payloads.
Definition context.h:260
bool dirty_sector_prefix_block
True if sector prefix block should be written during close.
Definition context.h:323
bool in_memory_ddt
True if primary (and possibly secondary) DDT loaded.
Definition context.h:199
bool dirty_index_block
True if index block should be written during close.
Definition context.h:340
AaruHeaderV2 header
Parsed container header (v2).
Definition context.h:178
bool dirty_json_block
True if JSON metadata block should be written during close.
Definition context.h:338
bool is_writing
True if context opened/created for writing.
Definition context.h:295
TapeDdtHashEntry * tape_ddt
Hash table root for tape DDT entries.
Definition context.h:185
spamsum_ctx * spamsum_context
Opaque SpamSum context for streaming updates.
Definition context.h:270
bool dirty_single_level_ddt
True if single-level DDT should be written during close.
Definition context.h:319
uint64_t magic
File magic (AARU_MAGIC) post-open.
Definition context.h:177
bool calculating_spamsum
True if whole-image SpamSum being calculated on-the-fly.
Definition context.h:279
uint64_t primary_ddt_offset
File offset of the primary DDT v2 table.
Definition context.h:195
blake3_hasher * blake3_context
Opaque BLAKE3 context for streaming updates.
Definition context.h:271
bool calculating_blake3
True if whole-image BLAKE3 being calculated on-the-fly.
Definition context.h:280
uint8_t library_minor_version
Linked library minor version;.
Definition context.h:181
uint64_t next_block_position
Absolute file offset where next block will be written.
Definition context.h:285
bool calculating_md5
True if whole-image MD5 being calculated on-the-fly.
Definition context.h:276
bool dirty_sector_suffix_ddt
True if sector suffix DDT should be written during close.
Definition context.h:326
bool dirty_dumphw_block
True if dump hardware block should be written during close.
Definition context.h:336
bool dirty_metadata_block
True if metadata block should be written during close.
Definition context.h:335
bool dirty_sector_subchannel_block
True if subchannel block should be written during close.
Definition context.h:327
FILE * imageStream
Underlying FILE* stream (binary mode).
Definition context.h:179
bool dirty_dvd_long_sector_blocks
True if DVD long sector blocks should be written during close.
Definition context.h:328
bool dirty_sector_prefix_ddt
True if sector prefix DDT should be written during close.
Definition context.h:324
UT_array * index_entries
Flattened index entries (UT_array of IndexEntry).
Definition context.h:255
bool dirty_tape_file_block
True if tape file block should be written during close.
Definition context.h:332
ImageInfo image_info
Exposed high-level image info summary.
Definition context.h:263
bool dirty_flux_block
True if flux block should be written during close.
Definition context.h:339
sha1_ctx sha1_context
Opaque SHA-1 context for streaming updates.
Definition context.h:274
bool dirty_secondary_ddt
True if secondary DDT tables should be written during close.
Definition context.h:317
bool * readableSectorTags
Per-sector boolean array (optical tags read successfully?).
Definition context.h:266
bool dirty_tape_ddt
True if tape DDT should be written during close.
Definition context.h:331
uint32_t lzma_dict_size
LZMA dictionary size (writing path).
Definition context.h:301
bool dirty_geometry_block
True if geometry block should be written during close.
Definition context.h:334