libaaruformat 1.0
Aaru Data Preservation Suite - Format Library
Loading...
Searching...
No Matches
open.c
Go to the documentation of this file.
1/*
2 * This file is part of the Aaru Data Preservation Suite.
3 * Copyright (c) 2019-2025 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
19#include <errno.h>
20#include <inttypes.h>
21#include <stdio.h>
22#include <stdlib.h>
23#include <string.h>
24
25#include <aaruformat.h>
26
27#include "internal.h"
28#include "log.h"
29#include "utarray.h"
30
32{
33 if(ctx == NULL) return;
34
35 if(ctx->imageStream != NULL)
36 {
37 fclose(ctx->imageStream);
38 ctx->imageStream = NULL;
39 }
40
41 free(ctx->readableSectorTags);
42 ctx->readableSectorTags = NULL;
43
44 free(ctx);
45}
46
223AARU_EXPORT void AARU_CALL *aaruf_open(const char *filepath, const bool resume_mode,
224 const char *options) // NOLINT(readability-function-size)
225{
226 aaruformat_context *ctx = NULL;
227 int error_no = 0;
228 size_t read_bytes = 0;
229 long pos = 0;
230 int i = 0;
231 uint32_t signature = 0;
232 UT_array *index_entries = NULL;
233
234#ifdef USE_SLOG
235#include "slog.h"
236
237 slog_init("aaruformat.log", SLOG_FLAGS_ALL, 0);
238#endif
239
240 TRACE("Logging initialized");
241
242 TRACE("Entering aaruf_open(%s)", filepath);
243
244 TRACE("Allocating memory for context");
245 ctx = (aaruformat_context *)malloc(sizeof(aaruformat_context));
246
247 if(ctx == NULL)
248 {
249 FATAL("Not enough memory to create context");
251
252 TRACE("Exiting aaruf_open() = NULL");
253 return NULL;
254 }
255
256 memset(ctx, 0, sizeof(aaruformat_context));
257
258 TRACE("Opening file %s", filepath);
259 if(resume_mode)
260 ctx->imageStream = fopen(filepath, "r+b");
261 else
262 ctx->imageStream = fopen(filepath, "rb");
263
264 if(ctx->imageStream == NULL)
265 {
266 FATAL("Error %d opening file %s for reading", errno, filepath);
267 error_no = errno;
269 errno = error_no;
270
271 TRACE("Exiting aaruf_open() = NULL");
272 return NULL;
273 }
274
275 TRACE("Reading header at position 0");
276 fseek(ctx->imageStream, 0, SEEK_SET);
277 read_bytes = fread(&ctx->header, 1, sizeof(AaruHeader), ctx->imageStream);
278
279 if(read_bytes != sizeof(AaruHeader))
280 {
281 FATAL("Could not read header");
284
285 TRACE("Exiting aaruf_open() = NULL");
286 return NULL;
287 }
288
290 {
291 FATAL("Incorrect identifier for AaruFormat file: %8.8s", (char *)&ctx->header.identifier);
294
295 TRACE("Exiting aaruf_open() = NULL");
296 return NULL;
297 }
298
299 if(ctx->header.imageMajorVersion < AARUF_VERSION_V2 && resume_mode)
300 {
301 TRACE("Cannot write to old images");
304 TRACE("Exiting aaruf_open() = NULL");
305 return NULL;
306 }
307
308 // Read new header version
310 {
311 TRACE("Reading new header version at position 0");
312 fseek(ctx->imageStream, 0, SEEK_SET);
313 read_bytes = fread(&ctx->header, 1, sizeof(AaruHeaderV2), ctx->imageStream);
314
315 if(read_bytes != sizeof(AaruHeaderV2))
316 {
319
320 return NULL;
321 }
322 }
323
325 {
326 FATAL("Incompatible AaruFormat version %d.%d found, maximum supported is %d.%d", ctx->header.imageMajorVersion,
330
331 TRACE("Exiting aaruf_open() = NULL");
332 return NULL;
333 }
334
335 TRACE("Opening image version %d.%d", ctx->header.imageMajorVersion, ctx->header.imageMinorVersion);
336
337 TRACE("Allocating memory for readable sector tags bitmap");
338 ctx->readableSectorTags = (bool *)malloc(sizeof(bool) * MaxSectorTag);
339
340 if(ctx->readableSectorTags == NULL)
341 {
342 FATAL("Could not allocate memory for readable sector tags bitmap");
345
346 TRACE("Exiting aaruf_open() = NULL");
347 return NULL;
348 }
349
350 memset(ctx->readableSectorTags, 0, sizeof(bool) * MaxSectorTag);
351
352 TRACE("Setting up image info");
353
354 // Handle application name based on image version
355 memset(ctx->image_info.Application, 0, 64);
356
358 {
359 // Version 2+: application name is UTF-8, direct copy
360 TRACE("Converting application name (v2+): UTF-8 direct copy");
361 size_t copy_len = AARU_HEADER_APP_NAME_LEN < 63 ? AARU_HEADER_APP_NAME_LEN : 63;
362 memcpy(ctx->image_info.Application, ctx->header.application, copy_len);
363 ctx->image_info.Application[63] = '\0';
364 }
365 else
366 {
367 // Version 1: application name is UTF-16LE, convert by taking every other byte
368 TRACE("Converting application name (v1): UTF-16LE to ASCII");
369 int dest_idx = 0;
370 for(int j = 0; j < AARU_HEADER_APP_NAME_LEN && dest_idx < 63; j += 2)
371 // Take the low byte, skip the high byte (assuming it's 0x00 for ASCII)
372 if(ctx->header.application[j] != 0)
373 ctx->image_info.Application[dest_idx++] = ctx->header.application[j];
374 else
375 // Stop at null terminator
376 break;
377 ctx->image_info.Application[dest_idx] = '\0';
378 }
379
380 // Set application version string directly in the fixed-size array
381 memset(ctx->image_info.ApplicationVersion, 0, 32);
384
385 // Set image version string directly in the fixed-size array
386 memset(ctx->image_info.Version, 0, 32);
387 sprintf(ctx->image_info.Version, "%d.%d", ctx->header.imageMajorVersion, ctx->header.imageMinorVersion);
388
390
391 // Read the index header
392 TRACE("Reading index header at position %" PRIu64, ctx->header.indexOffset);
393 pos = fseek(ctx->imageStream, ctx->header.indexOffset, SEEK_SET);
394 if(pos < 0)
395 {
398
399 return NULL;
400 }
401
402 pos = ftell(ctx->imageStream);
403 if(pos != ctx->header.indexOffset)
404 {
407
408 return NULL;
409 }
410
411 read_bytes = fread(&signature, 1, sizeof(uint32_t), ctx->imageStream);
412
413 if(read_bytes != sizeof(uint32_t) ||
414 (signature != IndexBlock && signature != IndexBlock2 && signature != IndexBlock3))
415 {
416 FATAL("Could not read index header or incorrect identifier %4.4s", (char *)&signature);
419
420 TRACE("Exiting aaruf_open() = NULL");
421 return NULL;
422 }
423
424 if(signature == IndexBlock)
425 index_entries = process_index_v1(ctx);
426 else if(signature == IndexBlock2)
427 index_entries = process_index_v2(ctx);
428 else if(signature == IndexBlock3)
429 index_entries = process_index_v3(ctx);
430
431 if(index_entries == NULL)
432 {
433 FATAL("Could not process index.");
434 utarray_free(index_entries);
437
438 TRACE("Exiting aaruf_open() = NULL");
439 return NULL;
440 }
441
442 TRACE("Index at %" PRIu64 " contains %d entries", ctx->header.indexOffset, utarray_len(index_entries));
443
444 for(i = 0; i < utarray_len(index_entries); i++)
445 {
446 IndexEntry *entry = utarray_eltptr(index_entries, i);
447 TRACE("Block type %4.4s with data type %d is indexed to be at %" PRIu64 "", (char *)&entry->blockType,
448 entry->dataType, entry->offset);
449 }
450
451 bool found_user_data_ddt = false;
452 ctx->image_info.ImageSize = 0;
453 for(i = 0; i < utarray_len(index_entries); i++)
454 {
455 IndexEntry *entry = utarray_eltptr(index_entries, i);
456 pos = fseek(ctx->imageStream, entry->offset, SEEK_SET);
457
458 if(pos < 0 || ftell(ctx->imageStream) != entry->offset)
459 {
460 TRACE("Could not seek to %" PRIu64 " as indicated by index entry %d, continuing...", entry->offset, i);
461
462 continue;
463 }
464
465 TRACE("Processing block type %4.4s with data type %d at position %" PRIu64 "", (char *)&entry->blockType,
466 entry->dataType, entry->offset);
467 switch(entry->blockType)
468 {
469 case DataBlock:
470 error_no = process_data_block(ctx, entry);
471
472 if(error_no != AARUF_STATUS_OK)
473 {
474 utarray_free(index_entries);
476 errno = error_no;
477
478 return NULL;
479 }
480
481 break;
482
484 error_no = process_ddt_v1(ctx, entry, &found_user_data_ddt);
485
486 if(error_no != AARUF_STATUS_OK)
487 {
488 utarray_free(index_entries);
490 errno = error_no;
491
492 return NULL;
493 }
494
495 break;
497 error_no = process_ddt_v2(ctx, entry, &found_user_data_ddt);
498
499 if(error_no != AARUF_STATUS_OK)
500 {
501 utarray_free(index_entries);
503 errno = error_no;
504
505 return NULL;
506 }
507
508 break;
509 case GeometryBlock:
510 process_geometry_block(ctx, entry);
511
512 break;
513 case MetadataBlock:
514 process_metadata_block(ctx, entry);
515
516 break;
517 case TracksBlock:
518 process_tracks_block(ctx, entry);
519
520 break;
521 case CicmBlock:
522 process_cicm_block(ctx, entry);
523
524 break;
527
528 break;
529 // Dump hardware block
531 process_dumphw_block(ctx, entry);
532
533 break;
534 case ChecksumBlock:
535 process_checksum_block(ctx, entry);
536
537 break;
538 case TapeFileBlock:
539 process_tape_files_block(ctx, entry);
540
541 break;
544
545 break;
546 default:
547 TRACE("Unhandled block type %4.4s with data type %d is indexed to be at %" PRIu64 "",
548 (char *)&entry->blockType, entry->dataType, entry->offset);
549 break;
550 }
551 }
552
553 ctx->index_entries = index_entries;
554
555 if(!found_user_data_ddt)
556 {
557 FATAL("Could not find user data deduplication table, aborting...");
558 aaruf_close(ctx);
559
560 TRACE("Exiting aaruf_open() = NULL");
561 return NULL;
562 }
563
567
569 {
570 ctx->cylinders = (uint32_t)(ctx->image_info.Sectors / 16 / 63);
571 ctx->heads = 16;
572 ctx->sectors_per_track = 63;
573 }
574
575 // Initialize caches
576 TRACE("Initializing caches");
577 ctx->block_header_cache.cache = NULL;
578 ctx->block_cache.cache = NULL;
579
580 const uint64_t cache_divisor = (uint64_t)ctx->image_info.SectorSize * (1ULL << ctx->shift);
581 if(cache_divisor == 0)
582 {
584 ctx->block_cache.max_items = 0;
585 }
586 else
587 {
588 ctx->block_header_cache.max_items = MAX_CACHE_SIZE / cache_divisor;
590 }
591
592 // TODO: Cache tracks and sessions?
593
594 // Initialize ECC for Compact Disc
595 TRACE("Initializing ECC for Compact Disc");
597
598 ctx->magic = AARU_MAGIC;
601
602 if(!resume_mode)
603 {
604 TRACE("Exiting aaruf_open() = %p", ctx);
605 return ctx;
606 }
607
608 // Parse the options
609 TRACE("Parsing options");
610 const aaru_options parsed_options = parse_options(options);
611
614
615 // Calculate aligned next block position
616 fseek(ctx->imageStream, 0, SEEK_END);
617 const uint64_t alignment_mask = (1ULL << ctx->user_data_ddt_header.blockAlignmentShift) - 1;
618 ctx->next_block_position = ftell(ctx->imageStream); // Start just after the header
619 ctx->next_block_position = ctx->next_block_position + alignment_mask & ~alignment_mask;
620
621 TRACE("Data blocks will start at position %" PRIu64, ctx->next_block_position);
622
623 // Position file pointer at the data start position
624 if(fseek(ctx->imageStream, ctx->next_block_position, SEEK_SET) != 0)
625 {
626 FATAL("Could not seek to data start position");
628 TRACE("Exiting aaruf_open() = NULL");
630 return NULL;
631 }
632
633 // Apply applicable options (we cannot change table or alignment options resuming)
634 ctx->compression_enabled = parsed_options.compress;
635 ctx->lzma_dict_size = parsed_options.dictionary;
636 ctx->deduplicate = parsed_options.deduplicate;
637 if(ctx->deduplicate)
638 ctx->sector_hash_map = create_map(ctx->user_data_ddt_header.blocks * 25 / 100); // 25% of total sectors
639
640 // Cannot checksum a resumed file
641 ctx->rewinded = true;
642
643 // Is writing
644 ctx->is_writing = true;
645
646 TRACE("Exiting aaruf_open() = %p", ctx);
647 // Return context
648 return ctx;
649}
#define LIBAARUFORMAT_MAJOR_VERSION
Definition aaruformat.h:22
#define LIBAARUFORMAT_MINOR_VERSION
Definition aaruformat.h:23
#define DIC_MAGIC
Magic identifier for legacy DiscImageChef container (ASCII "DICMFRMT").
Definition consts.h:61
#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
#define AARUF_VERSION
Current image format major version (incompatible changes bump this).
Definition consts.h:68
#define AARU_CALL
Definition decls.h:45
int aaruf_close(void *context)
Close an Aaru image context, flushing pending data structures and releasing resources.
Definition close.c:4059
#define AARU_EXPORT
Definition decls.h:54
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:347
@ IndexBlock3
Block containing the index v3.
Definition enums.h:147
@ ChecksumBlock
Block containing contents checksums.
Definition enums.h:152
@ DataBlock
Block containing data.
Definition enums.h:141
@ TapePartitionBlock
Block containing list of partitions for a tape image.
Definition enums.h:158
@ IndexBlock2
Block containing the index v2.
Definition enums.h:146
@ GeometryBlock
Block containing logical geometry.
Definition enums.h:148
@ AaruMetadataJsonBlock
Block containing JSON version of Aaru Metadata.
Definition enums.h:159
@ CicmBlock
Block containing CICM XML metadata.
Definition enums.h:151
@ IndexBlock
Block containing the index (v1).
Definition enums.h:145
@ DeDuplicationTable2
Block containing a deduplication table v2.
Definition enums.h:143
@ TapeFileBlock
Block containing list of files for a tape image.
Definition enums.h:157
@ DeDuplicationTable
Block containing a deduplication table (v1).
Definition enums.h:142
@ DumpHardwareBlock
Block containing an array of hardware used to create the image.
Definition enums.h:156
@ MetadataBlock
Block containing metadata.
Definition enums.h:149
@ TracksBlock
Block containing optical disc tracks.
Definition enums.h:150
@ BlockMedia
Media that is physically block-based or abstracted like that.
Definition enums.h:219
#define AARUF_ERROR_CANNOT_CREATE_FILE
Output file could not be created / opened for write.
Definition errors.h:58
#define AARUF_STATUS_OK
Sector present and read without uncorrectable errors.
Definition errors.h:75
#define AARUF_ERROR_NOT_ENOUGH_MEMORY
Memory allocation failure (critical).
Definition errors.h:48
#define AARUF_ERROR_INCOMPATIBLE_VERSION
Image uses a newer incompatible on-disk version.
Definition errors.h:42
#define AARUF_ERROR_CANNOT_READ_INDEX
Index block unreadable / truncated / bad identifier.
Definition errors.h:43
#define AARUF_ERROR_NOT_AARUFORMAT
Input file/stream failed magic or structural validation.
Definition errors.h:40
#define AARUF_ERROR_FILE_TOO_SMALL
File size insufficient for mandatory header / structures.
Definition errors.h:41
@ MaxSectorTag
Definition aaru.h:970
hash_map_t * create_map(size_t size)
Creates a new hash map with the specified initial size.
Definition hash_map.c:49
#define AARU_HEADER_APP_NAME_LEN
Size in bytes (UTF-16LE) of application name field (32 UTF-16 code units).
Definition header.h:59
void process_dumphw_block(aaruformat_context *ctx, const IndexEntry *entry)
Processes a dump hardware block from the image stream.
Definition dump.c:107
UT_array * process_index_v2(aaruformat_context *ctx)
Processes an index block (version 2) from the image stream.
Definition index_v2.c:81
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
int32_t process_data_block(aaruformat_context *ctx, IndexEntry *entry)
Processes a data block from the image stream.
Definition data.c:71
uint64_t get_filetime_uint64()
Gets the current time as a 64-bit FILETIME value.
Definition time.c:45
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
void process_metadata_block(aaruformat_context *ctx, const IndexEntry *entry)
Processes a metadata block from the image stream.
Definition metadata.c:35
void process_checksum_block(aaruformat_context *ctx, const IndexEntry *entry)
Processes a checksum block from the image stream.
Definition checksum.c:39
UT_array * process_index_v1(aaruformat_context *ctx)
Processes an index block (version 1) from the image stream.
Definition index_v1.c:79
void process_cicm_block(aaruformat_context *ctx, const IndexEntry *entry)
Processes a CICM XML metadata block from the image stream.
Definition metadata.c:311
void process_geometry_block(aaruformat_context *ctx, const IndexEntry *entry)
Processes a logical geometry block from the image stream.
Definition metadata.c:251
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
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
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
aaru_options parse_options(const char *options)
Parses the options string for AaruFormat image creation/opening.
Definition options.c:38
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
UT_array * process_index_v3(aaruformat_context *ctx)
Processes an index block (version 3) from the image stream.
Definition index_v3.c:98
#define FATAL(fmt,...)
Definition log.h:40
#define TRACE(fmt,...)
Definition log.h:25
static void cleanup_open_failure(aaruformat_context *ctx)
Definition open.c:31
void * aaruf_open(const char *filepath, const bool resume_mode, const char *options)
Opens an existing AaruFormat image file.
Definition open.c:223
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
uint32_t mediaType
Media type enumeration (value from MediaType).
Definition header.h:114
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
Version 1 container header placed at offset 0 for legacy / initial format.
Definition header.h:77
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:86
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 identifier
Block identifier, must be BlockType::GeometryBlock.
Definition data.h:92
uint32_t MediaType
Media type identifier (see MediaType enum; 0=Unknown)
Definition aaru.h:933
uint8_t MetadataMediaType
Media type for sidecar generation (internal archival use)
Definition aaru.h:934
uint32_t SectorSize
Size of each logical sector in bytes (512, 2048, 2352, 4096, etc.)
Definition aaru.h:927
char Application[64]
Name of application that created the image (NUL-terminated)
Definition aaru.h:929
uint64_t ImageSize
Size of the image payload in bytes (excludes headers/metadata)
Definition aaru.h:925
int64_t CreationTime
Image creation timestamp (Windows FILETIME: 100ns since 1601-01-01 UTC)
Definition aaru.h:931
int64_t LastModificationTime
Last modification timestamp (Windows FILETIME format)
Definition aaru.h:932
char Version[32]
Image format version string (NUL-terminated, e.g., "6.0")
Definition aaru.h:928
uint64_t Sectors
Total count of addressable logical sectors/blocks.
Definition aaru.h:926
char ApplicationVersion[32]
Version of the creating application (NUL-terminated)
Definition aaru.h:930
Single index entry describing a block's type, (optional) data classification, and file offset.
Definition index.h:109
uint32_t blockType
Block identifier of the referenced block (value from BlockType).
Definition index.h:110
uint64_t offset
Absolute byte offset in the image where the referenced block header begins.
Definition index.h:112
uint16_t dataType
Data classification (value from DataType) or unused for untyped blocks.
Definition index.h:111
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
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
Master context representing an open or in‑creation Aaru image.
Definition context.h:172
DdtHeader2 user_data_ddt_header
Active user data DDT v2 header (primary table meta).
Definition context.h:189
uint8_t library_major_version
Linked library major version.
Definition context.h:177
bool deduplicate
Storage deduplication active (duplicates coalesce).
Definition context.h:299
bool compression_enabled
True if block compression enabled (writing path).
Definition context.h:300
hash_map_t * sector_hash_map
Deduplication hash map (fingerprint->entry mapping).
Definition context.h:253
uint32_t cylinders
Cylinders of the media represented by the image.
Definition context.h:234
struct CacheHeader block_header_cache
LRU/Cache header for block headers.
Definition context.h:256
uint8_t shift
Legacy overall shift (deprecated by data_shift/table_shift).
Definition context.h:195
CdEccContext * ecc_cd_context
CD ECC/EDC helper tables (allocated on demand).
Definition context.h:248
bool rewinded
True if stream has been rewound after open (write path).
Definition context.h:293
struct CacheHeader block_cache
LRU/Cache header for block payloads.
Definition context.h:257
AaruHeaderV2 header
Parsed container header (v2).
Definition context.h:175
bool is_writing
True if context opened/created for writing.
Definition context.h:292
uint64_t magic
File magic (AARU_MAGIC) post-open.
Definition context.h:174
uint8_t library_minor_version
Linked library minor version;.
Definition context.h:178
uint64_t next_block_position
Absolute file offset where next block will be written.
Definition context.h:282
GeometryBlockHeader geometry_block
Logical geometry block (if present).
Definition context.h:229
uint32_t sectors_per_track
Sectors per track of the media represented by the image (for variable image, the smallest)
Definition context.h:236
uint32_t heads
Heads of the media represented by the image.
Definition context.h:235
FILE * imageStream
Underlying FILE* stream (binary mode).
Definition context.h:176
UT_array * index_entries
Flattened index entries (UT_array of IndexEntry).
Definition context.h:252
ImageInfo image_info
Exposed high-level image info summary.
Definition context.h:260
bool * readableSectorTags
Per-sector boolean array (optical tags read successfully?).
Definition context.h:263
uint32_t lzma_dict_size
LZMA dictionary size (writing path).
Definition context.h:298