Loading...
Searching...
No Matches
context.h File Reference

Central runtime context structures for libaaruformat (image state, caches, checksum buffers). More...

`#include "blake3.h"`
`#include "crc64.h"`
`#include "structs/flux.h"`
`#include "hash_map.h"`
`#include "lru.h"`
`#include "md5.h"`
`#include "sha1.h"`
`#include "sha256.h"`
`#include "spamsum.h"`
`#include "structs.h"`
`#include "utarray.h"`

Go to the source code of this file.

## Data Structures

struct | CdEccContext
| Lookup tables and state for Compact Disc EDC/ECC (P/Q) regeneration / verification. More...
struct | Checksums
| Collected whole‑image checksums / hashes present in a checksum block. More...
struct | mediaTagEntry
| Hash table entry for an arbitrary media tag (e.g., proprietary drive/medium descriptor). More...
struct | TapeFileHashEntry
struct | TapePartitionHashEntry
struct | TapeDdtHashEntry
struct | aaruformat_context
| Master context representing an open or in‑creation Aaru image. More...
struct | DumpHardwareEntriesWithData
| In-memory representation of a dump hardware entry plus decoded variable-length fields & extents. More...
struct | DumpExtent
| Inclusive [start,end] logical sector range contributed by a single hardware environment. More...

## Macros

#define | MD5_DIGEST_LENGTH 16

## Typedefs

typedef struct FluxCaptureMapEntry | FluxCaptureMapEntry
typedef struct CdEccContext | CdEccContext
typedef struct Checksums | Checksums
typedef struct mediaTagEntry | mediaTagEntry
typedef struct TapeFileHashEntry | tapeFileHashEntry
typedef struct TapePartitionHashEntry | TapePartitionHashEntry
typedef struct TapeDdtHashEntry | TapeDdtHashEntry
typedef struct aaruformat_context | aaruformat_context
typedef struct DumpHardwareEntriesWithData | DumpHardwareEntriesWithData
typedef struct DumpExtent | DumpExtent

## Detailed Description

Central runtime context structures for libaaruformat (image state, caches, checksum buffers).

The principal structure, aaruformat_context, aggregates: header metadata, open stream handle, deduplication tables (DDT) currently in memory, optical disc auxiliary data (sector prefix/suffix/subchannel), track listings, geometry & metadata blocks, checksum accumulators, CRC & ECC helper contexts, hash map for deduplication, and transient write buffers.

Memory ownership model (unless otherwise stated): if a pointer field is non-NULL it is owned by the context and will be freed (or otherwise released) during context close / destruction. Callers must not free or reallocate these pointers directly. External callers should treat all internal buffers as read‑only unless explicitly writing.

Threading: a single context instance is NOT thread-safe; serialize access if used across threads. Lifetime: allocate, initialize/open, perform read/write/verify operations, then close/free.

Deduplication tables (DDT): only a subset (primary table + an active secondary + optional cache) is retained in RAM; large images may rely on lazy loading of secondary tables. Flags (inMemoryDdt, userDataDdt*, cachedSecondary*) indicate what is currently resident.

Optical auxiliary buffers (sectorPrefix / sectorSuffix / subchannel / corrected variants) are populated only for images where those components exist (e.g., raw CD dumps). They may be NULL for block devices / non‑optical media.

Index handling: indexEntries (UT_array) holds a flattened list of IndexEntry structures (regardless of v1/v2/v3). hash_map_t *sectorHashMap provides fast duplicate detection keyed by content fingerprint / sparse sector key.

Invariants / sanity expectations (not strictly enforced everywhere):

- magic == AARU_MAGIC after successful open/create.
- header.imageMajorVersion <= AARUF_VERSION.
- imageStream != NULL when any I/O method is in progress.
- If deduplicate == false, sectorHashMap may still be populated for bookkeeping but duplicates are stored independently.
- If userDataDdtMini != NULL then userDataDdtBig == NULL (and vice versa) for a given level.

Definition in file context.h.

## Macro Definition Documentation

## MD5_DIGEST_LENGTH

#define MD5_DIGEST_LENGTH 16

Definition at line 72 of file context.h.

Referenced by process_checksum_block(), and write_checksum_block().

## Typedef Documentation

## aaruformat_context

typedef struct aaruformat_context aaruformat_context

## CdEccContext

typedef struct CdEccContext CdEccContext

## Checksums

typedef struct Checksums Checksums

## DumpExtent

typedef struct DumpExtent DumpExtent

## DumpHardwareEntriesWithData

typedef struct DumpHardwareEntriesWithData DumpHardwareEntriesWithData

## FluxCaptureMapEntry

typedef struct FluxCaptureMapEntry FluxCaptureMapEntry

Definition at line 34 of file context.h.

## mediaTagEntry

typedef struct mediaTagEntry mediaTagEntry

## TapeDdtHashEntry

typedef struct TapeDdtHashEntry TapeDdtHashEntry

## tapeFileHashEntry

typedef struct TapeFileHashEntry tapeFileHashEntry

## TapePartitionHashEntry

typedef struct TapePartitionHashEntry TapePartitionHashEntry