|
libaaruformat 1.0
Aaru Data Preservation Suite - Format Library
|
#include "aaru.h"#include "crc64.h"#include "md5.h"#include "sha1.h"#include "sha256.h"#include "simd.h"#include "spamsum.h"#include "structs/optical.h"Go to the source code of this file.
Macros | |
| #define | EXTERNC |
| #define | AARU_CALL |
| #define | AARU_EXPORT EXTERNC |
| #define | AARU_LOCAL |
| #define | FORCE_INLINE static inline __attribute__((always_inline)) |
Functions | |
| int | aaruf_identify (const char *filename) |
| Identifies a file as an AaruFormat image using a file path. | |
| int | aaruf_identify_stream (FILE *image_stream) |
| Identifies a file as an AaruFormat image using an open stream. | |
| void * | aaruf_open (const char *filepath) |
| Opens an existing AaruFormat image file. | |
| void * | aaruf_create (const char *filepath, uint32_t media_type, uint32_t sector_size, uint64_t user_sectors, uint64_t negative_sectors, uint64_t overflow_sectors, const char *options, const uint8_t *application_name, uint8_t application_name_length, uint8_t application_major_version, uint8_t application_minor_version, bool is_tape) |
| Creates a new AaruFormat image file. | |
| int | aaruf_close (void *context) |
| Close an Aaru image context, flushing pending data structures and releasing resources. | |
| int32_t | aaruf_read_media_tag (void *context, uint8_t *data, int32_t tag, uint32_t *length) |
| Reads a media tag from the AaruFormat image. | |
| crc64_ctx * | aaruf_crc64_init () |
| Initializes a CRC64 context. | |
| int | aaruf_crc64_update (crc64_ctx *ctx, const uint8_t *data, uint32_t len) |
| Updates the CRC64 context with new data. | |
| int | aaruf_crc64_final (crc64_ctx *ctx, uint64_t *crc) |
| Computes the final CRC64 value from the context. | |
| void | aaruf_crc64_free (crc64_ctx *ctx) |
| Frees a CRC64 context. | |
| void | aaruf_crc64_slicing (uint64_t *previous_crc, const uint8_t *data, uint32_t len) |
| Updates a CRC64 value using the slicing-by-8 algorithm. | |
| uint64_t | aaruf_crc64_data (const uint8_t *data, uint32_t len) |
| int32_t | aaruf_get_tracks (const void *context, uint8_t *buffer, size_t *length) |
| Retrieve the array of track descriptors contained in an opened AaruFormat image. | |
| int32_t | aaruf_set_tracks (void *context, TrackEntry *tracks, const int count) |
| Replace (or clear) the in-memory track table for an AaruFormat image context. | |
| int32_t | aaruf_read_sector (void *context, uint64_t sector_address, bool negative, uint8_t *data, uint32_t *length) |
| Reads a sector from the AaruFormat image. | |
| int32_t | aaruf_read_sector_long (void *context, uint64_t sector_address, bool negative, uint8_t *data, uint32_t *length) |
| Reads a complete sector with all metadata from the AaruFormat image. | |
| int32_t | aaruf_write_sector (void *context, uint64_t sector_address, bool negative, const uint8_t *data, uint8_t sector_status, uint32_t length) |
| Writes a sector to the AaruFormat image. | |
| int32_t | aaruf_write_sector_long (void *context, uint64_t sector_address, bool negative, const uint8_t *data, uint8_t sector_status, uint32_t length) |
| Writes a full ("long") raw sector from optical or block media, parsing structure and validating content. | |
| int32_t | aaruf_write_media_tag (void *context, const uint8_t *data, int32_t type, uint32_t length) |
| Writes a media tag to the AaruFormat image, storing medium-specific metadata and descriptors. | |
| int32_t | aaruf_write_sector_tag (void *context, uint64_t sector_address, bool negative, const uint8_t *data, size_t length, int32_t tag) |
| Writes per-sector tag data (auxiliary metadata) for a specific sector. | |
| int32_t | aaruf_verify_image (void *context) |
| Verifies the integrity of an AaruFormat image file. | |
| int32_t | aaruf_cst_transform (const uint8_t *interleaved, uint8_t *sequential, size_t length) |
| Transforms interleaved subchannel data to sequential format. | |
| int32_t | aaruf_cst_untransform (const uint8_t *sequential, uint8_t *interleaved, size_t length) |
| Reverses the CST (Claunia's Subchannel Transform) transformation from sequential to interleaved data. | |
| void * | aaruf_ecc_cd_init () |
| Initializes a Compact Disc ECC context. | |
| bool | aaruf_ecc_cd_is_suffix_correct (void *context, const uint8_t *sector) |
| Checks if the suffix (EDC/ECC) of a CD sector is correct (Mode 1). | |
| bool | aaruf_ecc_cd_is_suffix_correct_mode2 (void *context, const uint8_t *sector) |
| Checks if the suffix (EDC/ECC) of a CD sector is correct (Mode 2). | |
| bool | aaruf_ecc_cd_check (void *context, const uint8_t *address, const uint8_t *data, uint32_t major_count, uint32_t minor_count, uint32_t major_mult, uint32_t minor_inc, const uint8_t *ecc, int32_t address_offset, int32_t data_offset, int32_t ecc_offset) |
| Checks the ECC of a CD sector. | |
| void | aaruf_ecc_cd_write (void *context, const uint8_t *address, const uint8_t *data, uint32_t major_count, uint32_t minor_count, uint32_t major_mult, uint32_t minor_inc, uint8_t *ecc, int32_t address_offset, int32_t data_offset, int32_t ecc_offset) |
| Writes ECC for a CD sector. | |
| void | aaruf_ecc_cd_write_sector (void *context, const uint8_t *address, const uint8_t *data, uint8_t *ecc, int32_t address_offset, int32_t data_offset, int32_t ecc_offset) |
| Writes ECC for a full CD sector (both P and Q ECC). | |
| void | aaruf_cd_lba_to_msf (int64_t pos, uint8_t *minute, uint8_t *second, uint8_t *frame) |
| Converts a CD LBA (Logical Block Address) to MSF (Minute:Second:Frame) format. | |
| void | aaruf_ecc_cd_reconstruct_prefix (uint8_t *sector, uint8_t type, int64_t lba) |
| Reconstructs the prefix (sync, address, mode) of a CD sector. | |
| void | aaruf_ecc_cd_reconstruct (void *context, uint8_t *sector, uint8_t type) |
| Reconstructs the EDC and ECC fields of a CD sector. | |
| uint32_t | aaruf_edc_cd_compute (void *context, uint32_t edc, const uint8_t *src, int size, int pos) |
| Computes the EDC (Error Detection Code) for a CD sector. | |
| int32_t | aaruf_read_track_sector (void *context, uint8_t *data, uint64_t sector_address, uint32_t *length, uint8_t track) |
| Reads a sector from a specific track in the AaruFormat image. | |
| int32_t | aaruf_read_sector_tag (const void *context, uint64_t sector_address, bool negative, uint8_t *buffer, uint32_t *length, int32_t tag) |
| Reads a specific sector tag from the AaruFormat image. | |
| int32_t | aaruf_get_media_tag_type_for_datatype (int32_t type) |
| Converts an image data type to an Aaru media tag type. | |
| int32_t | aaruf_get_datatype_for_media_tag_type (int32_t tag_type) |
| Converts an Aaru media tag type to an image data type. | |
| int32_t | aaruf_get_xml_mediatype (int32_t type) |
| int32_t | aaruf_get_geometry (const void *context, uint32_t *cylinders, uint32_t *heads, uint32_t *sectors_per_track) |
| Retrieves the logical CHS geometry from the AaruFormat image. | |
| int32_t | aaruf_set_geometry (void *context, uint32_t cylinders, uint32_t heads, uint32_t sectors_per_track) |
| Sets the logical CHS geometry for the AaruFormat image. | |
| int32_t | aaruf_set_media_sequence (void *context, int32_t sequence, int32_t last_sequence) |
| Sets the media sequence information for multi-volume media sets. | |
| int32_t | aaruf_set_creator (void *context, const uint8_t *data, int32_t length) |
| Sets the creator (person/operator) information for the image. | |
| int32_t | aaruf_set_comments (void *context, const uint8_t *data, int32_t length) |
| Sets user comments or notes for the image. | |
| int32_t | aaruf_set_media_title (void *context, const uint8_t *data, int32_t length) |
| Sets the media title or label for the image. | |
| int32_t | aaruf_set_media_manufacturer (void *context, const uint8_t *data, int32_t length) |
| Sets the media manufacturer information for the image. | |
| int32_t | aaruf_set_media_model (void *context, const uint8_t *data, int32_t length) |
| Sets the media model or product designation for the image. | |
| int32_t | aaruf_set_media_serial_number (void *context, const uint8_t *data, int32_t length) |
| Sets the media serial number for the image. | |
| int32_t | aaruf_set_media_barcode (void *context, const uint8_t *data, int32_t length) |
| Sets the media barcode information for the image. | |
| int32_t | aaruf_set_media_part_number (void *context, const uint8_t *data, int32_t length) |
| Sets the media part number or model designation for the image. | |
| int32_t | aaruf_set_drive_manufacturer (void *context, const uint8_t *data, int32_t length) |
| Sets the drive manufacturer information for the image. | |
| int32_t | aaruf_set_drive_model (void *context, const uint8_t *data, int32_t length) |
| Sets the drive model information for the image. | |
| int32_t | aaruf_set_drive_serial_number (void *context, const uint8_t *data, int32_t length) |
| Sets the drive serial number for the image. | |
| int32_t | aaruf_set_drive_firmware_revision (void *context, const uint8_t *data, int32_t length) |
| Sets the drive firmware revision for the image. | |
| int32_t | aaruf_get_media_sequence (const void *context, int32_t *sequence, int32_t *last_sequence) |
| Retrieves the media sequence metadata for multi-volume image sets. | |
| int32_t | aaruf_get_creator (const void *context, uint8_t *buffer, int32_t *length) |
| Retrieves the recorded creator (operator) name from the MetadataBlock. | |
| int32_t | aaruf_get_comments (const void *context, uint8_t *buffer, int32_t *length) |
| Retrieves the user comments or notes stored in the MetadataBlock. | |
| int32_t | aaruf_get_media_title (const void *context, uint8_t *buffer, int32_t *length) |
| Retrieves the media title or label captured during image creation. | |
| int32_t | aaruf_get_media_manufacturer (const void *context, uint8_t *buffer, int32_t *length) |
| Retrieves the recorded media manufacturer name. | |
| int32_t | aaruf_get_media_model (const void *context, uint8_t *buffer, int32_t *length) |
| Retrieves the media model or product designation metadata. | |
| int32_t | aaruf_get_media_serial_number (const void *context, uint8_t *buffer, int32_t *length) |
| Retrieves the media serial number recorded in the image metadata. | |
| int32_t | aaruf_get_media_barcode (const void *context, uint8_t *buffer, int32_t *length) |
| Retrieves the barcode assigned to the physical media or its packaging. | |
| int32_t | aaruf_get_media_part_number (const void *context, uint8_t *buffer, int32_t *length) |
| Retrieves the media part number recorded in the MetadataBlock. | |
| int32_t | aaruf_get_drive_manufacturer (const void *context, uint8_t *buffer, int32_t *length) |
| Retrieves the drive manufacturer metadata captured during imaging. | |
| int32_t | aaruf_get_drive_model (const void *context, uint8_t *buffer, int32_t *length) |
| Retrieves the device model information for the imaging drive. | |
| int32_t | aaruf_get_drive_serial_number (const void *context, uint8_t *buffer, int32_t *length) |
| Retrieves the imaging drive's serial number metadata. | |
| int32_t | aaruf_get_drive_firmware_revision (const void *context, uint8_t *buffer, int32_t *length) |
| Retrieves the firmware revision metadata for the imaging drive. | |
| int32_t | aaruf_get_cicm_metadata (const void *context, uint8_t *buffer, size_t *length) |
| Retrieves the embedded CICM XML metadata sidecar from the image. | |
| int32_t | aaruf_get_aaru_json_metadata (const void *context, uint8_t *buffer, size_t *length) |
| Retrieves the embedded Aaru metadata JSON from the image. | |
| int32_t | aaruf_set_aaru_json_metadata (void *context, uint8_t *data, size_t length) |
| Sets the Aaru metadata JSON for the image during creation. | |
| int32_t | aaruf_get_user_sectors (const void *context, uint64_t *sectors) |
| Retrieves the total number of user-accessible sectors in the AaruFormat image. | |
| int32_t | aaruf_get_negative_sectors (const void *context, uint16_t *sectors) |
| Retrieves the number of negative (pre-gap) sectors in the AaruFormat image. | |
| int32_t | aaruf_get_overflow_sectors (const void *context, uint16_t *sectors) |
| Retrieves the number of overflow (post-gap) sectors in the AaruFormat image. | |
| int32_t | aaruf_get_image_info (const void *context, ImageInfo *image_info) |
| Retrieves a deep copy of the ImageInfo structure from the AaruFormat image. | |
| int32_t | aaruf_get_tape_file (const void *context, uint8_t partition, uint32_t file, uint64_t *starting_block, uint64_t *ending_block) |
| Retrieves the block range for a specific tape file from an Aaru tape image. | |
| int32_t | aaruf_set_tape_file (void *context, uint8_t partition, uint32_t file, uint64_t starting_block, uint64_t ending_block) |
| Sets or updates the block range for a specific tape file in an Aaru tape image. | |
| int32_t | aaruf_get_tape_partition (const void *context, uint8_t partition, uint64_t *starting_block, uint64_t *ending_block) |
| Retrieves the block range for a specific tape partition from an Aaru tape image. | |
| int32_t | aaruf_set_tape_partition (void *context, uint8_t partition, uint64_t starting_block, uint64_t ending_block) |
| Sets or updates the block range for a specific tape partition in an Aaru tape image. | |
| int32_t | aaruf_get_dumphw (void *context, uint8_t *buffer, size_t *length) |
| Retrieves the dump hardware block containing acquisition environment information. | |
| int32_t | aaruf_set_dumphw (void *context, uint8_t *data, size_t length) |
| Sets the dump hardware block for the image during creation. | |
| spamsum_ctx * | aaruf_spamsum_init (void) |
| int | aaruf_spamsum_update (spamsum_ctx *ctx, const uint8_t *data, uint32_t len) |
| Updates the spamsum context with new data. | |
| int | aaruf_spamsum_final (spamsum_ctx *ctx, uint8_t *result) |
| void | aaruf_spamsum_free (spamsum_ctx *ctx) |
| Frees a spamsum (fuzzy hash) context. | |
| void | fuzzy_engine_step (spamsum_ctx *ctx, uint8_t c) |
| void | roll_hash (spamsum_ctx *ctx, uint8_t c) |
| void | fuzzy_try_reduce_blockhash (spamsum_ctx *ctx) |
| void | fuzzy_try_fork_blockhash (spamsum_ctx *ctx) |
| size_t | aaruf_flac_decode_redbook_buffer (uint8_t *dst_buffer, size_t dst_size, const uint8_t *src_buffer, size_t src_size) |
| Decodes a FLAC-compressed Red Book audio buffer. | |
| size_t | aaruf_flac_encode_redbook_buffer (uint8_t *dst_buffer, size_t dst_size, const uint8_t *src_buffer, size_t src_size, uint32_t blocksize, int32_t do_mid_side_stereo, int32_t loose_mid_side_stereo, const char *apodization, uint32_t max_lpc_order, uint32_t qlp_coeff_precision, int32_t do_qlp_coeff_prec_search, int32_t do_exhaustive_model_search, uint32_t min_residual_partition_order, uint32_t max_residual_partition_order, const char *application_id, uint32_t application_id_len) |
| Encodes a Red Book audio buffer to FLAC format. | |
| int32_t | aaruf_lzma_decode_buffer (uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer, size_t *src_size, const uint8_t *props, size_t props_size) |
| Decodes an LZMA-compressed buffer. | |
| int32_t | aaruf_lzma_encode_buffer (uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer, size_t src_size, uint8_t *out_props, size_t *out_props_size, int32_t level, uint32_t dict_size, int32_t lc, int32_t lp, int32_t pb, int32_t fb, int32_t num_threads) |
| Encodes a buffer using LZMA compression. | |
| void | aaruf_md5_init (md5_ctx *ctx) |
| void | aaruf_md5_update (md5_ctx *ctx, const void *data, unsigned long size) |
| void | aaruf_md5_final (md5_ctx *ctx, unsigned char *result) |
| void | aaruf_md5_buffer (const void *data, unsigned long size, unsigned char *result) |
| void | aaruf_sha1_init (sha1_ctx *ctx) |
| void | aaruf_sha1_update (sha1_ctx *ctx, const void *data, unsigned long size) |
| void | aaruf_sha1_final (sha1_ctx *ctx, unsigned char *result) |
| void | aaruf_sha1_buffer (const void *data, unsigned long size, unsigned char *result) |
| void | aaruf_sha256_init (sha256_ctx *ctx) |
| void | aaruf_sha256_update (sha256_ctx *ctx, const void *data, unsigned long size) |
| void | aaruf_sha256_final (sha256_ctx *ctx, unsigned char *result) |
| void | aaruf_sha256_buffer (const void *data, unsigned long size, unsigned char *result) |
| #define AARU_CALL |
Definition at line 45 of file decls.h.
Referenced by aaruf_crc64_data(), aaruf_crc64_final(), aaruf_crc64_free(), aaruf_crc64_init(), aaruf_crc64_slicing(), aaruf_crc64_update(), aaruf_flac_decode_redbook_buffer(), aaruf_flac_encode_redbook_buffer(), aaruf_lzma_decode_buffer(), aaruf_lzma_encode_buffer(), aaruf_md5_buffer(), aaruf_md5_final(), aaruf_md5_init(), aaruf_md5_update(), aaruf_sha1_buffer(), aaruf_sha1_final(), aaruf_sha1_init(), aaruf_sha1_update(), aaruf_sha256_buffer(), aaruf_sha256_final(), aaruf_sha256_init(), aaruf_sha256_update(), aaruf_spamsum_final(), aaruf_spamsum_free(), aaruf_spamsum_init(), and aaruf_spamsum_update().
| #define AARU_EXPORT EXTERNC |
Definition at line 54 of file decls.h.
Referenced by aaruf_crc64_data(), aaruf_crc64_final(), aaruf_crc64_free(), aaruf_crc64_init(), aaruf_crc64_slicing(), aaruf_crc64_update(), aaruf_flac_decode_redbook_buffer(), aaruf_flac_encode_redbook_buffer(), aaruf_lzma_decode_buffer(), aaruf_lzma_encode_buffer(), aaruf_md5_buffer(), aaruf_md5_final(), aaruf_md5_init(), aaruf_md5_update(), aaruf_sha1_buffer(), aaruf_sha1_final(), aaruf_sha1_init(), aaruf_sha1_update(), aaruf_sha256_buffer(), aaruf_sha256_final(), aaruf_sha256_init(), aaruf_sha256_update(), aaruf_spamsum_final(), aaruf_spamsum_free(), aaruf_spamsum_init(), and aaruf_spamsum_update().
| #define AARU_LOCAL |
Definition at line 55 of file decls.h.
Referenced by fuzzy_engine_step(), fuzzy_try_fork_blockhash(), fuzzy_try_reduce_blockhash(), roll_hash(), sha1_transform(), and sha256_transform().
| #define FORCE_INLINE static inline __attribute__((always_inline)) |
Definition at line 63 of file decls.h.
Referenced by __attribute__(), and md5_process_block_loaded().
| void aaruf_cd_lba_to_msf | ( | const int64_t | pos, |
| uint8_t * | minute, | ||
| uint8_t * | second, | ||
| uint8_t * | frame ) |
Converts a CD LBA (Logical Block Address) to MSF (Minute:Second:Frame) format.
| pos | LBA position. |
| minute | Pointer to store the minute value. |
| second | Pointer to store the second value. |
| frame | Pointer to store the frame value. |
Definition at line 370 of file ecc_cd.c.
References TRACE.
Referenced by aaruf_ecc_cd_reconstruct_prefix().
| int aaruf_close | ( | void * | context | ) |
Close an Aaru image context, flushing pending data structures and releasing resources.
Public API entry point used to finalize an image being written or simply dispose of a context opened for reading. For write-mode contexts (ctx->isWriting true) the function performs the following ordered steps:
Afterwards (or for read-mode contexts) all dynamically allocated buffers, arrays, hash tables and mapping structures are freed/unmapped. Media tags are removed from their hash table.
Error Handling:
| context | Opaque pointer returned by earlier open/create calls (must be an aaruformatContext). |
| 0 | All pending data flushed (if writing) and resources released successfully. |
| -1 | Invalid context pointer or initial header rewrite failure (errno = EINVAL or AARUF_ERROR_CANNOT_WRITE_HEADER). |
| AARUF_ERROR_CANNOT_WRITE_HEADER | A later write helper (e.g., index, DDT) failed and returned this code directly. |
| <other | negative libaaruformat code> Propagated from a write helper if future helpers add more error codes. |
Definition at line 3995 of file close.c.
References AARU_MAGIC, aaruf_close_current_block(), AARUF_ERROR_CANNOT_WRITE_HEADER, AARUF_STATUS_OK, aaruformat_context::checksums, aaruformat_context::cicm_block, mediaTagEntry::data, aaruformat_context::deduplicate, aaruformat_context::dump_hardware_entries_with_data, aaruformat_context::dump_hardware_header, aaruformat_context::ecc_cd_context, DumpHardwareHeader::entries, DumpHardwareEntriesWithData::extents, FATAL, DumpHardwareEntriesWithData::firmware, free_map(), aaruformat_context::header, aaruformat_context::imageStream, aaruformat_context::in_memory_ddt, aaruformat_context::index_entries, aaruformat_context::is_tape, aaruformat_context::is_writing, aaruformat_context::magic, DumpHardwareEntriesWithData::manufacturer, aaruformat_context::mapped_memory_ddt_size, aaruformat_context::mediaTags, aaruformat_context::metadata_block, aaruformat_context::mode2_subheaders, DumpHardwareEntriesWithData::model, aaruformat_context::readableSectorTags, DumpHardwareEntriesWithData::revision, aaruformat_context::sector_cpr_mai, aaruformat_context::sector_edc, aaruformat_context::sector_hash_map, aaruformat_context::sector_id, aaruformat_context::sector_ied, aaruformat_context::sector_prefix, aaruformat_context::sector_prefix_corrected, aaruformat_context::sector_prefix_ddt, aaruformat_context::sector_prefix_ddt2, aaruformat_context::sector_subchannel, aaruformat_context::sector_suffix, aaruformat_context::sector_suffix_corrected, aaruformat_context::sector_suffix_ddt, aaruformat_context::sector_suffix_ddt2, DumpHardwareEntriesWithData::serial, DumpHardwareEntriesWithData::softwareName, DumpHardwareEntriesWithData::softwareOperatingSystem, DumpHardwareEntriesWithData::softwareVersion, Checksums::spamsum, TRACE, aaruformat_context::track_entries, aaruformat_context::user_data_ddt, write_aaru_json_block(), write_cached_secondary_ddt(), write_checksum_block(), write_cicm_block(), write_dumphw_block(), write_dvd_long_sector_blocks(), write_dvd_title_key_decrypted_block(), write_geometry_block(), write_index_block(), write_media_tags(), write_metadata_block(), write_mode2_subheaders_block(), write_primary_ddt(), write_sector_prefix(), write_sector_prefix_ddt(), write_sector_subchannel(), write_sector_suffix(), write_sector_suffix_ddt(), write_single_level_ddt(), write_tape_ddt(), write_tape_file_block(), write_tape_partition_block(), write_tracks_block(), and aaruformat_context::writing_buffer.
Referenced by aaruf_open().
| uint64_t aaruf_crc64_data | ( | const uint8_t * | data, |
| uint32_t | len ) |
Definition at line 160 of file crc64.c.
References AARU_CALL, AARU_EXPORT, aaruf_crc64_final(), aaruf_crc64_free(), aaruf_crc64_init(), and aaruf_crc64_update().
Referenced by aaruf_close_current_block(), aaruf_get_dumphw(), aaruf_set_dumphw(), aaruf_set_tracks(), process_data_block(), process_dumphw_block(), process_tape_files_block(), process_tape_partitions_block(), process_tracks_block(), set_ddt_multi_level_v2(), verify_index_v1(), write_cached_secondary_ddt(), write_dumphw_block(), write_dvd_long_sector_blocks(), write_dvd_title_key_decrypted_block(), write_media_tags(), write_mode2_subheaders_block(), write_sector_prefix(), write_sector_prefix_ddt(), write_sector_subchannel(), write_sector_suffix(), write_sector_suffix_ddt(), write_single_level_ddt(), write_tape_file_block(), and write_tape_partition_block().
| int aaruf_crc64_final | ( | crc64_ctx * | ctx, |
| uint64_t * | crc ) |
Computes the final CRC64 value from the context.
| ctx | Pointer to the CRC64 context. |
| crc | Pointer to store the resulting CRC64 value. |
Definition at line 141 of file crc64.c.
References AARU_CALL, AARU_EXPORT, crc64_ctx::crc, and CRC64_ECMA_SEED.
Referenced by aaruf_close_current_block(), aaruf_crc64_data(), aaruf_verify_image(), decode_ddt_multi_level_v2(), process_ddt_v2(), set_ddt_multi_level_v2(), verify_index_v2(), verify_index_v3(), write_cached_secondary_ddt(), write_index_block(), and write_primary_ddt().
| void aaruf_crc64_free | ( | crc64_ctx * | ctx | ) |
Frees a CRC64 context.
| ctx | Pointer to the CRC64 context to free. |
Definition at line 155 of file crc64.c.
References AARU_CALL, and AARU_EXPORT.
Referenced by aaruf_close_current_block(), aaruf_crc64_data(), aaruf_verify_image(), verify_index_v2(), and verify_index_v3().
| crc64_ctx * aaruf_crc64_init | ( | void | ) |
Initializes a CRC64 context.
Allocates and initializes a CRC64 context for checksum calculations.
Definition at line 32 of file crc64.c.
References AARU_CALL, AARU_EXPORT, crc64_ctx::crc, CRC64_ECMA_SEED, and TRACE.
Referenced by aaruf_close_current_block(), aaruf_crc64_data(), aaruf_verify_image(), decode_ddt_multi_level_v2(), process_ddt_v2(), set_ddt_multi_level_v2(), verify_index_v2(), verify_index_v3(), write_cached_secondary_ddt(), write_index_block(), and write_primary_ddt().
| void aaruf_crc64_slicing | ( | uint64_t * | previous_crc, |
| const uint8_t * | data, | ||
| uint32_t | len ) |
Updates a CRC64 value using the slicing-by-8 algorithm.
| previous_crc | Pointer to the previous CRC64 value (input/output). |
| data | Pointer to the data buffer. |
| len | Length of the data buffer in bytes. |
Definition at line 102 of file crc64.c.
References AARU_CALL, AARU_EXPORT, and crc64_table.
Referenced by aaruf_crc64_update().
| int aaruf_crc64_update | ( | crc64_ctx * | ctx, |
| const uint8_t * | data, | ||
| uint32_t | len ) |
Updates the CRC64 context with new data.
Processes the given data buffer and updates the CRC64 value in the context.
| ctx | Pointer to the CRC64 context. |
| data | Pointer to the data buffer. |
| len | Length of the data buffer. |
Definition at line 55 of file crc64.c.
References AARU_CALL, AARU_EXPORT, aaruf_crc64_slicing(), crc64_ctx::crc, and TRACE.
Referenced by aaruf_close_current_block(), aaruf_crc64_data(), decode_ddt_multi_level_v2(), process_ddt_v2(), set_ddt_multi_level_v2(), update_crc64_from_stream(), verify_index_v2(), verify_index_v3(), write_cached_secondary_ddt(), write_index_block(), and write_primary_ddt().
| 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.
Allocates and initializes a new aaruformat context and image file with the specified parameters. This function sets up all necessary data structures including headers, DDT (deduplication table), caches, and index entries for writing a new AaruFormat image. It also handles file creation, memory allocation, and proper initialization of the writing context. The function supports both block-based media (disks, optical media) and sequential tape media with different initialization strategies optimized for each media type.
Media Type Handling: The function creates different internal structures based on the is_tape parameter:
Block Media (is_tape = false):
Tape Media (is_tape = true):
Initialization Flow:
DDT Configuration (Block Media Only): The function automatically selects optimal DDT parameters:
The DDT offset calculation ensures proper alignment:
| filepath | Path to the image file to create. The file will be created if it doesn't exist, or overwritten if it does. Must be a valid writable path. |
| media_type | Media type identifier (e.g., CompactDisc, DVD, HardDisk, Tape formats). This affects how the image is structured and which features are enabled. |
| sector_size | Size of each sector/block in bytes. Common values:
|
| user_sectors | Number of user data sectors/blocks in the image. This is the main data area excluding negative (lead-in) and overflow (lead-out) regions. For tape media, this may be an estimate as the final size is often unknown. |
| negative_sectors | Number of negative sectors (typically lead-in area for optical media). Set to 0 for media types without lead-in areas. Not used for tape media. |
| overflow_sectors | Number of overflow sectors (typically lead-out area for optical media). Set to 0 for media types without lead-out areas. Not used for tape media. |
| options | String with creation options in key=value format, semicolon-separated. Supported options:
|
| application_name | Pointer to the application name string (UTF-8 encoded). This identifies the software that created the image. The string will be copied directly to the image header. |
| application_name_length | Length of the application name string in bytes. Must be ≤ AARU_HEADER_APP_NAME_LEN (64 bytes). |
| application_major_version | Major version of the creating application (0-255). |
| application_minor_version | Minor version of the creating application (0-255). |
| is_tape | Boolean flag indicating tape media type:
|
| aaruformatContext* | Successfully created and initialized context. The returned pointer contains:
|
| NULL | Creation failed. The specific error can be determined by checking errno, which will be set to:
|
< Size in bytes (UTF-16LE) of application name field (32 UTF-16 code units).
Definition at line 279 of file create.c.
References AARU_HEADER_APP_NAME_LEN, AARU_MAGIC, aaruf_ecc_cd_init(), AARUF_ERROR_CANNOT_CREATE_FILE, AARUF_ERROR_INVALID_APP_NAME_LENGTH, AARUF_ERROR_NOT_ENOUGH_MEMORY, aaruf_get_xml_mediatype(), aaruf_md5_init(), aaruf_sha1_init(), aaruf_sha256_init(), aaruf_spamsum_init(), AARUF_VERSION_V2, ImageInfo::Application, AaruHeaderV2::application, AaruHeaderV2::applicationMajorVersion, AaruHeaderV2::applicationMinorVersion, ImageInfo::ApplicationVersion, aaru_options::blake3, aaruformat_context::blake3_context, aaru_options::block_alignment, aaruformat_context::block_cache, aaruformat_context::block_header_cache, DdtHeader2::blockAlignmentShift, DdtHeader2::blocks, CacheHeader::cache, aaruformat_context::calculating_blake3, aaruformat_context::calculating_md5, aaruformat_context::calculating_sha1, aaruformat_context::calculating_sha256, aaruformat_context::calculating_spamsum, cleanup_failed_create(), aaru_options::compress, DdtHeader2::compression, aaruformat_context::compression_enabled, create_map(), ImageInfo::CreationTime, AaruHeaderV2::creationTime, aaru_options::data_shift, DdtHeader2::dataShift, aaru_options::deduplicate, aaruformat_context::deduplicate, DeDuplicationTable2, aaru_options::dictionary, aaruformat_context::ecc_cd_context, DdtHeader2::entries, FATAL, get_filetime_uint64(), aaruformat_context::header, AaruHeaderV2::identifier, DdtHeader2::identifier, aaruformat_context::image_info, AaruHeaderV2::imageMajorVersion, AaruHeaderV2::imageMinorVersion, ImageInfo::ImageSize, aaruformat_context::imageStream, aaruformat_context::in_memory_ddt, aaruformat_context::index_entries, AaruHeaderV2::indexOffset, aaruformat_context::is_tape, aaruformat_context::is_writing, aaruformat_context::last_written_block, ImageInfo::LastModificationTime, AaruHeaderV2::lastWrittenTime, DdtHeader2::levels, LIBAARUFORMAT_MAJOR_VERSION, LIBAARUFORMAT_MINOR_VERSION, aaruformat_context::library_major_version, aaruformat_context::library_minor_version, aaruformat_context::lzma_dict_size, aaruformat_context::magic, MAX_CACHE_SIZE, CacheHeader::max_items, MaxSectorTag, aaru_options::md5, aaruformat_context::md5_context, ImageInfo::MediaType, AaruHeaderV2::mediaType, ImageInfo::MetadataMediaType, DdtHeader2::negative, aaruformat_context::next_block_position, None, DdtHeader2::overflow, parse_options(), DdtHeader2::previousLevelOffset, aaruformat_context::primary_ddt_offset, aaruformat_context::readableSectorTags, aaruformat_context::rewinded, aaruformat_context::sector_hash_map, ImageInfo::Sectors, ImageInfo::SectorSize, aaru_options::sha1, aaruformat_context::sha1_context, aaru_options::sha256, aaruformat_context::sha256_context, aaruformat_context::shift, aaru_options::spamsum, aaruformat_context::spamsum_context, DdtHeader2::start, aaru_options::table_shift, DdtHeader2::tableLevel, DdtHeader2::tableShift, aaruformat_context::tape_ddt, TRACE, DdtHeader2::type, aaruformat_context::user_data_ddt2, aaruformat_context::user_data_ddt_header, UserData, and ImageInfo::Version.
| int32_t aaruf_cst_transform | ( | const uint8_t * | interleaved, |
| uint8_t * | sequential, | ||
| const size_t | length ) |
Transforms interleaved subchannel data to sequential format.
Converts interleaved subchannel data into a sequential format for further processing.
| interleaved | Pointer to the interleaved data buffer. |
| sequential | Pointer to the output sequential data buffer. |
| length | Length of the data buffer. |
Definition at line 35 of file cst.c.
References AARUF_ERROR_BUFFER_TOO_SMALL, AARUF_ERROR_NOT_ENOUGH_MEMORY, and AARUF_STATUS_OK.
Referenced by write_sector_subchannel().
| int32_t aaruf_cst_untransform | ( | const uint8_t * | sequential, |
| uint8_t * | interleaved, | ||
| const size_t | length ) |
Reverses the CST (Claunia's Subchannel Transform) transformation from sequential to interleaved data.
| sequential | Pointer to the sequential data buffer. |
| interleaved | Pointer to the output buffer for interleaved data. |
| length | Length of the data in bytes. |
Definition at line 193 of file cst.c.
References AARUF_ERROR_BUFFER_TOO_SMALL, AARUF_ERROR_NOT_ENOUGH_MEMORY, and AARUF_STATUS_OK.
Referenced by process_data_block().
| bool aaruf_ecc_cd_check | ( | void * | context, |
| const uint8_t * | address, | ||
| const uint8_t * | data, | ||
| const uint32_t | major_count, | ||
| const uint32_t | minor_count, | ||
| const uint32_t | major_mult, | ||
| const uint32_t | minor_inc, | ||
| const uint8_t * | ecc, | ||
| const int32_t | address_offset, | ||
| const int32_t | data_offset, | ||
| const int32_t | ecc_offset ) |
Checks the ECC of a CD sector.
| context | Pointer to the ECC context. |
| address | Pointer to the address field. |
| data | Pointer to the data field. |
| major_count | Number of major iterations. |
| minor_count | Number of minor iterations. |
| major_mult | Major multiplier. |
| minor_inc | Minor increment. |
| ecc | Pointer to the ECC field. |
| address_offset | Offset for the address field. |
| data_offset | Offset for the data field. |
| ecc_offset | Offset for the ECC field. |
Definition at line 227 of file ecc_cd.c.
References CdEccContext::ecc_b_table, CdEccContext::ecc_f_table, CdEccContext::inited_edc, and TRACE.
Referenced by aaruf_ecc_cd_is_suffix_correct(), and aaruf_ecc_cd_is_suffix_correct_mode2().
| void * aaruf_ecc_cd_init | ( | ) |
Initializes a Compact Disc ECC context.
Allocates and initializes a context for Compact Disc ECC calculations.
Definition at line 35 of file ecc_cd.c.
References CdEccContext::ecc_b_table, CdEccContext::ecc_f_table, CdEccContext::edc_table, CdEccContext::inited_edc, and TRACE.
Referenced by aaruf_create(), and aaruf_open().
| bool aaruf_ecc_cd_is_suffix_correct | ( | void * | context, |
| const uint8_t * | sector ) |
Checks if the suffix (EDC/ECC) of a CD sector is correct (Mode 1).
| context | Pointer to the ECC context. |
| sector | Pointer to the sector data. |
Definition at line 101 of file ecc_cd.c.
References aaruf_ecc_cd_check(), aaruf_edc_cd_compute(), CdEccContext::inited_edc, and TRACE.
Referenced by aaruf_write_sector_long().
| bool aaruf_ecc_cd_is_suffix_correct_mode2 | ( | void * | context, |
| const uint8_t * | sector ) |
Checks if the suffix (EDC/ECC) of a CD sector is correct (Mode 2).
| context | Pointer to the ECC context. |
| sector | Pointer to the sector data. |
Definition at line 165 of file ecc_cd.c.
References aaruf_ecc_cd_check(), aaruf_edc_cd_compute(), CdEccContext::inited_edc, and TRACE.
Referenced by aaruf_write_sector_long().
| void aaruf_ecc_cd_reconstruct | ( | void * | context, |
| uint8_t * | sector, | ||
| const uint8_t | type ) |
Reconstructs the EDC and ECC fields of a CD sector.
| context | Pointer to the ECC context. |
| sector | Pointer to the sector data (must be 2352 bytes). |
| type | Track type (mode). |
Definition at line 455 of file ecc_cd.c.
References aaruf_ecc_cd_write_sector(), aaruf_edc_cd_compute(), CdMode1, CdMode2Form1, CdMode2Form2, CdEccContext::inited_edc, and TRACE.
Referenced by aaruf_read_sector_long().
| void aaruf_ecc_cd_reconstruct_prefix | ( | uint8_t * | sector, |
| const uint8_t | type, | ||
| const int64_t | lba ) |
Reconstructs the prefix (sync, address, mode) of a CD sector.
| sector | Pointer to the sector data (must be 2352 bytes). |
| type | Track type (mode). |
| lba | Logical Block Address. |
Definition at line 388 of file ecc_cd.c.
References aaruf_cd_lba_to_msf(), CdMode1, CdMode2Form1, CdMode2Form2, CdMode2Formless, and TRACE.
Referenced by aaruf_read_sector_long().
| void aaruf_ecc_cd_write | ( | void * | context, |
| const uint8_t * | address, | ||
| const uint8_t * | data, | ||
| const uint32_t | major_count, | ||
| const uint32_t | minor_count, | ||
| const uint32_t | major_mult, | ||
| const uint32_t | minor_inc, | ||
| uint8_t * | ecc, | ||
| const int32_t | address_offset, | ||
| const int32_t | data_offset, | ||
| const int32_t | ecc_offset ) |
Writes ECC for a CD sector.
| context | Pointer to the ECC context. |
| address | Pointer to the address field. |
| data | Pointer to the data field. |
| major_count | Number of major iterations. |
| minor_count | Number of minor iterations. |
| major_mult | Major multiplier. |
| minor_inc | Minor increment. |
| ecc | Pointer to the ECC field to write. |
| address_offset | Offset for the address field. |
| data_offset | Offset for the data field. |
| ecc_offset | Offset for the ECC field. |
Definition at line 292 of file ecc_cd.c.
References CdEccContext::ecc_b_table, CdEccContext::ecc_f_table, CdEccContext::inited_edc, and TRACE.
Referenced by aaruf_ecc_cd_write_sector().
| void aaruf_ecc_cd_write_sector | ( | void * | context, |
| const uint8_t * | address, | ||
| const uint8_t * | data, | ||
| uint8_t * | ecc, | ||
| const int32_t | address_offset, | ||
| const int32_t | data_offset, | ||
| const int32_t | ecc_offset ) |
Writes ECC for a full CD sector (both P and Q ECC).
| context | Pointer to the ECC context. |
| address | Pointer to the address field. |
| data | Pointer to the data field. |
| ecc | Pointer to the ECC field to write. |
| address_offset | Offset for the address field. |
| data_offset | Offset for the data field. |
| ecc_offset | Offset for the ECC field. |
Definition at line 349 of file ecc_cd.c.
References aaruf_ecc_cd_write(), and TRACE.
Referenced by aaruf_ecc_cd_reconstruct().
| uint32_t aaruf_edc_cd_compute | ( | void * | context, |
| uint32_t | edc, | ||
| const uint8_t * | src, | ||
| int | size, | ||
| int | pos ) |
Computes the EDC (Error Detection Code) for a CD sector.
| context | Pointer to the ECC context. |
| edc | Initial EDC value. |
| src | Pointer to the data to compute EDC over. |
| size | Number of bytes to process. |
| pos | Starting position in the data. |
Definition at line 543 of file ecc_cd.c.
References CdEccContext::edc_table, CdEccContext::inited_edc, and TRACE.
Referenced by aaruf_ecc_cd_is_suffix_correct(), aaruf_ecc_cd_is_suffix_correct_mode2(), aaruf_ecc_cd_reconstruct(), and aaruf_write_sector_long().
| size_t aaruf_flac_decode_redbook_buffer | ( | uint8_t * | dst_buffer, |
| size_t | dst_size, | ||
| const uint8_t * | src_buffer, | ||
| size_t | src_size ) |
Decodes a FLAC-compressed Red Book audio buffer.
Decompresses FLAC-compressed Red Book audio data into the destination buffer.
| dst_buffer | Pointer to the destination buffer. |
| dst_size | Size of the destination buffer. |
| src_buffer | Pointer to the source (compressed) buffer. |
| src_size | Size of the source buffer. |
Definition at line 48 of file flac.c.
References AARU_CALL, AARU_EXPORT, aaru_flac_ctx::dst_buffer, aaru_flac_ctx::dst_len, aaru_flac_ctx::dst_pos, aaru_flac_ctx::error, error_callback(), read_callback(), aaru_flac_ctx::src_buffer, aaru_flac_ctx::src_len, aaru_flac_ctx::src_pos, and write_callback().
Referenced by aaruf_read_sector().
| size_t aaruf_flac_encode_redbook_buffer | ( | uint8_t * | dst_buffer, |
| size_t | dst_size, | ||
| const uint8_t * | src_buffer, | ||
| size_t | src_size, | ||
| uint32_t | blocksize, | ||
| int32_t | do_mid_side_stereo, | ||
| int32_t | loose_mid_side_stereo, | ||
| const char * | apodization, | ||
| uint32_t | max_lpc_order, | ||
| uint32_t | qlp_coeff_precision, | ||
| int32_t | do_qlp_coeff_prec_search, | ||
| int32_t | do_exhaustive_model_search, | ||
| uint32_t | min_residual_partition_order, | ||
| uint32_t | max_residual_partition_order, | ||
| const char * | application_id, | ||
| uint32_t | application_id_len ) |
Encodes a Red Book audio buffer to FLAC format.
| dst_buffer | Pointer to the destination buffer for FLAC data. |
| dst_size | Size of the destination buffer in bytes. |
| src_buffer | Pointer to the source Red Book audio buffer. |
| src_size | Size of the source buffer in bytes. |
| blocksize | FLAC block size. |
| do_mid_side_stereo | Enable mid-side stereo encoding. |
| loose_mid_side_stereo | Enable loose mid-side stereo encoding. |
| apodization | Apodization string for FLAC encoder. |
| max_lpc_order | Maximum LPC order. |
| qlp_coeff_precision | QLP coefficient precision. |
| do_qlp_coeff_prec_search | Enable QLP coefficient precision search. |
| do_exhaustive_model_search | Enable exhaustive model search. |
| min_residual_partition_order | Minimum residual partition order. |
| max_residual_partition_order | Maximum residual partition order. |
| application_id | Application ID string for FLAC encoder. |
| application_id_len | Length of the application ID string. |
Definition at line 175 of file flac.c.
References AARU_CALL, AARU_EXPORT, aaru_flac_ctx::dst_buffer, aaru_flac_ctx::dst_len, aaru_flac_ctx::dst_pos, encoder_write_callback(), aaru_flac_ctx::error, aaru_flac_ctx::src_buffer, aaru_flac_ctx::src_len, and aaru_flac_ctx::src_pos.
Referenced by aaruf_close_current_block().
| int32_t aaruf_get_aaru_json_metadata | ( | const void * | context, |
| uint8_t * | buffer, | ||
| size_t * | length ) |
Retrieves the embedded Aaru metadata JSON from the image.
Aaru metadata JSON is a structured metadata format that provides machine-readable, comprehensive information about the image, media, imaging session details, hardware configuration, optical disc tracks and sessions, checksums, and preservation metadata. This function extracts the raw JSON payload that was embedded in the AaruFormat image during creation. The JSON data is preserved in its original form without parsing or interpretation by the library, allowing callers to process the structured metadata using standard JSON parsing libraries.
This function supports a two-call pattern for buffer size determination:
Alternatively, if the caller already knows the buffer is large enough, a single call will succeed and populate the buffer with the Aaru JSON data.
| context | Pointer to the aaruformat context (must be a valid, opened image context). |
| buffer | Pointer to a buffer that will receive the Aaru metadata JSON. Must be large enough to hold the entire JSON payload (at least *length bytes on input). The buffer will contain raw UTF-8 encoded JSON data on success. |
| length | Pointer to a size_t that serves dual purpose:
|
| AARUF_STATUS_OK | (0) Successfully retrieved Aaru metadata JSON. This is returned when:
|
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context is invalid. This occurs when:
|
| AARUF_ERROR_CANNOT_READ_BLOCK | (-6) The Aaru JSON block is not present. This occurs when:
|
| AARUF_ERROR_BUFFER_TOO_SMALL | (-10) The provided buffer is insufficient. This occurs when:
|
Definition at line 2099 of file metadata.c.
References AARU_MAGIC, AARUF_ERROR_BUFFER_TOO_SMALL, AARUF_ERROR_CANNOT_READ_BLOCK, AARUF_ERROR_NOT_AARUFORMAT, AARUF_STATUS_OK, AaruMetadataJsonBlock, FATAL, AaruMetadataJsonBlockHeader::identifier, aaruformat_context::json_block, aaruformat_context::json_block_header, AaruMetadataJsonBlockHeader::length, aaruformat_context::magic, and TRACE.
| int32_t aaruf_get_cicm_metadata | ( | const void * | context, |
| uint8_t * | buffer, | ||
| size_t * | length ) |
Retrieves the embedded CICM XML metadata sidecar from the image.
CICM (Canary Islands Computer Museum) XML is a standardized metadata format used for documenting preservation and archival information about media and disk images. This function extracts the raw CICM XML payload that was embedded in the AaruFormat image during creation. The XML data is preserved in its original form without parsing, interpretation, or validation by the library. The metadata typically includes detailed information about the physical media, imaging process, checksums, device information, and preservation metadata following the CICM schema.
This function supports a two-call pattern for buffer size determination:
Alternatively, if the caller already knows the buffer is large enough, a single call will succeed and populate the buffer with the CICM XML data.
| context | Pointer to the aaruformat context (must be a valid, opened image context). |
| buffer | Pointer to a buffer that will receive the CICM XML metadata. Must be large enough to hold the entire XML payload (at least *length bytes on input). The buffer will contain raw UTF-8 encoded XML data on success. |
| length | Pointer to a size_t that serves dual purpose:
|
| AARUF_STATUS_OK | (0) Successfully retrieved CICM XML metadata. This is returned when:
|
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context is invalid. This occurs when:
|
| AARUF_ERROR_CANNOT_READ_BLOCK | (-6) The CICM block is not present. This occurs when:
|
| AARUF_ERROR_BUFFER_TOO_SMALL | (-10) The provided buffer is insufficient. This occurs when:
|
Definition at line 1944 of file metadata.c.
References AARU_MAGIC, AARUF_ERROR_BUFFER_TOO_SMALL, AARUF_ERROR_CANNOT_READ_BLOCK, AARUF_ERROR_NOT_AARUFORMAT, AARUF_STATUS_OK, aaruformat_context::cicm_block, aaruformat_context::cicm_block_header, CicmBlock, FATAL, CicmMetadataBlock::identifier, CicmMetadataBlock::length, aaruformat_context::magic, and TRACE.
| int32_t aaruf_get_comments | ( | const void * | context, |
| uint8_t * | buffer, | ||
| int32_t * | length ) |
Retrieves the user comments or notes stored in the MetadataBlock.
Provides access to the UTF-16LE encoded comments associated with the image. Comments are often used for provenance notes, imaging details, or curator remarks. The function follows the same two-call buffer sizing pattern used by other metadata retrieval APIs: the caller may probe the required size before allocating memory.
| context | Pointer to a valid aaruformat context opened with aaruf_open() or aaruf_create(). |
| buffer | Destination buffer that receives the comments data. May be NULL when probing size. |
| length | Pointer to an int32_t. On input it contains the size of buffer in bytes; on output it is updated with the actual comments length. |
| AARUF_STATUS_OK | (0) Comments were available and copied successfully. |
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context pointer is invalid or not a libaaruformat context. |
| AARUF_ERROR_METADATA_NOT_PRESENT | (-30) No comments metadata exists in the image. |
| AARUF_ERROR_BUFFER_TOO_SMALL | (-10) The supplied buffer was too small. *length is updated with the required size and no data is copied. |
Definition at line 2476 of file metadata.c.
References AARU_MAGIC, AARUF_ERROR_BUFFER_TOO_SMALL, AARUF_ERROR_METADATA_NOT_PRESENT, AARUF_ERROR_NOT_AARUFORMAT, AARUF_STATUS_OK, aaruformat_context::comments, MetadataBlockHeader::commentsLength, FATAL, MetadataBlockHeader::identifier, aaruformat_context::magic, aaruformat_context::metadata_block_header, MetadataBlock, and TRACE.
| int32_t aaruf_get_creator | ( | const void * | context, |
| uint8_t * | buffer, | ||
| int32_t * | length ) |
Retrieves the recorded creator (operator) name from the MetadataBlock.
Copies the UTF-16LE encoded creator string that identifies the person or operator who created the image. The function supports the common two-call pattern: the caller first determines the required buffer size by passing a buffer that may be NULL or too small, then allocates sufficient memory and calls again to obtain the actual data. On success the buffer contains an opaque UTF-16LE string of length *length bytes (not null-terminated).
| context | Pointer to a valid aaruformat context opened for reading or writing. |
| buffer | Pointer to the destination buffer that will receive the creator string. May be NULL to query the required size. |
| length | Pointer to an int32_t that on input specifies the size of buffer in bytes and on output receives the actual length of the creator metadata. |
| AARUF_STATUS_OK | (0) The creator string was copied successfully. |
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context is NULL or not an aaruformat context. |
| AARUF_ERROR_METADATA_NOT_PRESENT | (-30) Creator metadata has not been recorded in the image. |
| AARUF_ERROR_BUFFER_TOO_SMALL | (-10) The provided buffer was insufficient; *length contains the required size and no data was copied. |
buffer is large enough before requesting the data. Definition at line 2404 of file metadata.c.
References AARU_MAGIC, AARUF_ERROR_BUFFER_TOO_SMALL, AARUF_ERROR_METADATA_NOT_PRESENT, AARUF_ERROR_NOT_AARUFORMAT, AARUF_STATUS_OK, aaruformat_context::creator, MetadataBlockHeader::creatorLength, FATAL, MetadataBlockHeader::identifier, aaruformat_context::magic, aaruformat_context::metadata_block_header, MetadataBlock, and TRACE.
| int32_t aaruf_get_datatype_for_media_tag_type | ( | const int32_t | tag_type | ) |
Converts an Aaru media tag type to an image data type.
Maps the given Aaru media tag type to the corresponding image data type. This is the inverse function of aaruf_get_media_tag_type_for_datatype.
| tag_type | Aaru media tag type identifier. |
Definition at line 189 of file helpers.c.
References AACS_CPRM_MKB, AACS_DataKeys, AACS_LBAExtents, AACS_MediaIdentifier, AACS_MKB, AACS_SerialNumber, AACS_VolumeIdentifier, AacsDataKeys, AacsLbaExtents, AacsMediaIdentifier, AacsMediaKeyBlock, AacsSerialNumber, AacsVolumeIdentifier, ATA_IDENTIFY, AtaIdentify, ATAPI_IDENTIFY, AtapiIdentify, BD_BCA, BD_CartridgeStatus, BD_DDS, BD_DI, BD_SpareArea, BlurayBca, BlurayCartridgeStatus, BlurayDds, BlurayDi, BluraySpareArea, CD_ATIP, CD_FirstTrackPregap, CD_FullTOC, CD_LeadIn, CD_LeadOut, CD_MCN, CD_PMA, CD_SessionInfo, CD_TEXT, CD_TOC, CompactDiscAtip, CompactDiscFirstTrackPregap, CompactDiscLeadIn, CompactDiscLeadInCdText, CompactDiscLeadOut, CompactDiscMediaCatalogueNumber, CompactDiscPartialToc, CompactDiscPma, CompactDiscSessionInfo, CompactDiscToc, CprmMediaKeyBlock, DCB, DVD_ADIP, DVD_BCA, DVD_CMI, DVD_DiscKey, DVD_DiscKey_Decrypted, DVD_DMI, DVD_MediaIdentifier, DVD_MKB, DVD_PFI, DvdAdip, DvdBca, DvdDiscControlBlock, DvdDiscKey, DvdDiscKeyDecrypted, DVDDL_JumpIntervalSize, DVDDL_LayerCapacity, DVDDL_ManualLayerJumpLBA, DVDDL_MiddleZoneAddress, DvdDlJumpIntervalSize, DvdDlLayerCapacity, DvdDlManualLayerJumpLba, DvdDlMiddleZoneAddress, DvdDmi, DvdLeadInCmi, DvdMediaIdentifier, DvdMediaKeyBlock, DvdPfi, DVDR_MediaIdentifier, DVDR_PFI, DVDR_PreRecordedInfo, DVDR_RMD, DVDRAM_DDS, DVDRAM_MediumStatus, DVDRAM_SpareArea, DvdRamDds, DvdRamMediumStatus, DvdRamSpareArea, DvdRMediaIdentifier, DvdRPfi, DvdRPrerecordedInfo, DvdRRmd, Floppy_LeadOut, FloppyLeadOut, HDDVD_CPI, HDDVD_MediumStatus, HdDvdCpi, HdDvdMediumStatus, Hybrid_RecognizedLayers, HybridRecognizedLayers, MMC_CID, MMC_CSD, MMC_DiscInformation, MMC_ExtendedCSD, MMC_OCR, MMC_POWResourcesInformation, MMC_TrackResourcesInformation, MMC_WriteProtection, MultiMediaCardCid, MultiMediaCardCsd, MultiMediaCardExtendedCsd, MultiMediaCardOcr, PCMCIA_CIS, PcmciaCis, SCSI_INQUIRY, SCSI_MODEPAGE_2A, SCSI_MODESENSE_10, SCSI_MODESENSE_6, ScsiInquiry, ScsiMmcDiscInformation, ScsiMmcPowResourcesInformation, ScsiMmcTrackResourcesInformation, ScsiMmcWriteProtection, ScsiModePage2A, ScsiModeSense10, ScsiModeSense6, SD_CID, SD_CSD, SD_OCR, SD_SCR, SecureDigitalCid, SecureDigitalCsd, SecureDigitalOcr, SecureDigitalScr, USB_Descriptors, UsbDescriptors, Xbox_DMI, Xbox_PFI, Xbox_SecuritySector, XboxDmi, XboxPfi, and XboxSecuritySector.
Referenced by write_media_tags().
| int32_t aaruf_get_drive_firmware_revision | ( | const void * | context, |
| uint8_t * | buffer, | ||
| int32_t * | length ) |
Retrieves the firmware revision metadata for the imaging drive.
Returns the UTF-16LE encoded firmware revision string that was captured when the image was created. Firmware information is critical for reproducing imaging environments and diagnosing drive-specific behavior or bugs.
| context | Pointer to a valid aaruformat context. |
| buffer | Destination buffer for the firmware revision string. May be NULL when probing size. |
| length | Pointer to an int32_t that specifies the buffer capacity in bytes on input and is updated with the actual metadata length on output. |
| AARUF_STATUS_OK | (0) Firmware revision metadata was present and copied successfully. |
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context pointer is invalid. |
| AARUF_ERROR_METADATA_NOT_PRESENT | (-30) No firmware metadata exists in the image. |
| AARUF_ERROR_BUFFER_TOO_SMALL | (-10) The supplied buffer was too small; *length is updated. |
Definition at line 3178 of file metadata.c.
References AARU_MAGIC, AARUF_ERROR_BUFFER_TOO_SMALL, AARUF_ERROR_METADATA_NOT_PRESENT, AARUF_ERROR_NOT_AARUFORMAT, AARUF_STATUS_OK, aaruformat_context::drive_firmware_revision, MetadataBlockHeader::driveFirmwareRevisionLength, FATAL, MetadataBlockHeader::identifier, aaruformat_context::magic, aaruformat_context::metadata_block_header, MetadataBlock, and TRACE.
| int32_t aaruf_get_drive_manufacturer | ( | const void * | context, |
| uint8_t * | buffer, | ||
| int32_t * | length ) |
Retrieves the drive manufacturer metadata captured during imaging.
Copies the UTF-16LE encoded manufacturer name of the device used to read or write the medium. This information documents the hardware involved in the imaging process, which is crucial for forensic reporting and reproducibility studies.
| context | Pointer to a valid aaruformat context. |
| buffer | Destination buffer for the manufacturer string. May be NULL when querying required length. |
| length | Pointer to an int32_t specifying the buffer size on input and receiving the actual metadata length on output. |
| AARUF_STATUS_OK | (0) Drive manufacturer metadata was copied successfully. |
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context pointer is invalid. |
| AARUF_ERROR_METADATA_NOT_PRESENT | (-30) The image lacks drive manufacturer metadata. |
| AARUF_ERROR_BUFFER_TOO_SMALL | (-10) The provided buffer is too small; *length holds the required size for a subsequent call. |
Definition at line 2968 of file metadata.c.
References AARU_MAGIC, AARUF_ERROR_BUFFER_TOO_SMALL, AARUF_ERROR_METADATA_NOT_PRESENT, AARUF_ERROR_NOT_AARUFORMAT, AARUF_STATUS_OK, aaruformat_context::drive_manufacturer, MetadataBlockHeader::driveManufacturerLength, FATAL, MetadataBlockHeader::identifier, aaruformat_context::magic, aaruformat_context::metadata_block_header, MetadataBlock, and TRACE.
| int32_t aaruf_get_drive_model | ( | const void * | context, |
| uint8_t * | buffer, | ||
| int32_t * | length ) |
Retrieves the device model information for the imaging drive.
Returns the UTF-16LE encoded model identifier for the drive used during acquisition. The model metadata provides finer granularity than the manufacturer name, enabling detailed documentation of imaging hardware capabilities and behavior.
| context | Pointer to a valid aaruformat context. |
| buffer | Buffer that receives the model string; may be NULL while probing required capacity. |
| length | Pointer to an int32_t indicating buffer size on input and receiving the metadata length on output. |
| AARUF_STATUS_OK | (0) Drive model metadata was available and copied. |
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context pointer is invalid. |
| AARUF_ERROR_METADATA_NOT_PRESENT | (-30) No drive model metadata exists in the image. |
| AARUF_ERROR_BUFFER_TOO_SMALL | (-10) The supplied buffer was insufficient; *length is updated. |
Definition at line 3038 of file metadata.c.
References AARU_MAGIC, AARUF_ERROR_BUFFER_TOO_SMALL, AARUF_ERROR_METADATA_NOT_PRESENT, AARUF_ERROR_NOT_AARUFORMAT, AARUF_STATUS_OK, aaruformat_context::drive_model, MetadataBlockHeader::driveModelLength, FATAL, MetadataBlockHeader::identifier, aaruformat_context::magic, aaruformat_context::metadata_block_header, MetadataBlock, and TRACE.
| int32_t aaruf_get_drive_serial_number | ( | const void * | context, |
| uint8_t * | buffer, | ||
| int32_t * | length ) |
Retrieves the imaging drive's serial number metadata.
Copies the UTF-16LE encoded serial number reported for the drive used during the imaging session. This metadata enables correlation between images and specific hardware units for forensic chain of custody or quality assurance workflows.
| context | Pointer to a valid aaruformat context. |
| buffer | Destination buffer for the serial number; may be NULL when querying size. |
| length | Pointer to an int32_t carrying the buffer size on input and receiving the actual serial number length on output. |
| AARUF_STATUS_OK | (0) Drive serial number metadata was copied to buffer. |
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context pointer is invalid. |
| AARUF_ERROR_METADATA_NOT_PRESENT | (-30) No drive serial number metadata is available. |
| AARUF_ERROR_BUFFER_TOO_SMALL | (-10) The provided buffer was insufficient. |
Definition at line 3108 of file metadata.c.
References AARU_MAGIC, AARUF_ERROR_BUFFER_TOO_SMALL, AARUF_ERROR_METADATA_NOT_PRESENT, AARUF_ERROR_NOT_AARUFORMAT, AARUF_STATUS_OK, aaruformat_context::drive_serial_number, MetadataBlockHeader::driveSerialNumberLength, FATAL, MetadataBlockHeader::identifier, aaruformat_context::magic, aaruformat_context::metadata_block_header, MetadataBlock, and TRACE.
| int32_t aaruf_get_dumphw | ( | void * | context, |
| uint8_t * | buffer, | ||
| size_t * | length ) |
Retrieves the dump hardware block containing acquisition environment information.
Extracts the complete DumpHardwareBlock from the image, which documents the hardware and software environments used to create the image. A dump hardware block records one or more "dump environments" – typically combinations of physical devices (drives, controllers, adapters) and the software stacks that performed the read operations. This metadata is essential for understanding the imaging context, validating acquisition integrity, reproducing imaging conditions, and supporting forensic or archival documentation requirements.
Each environment entry includes hardware identification (manufacturer, model, revision, firmware, serial number), software identification (name, version, operating system), and optional extent ranges that specify which logical sectors or units were contributed by that particular environment. This structure supports complex imaging scenarios where multiple devices or software configurations were used to create a composite image.
The function reconstructs the complete on-disk binary representation of the dump hardware block, including the DumpHardwareHeader followed by all entries with their variable-length UTF-8 strings and extent arrays. The reconstructed block includes a calculated CRC64 checksum over the payload data for integrity verification.
This function supports a two-call pattern for buffer size determination:
Alternatively, if the caller already knows the buffer is large enough, a single call will succeed and populate the buffer with the complete dump hardware block.
| context | Pointer to the aaruformat context (must be a valid, opened image context). |
| buffer | Pointer to a buffer that will receive the dump hardware block data. Must be large enough to hold the complete block (at least *length bytes on input). May be NULL to query the required buffer size. The buffer will contain the DumpHardwareHeader followed by serialized entries, strings, and extent arrays on success. |
| length | Pointer to a size_t that serves dual purpose:
|
| AARUF_STATUS_OK | (0) Successfully retrieved dump hardware block. This is returned when:
|
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context is invalid. This occurs when:
|
| AARUF_ERROR_CANNOT_READ_BLOCK | (-6) The dump hardware block is not present. This occurs when:
|
| AARUF_ERROR_BUFFER_TOO_SMALL | (-12) The provided buffer is insufficient. This occurs when:
|
Definition at line 186 of file dump.c.
References AARU_MAGIC, aaruf_crc64_data(), AARUF_ERROR_BUFFER_TOO_SMALL, AARUF_ERROR_CANNOT_READ_BLOCK, AARUF_ERROR_INCORRECT_DATA_SIZE, AARUF_ERROR_NOT_AARUFORMAT, AARUF_STATUS_OK, DumpHardwareHeader::crc64, aaruformat_context::dump_hardware_entries_with_data, aaruformat_context::dump_hardware_header, DumpHardwareBlock, DumpHardwareHeader::entries, DumpHardwareEntriesWithData::entry, DumpHardwareEntriesWithData::extents, DumpHardwareEntry::extents, FATAL, DumpHardwareEntriesWithData::firmware, DumpHardwareEntry::firmwareLength, DumpHardwareHeader::identifier, DumpHardwareHeader::length, aaruformat_context::magic, DumpHardwareEntriesWithData::manufacturer, DumpHardwareEntry::manufacturerLength, DumpHardwareEntriesWithData::model, DumpHardwareEntry::modelLength, DumpHardwareEntriesWithData::revision, DumpHardwareEntry::revisionLength, DumpHardwareEntriesWithData::serial, DumpHardwareEntry::serialLength, DumpHardwareEntriesWithData::softwareName, DumpHardwareEntry::softwareNameLength, DumpHardwareEntriesWithData::softwareOperatingSystem, DumpHardwareEntry::softwareOperatingSystemLength, DumpHardwareEntriesWithData::softwareVersion, DumpHardwareEntry::softwareVersionLength, and TRACE.
| int32_t aaruf_get_geometry | ( | const void * | context, |
| uint32_t * | cylinders, | ||
| uint32_t * | heads, | ||
| uint32_t * | sectors_per_track ) |
Retrieves the logical CHS geometry from the AaruFormat image.
Reads the Cylinder-Head-Sector (CHS) geometry information from the image's geometry block and returns the values through output parameters. The geometry block contains legacy-style logical addressing parameters that describe how the storage medium was originally organized in terms of cylinders, heads (tracks per cylinder), and sectors per track. This information is essential for software that requires CHS addressing or for accurately representing the original medium's logical structure.
| context | Pointer to the aaruformat context (must be a valid, opened image context). |
| cylinders | Pointer to store the number of cylinders. Updated on success. |
| heads | Pointer to store the number of heads (tracks per cylinder). Updated on success. |
| sectors_per_track | Pointer to store the number of sectors per track. Updated on success. |
| AARUF_STATUS_OK | (0) Successfully retrieved geometry information. This is returned when:
|
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context is invalid. This occurs when:
|
| AARUF_ERROR_CANNOT_READ_BLOCK | (-6) The geometry block is not present. This occurs when:
|
Definition at line 94 of file metadata.c.
References AARU_MAGIC, AARUF_ERROR_CANNOT_READ_BLOCK, AARUF_ERROR_NOT_AARUFORMAT, AARUF_STATUS_OK, GeometryBlockHeader::cylinders, FATAL, aaruformat_context::geometry_block, GeometryBlock, GeometryBlockHeader::heads, GeometryBlockHeader::identifier, aaruformat_context::magic, GeometryBlockHeader::sectorsPerTrack, and TRACE.
| int32_t aaruf_get_image_info | ( | const void * | context, |
| ImageInfo * | image_info ) |
Retrieves a deep copy of the ImageInfo structure from the AaruFormat image.
Returns a complete copy of the high-level image information summary containing metadata such as image size, sector count, sector size, version information, creation timestamps, and media type. This function performs a deep copy of all fields including string buffers, ensuring the caller receives a complete, independent copy of the image information.
| context | Pointer to the aaruformat context (must be a valid, opened image context). |
| image_info | Pointer to an ImageInfo structure to receive the copied data. Must be a valid pointer to allocated memory. |
| AARUF_STATUS_OK | (0) Successfully copied image info. The image_info parameter contains a complete copy of all fields including:
|
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context is invalid. This occurs when:
|
Definition at line 3634 of file metadata.c.
References AARU_MAGIC, AARUF_ERROR_INCORRECT_DATA_SIZE, AARUF_ERROR_NOT_AARUFORMAT, AARUF_STATUS_OK, FATAL, aaruformat_context::image_info, aaruformat_context::magic, and TRACE.
| int32_t aaruf_get_media_barcode | ( | const void * | context, |
| uint8_t * | buffer, | ||
| int32_t * | length ) |
Retrieves the barcode assigned to the physical media or its packaging.
Returns the UTF-16LE encoded barcode string that was captured when the image was created. Barcodes are commonly used in institutional workflows for inventory tracking and automated retrieval.
| context | Pointer to a valid aaruformat context. |
| buffer | Buffer that receives the barcode string; may be NULL when probing size requirements. |
| length | Pointer to an int32_t specifying the buffer size on input and receiving the actual barcode length on output. |
| AARUF_STATUS_OK | (0) Barcode metadata was present and copied successfully. |
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context pointer is invalid. |
| AARUF_ERROR_METADATA_NOT_PRESENT | (-30) No barcode metadata exists in the image. |
| AARUF_ERROR_BUFFER_TOO_SMALL | (-10) The supplied buffer was too small. |
Definition at line 2825 of file metadata.c.
References AARU_MAGIC, AARUF_ERROR_BUFFER_TOO_SMALL, AARUF_ERROR_METADATA_NOT_PRESENT, AARUF_ERROR_NOT_AARUFORMAT, AARUF_STATUS_OK, FATAL, MetadataBlockHeader::identifier, aaruformat_context::magic, aaruformat_context::media_barcode, MetadataBlockHeader::mediaBarcodeLength, aaruformat_context::metadata_block_header, MetadataBlock, and TRACE.
| int32_t aaruf_get_media_manufacturer | ( | const void * | context, |
| uint8_t * | buffer, | ||
| int32_t * | length ) |
Retrieves the recorded media manufacturer name.
Provides access to the UTF-16LE encoded manufacturer metadata that identifies the company which produced the physical medium. This information is taken from the MetadataBlock and mirrors the value previously stored via aaruf_set_media_manufacturer().
| context | Pointer to a valid aaruformat context. |
| buffer | Buffer that receives the manufacturer string. May be NULL when probing size. |
| length | Pointer to an int32_t specifying the buffer size on input and receiving the actual manufacturer string length on output. |
| AARUF_STATUS_OK | (0) Manufacturer metadata was available and copied. |
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context pointer is invalid. |
| AARUF_ERROR_METADATA_NOT_PRESENT | (-30) The image lacks manufacturer metadata. |
| AARUF_ERROR_BUFFER_TOO_SMALL | (-10) The provided buffer was too small; *length indicates size. |
Definition at line 2616 of file metadata.c.
References AARU_MAGIC, AARUF_ERROR_BUFFER_TOO_SMALL, AARUF_ERROR_METADATA_NOT_PRESENT, AARUF_ERROR_NOT_AARUFORMAT, AARUF_STATUS_OK, FATAL, MetadataBlockHeader::identifier, aaruformat_context::magic, aaruformat_context::media_manufacturer, MetadataBlockHeader::mediaManufacturerLength, aaruformat_context::metadata_block_header, MetadataBlock, and TRACE.
| int32_t aaruf_get_media_model | ( | const void * | context, |
| uint8_t * | buffer, | ||
| int32_t * | length ) |
Retrieves the media model or product designation metadata.
Returns the UTF-16LE encoded model name that specifies the exact product variant of the physical medium. The function mirrors the set counterpart and is useful for accurately documenting media specifications during preservation workflows.
| context | Pointer to a valid aaruformat context. |
| buffer | Destination buffer for the model string; may be NULL when querying required size. |
| length | Pointer to an int32_t that on input contains the buffer capacity in bytes and on output is updated with the actual metadata length. |
| AARUF_STATUS_OK | (0) Model metadata was successfully copied. |
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context pointer is invalid. |
| AARUF_ERROR_METADATA_NOT_PRESENT | (-30) No media model metadata is present in the image. |
| AARUF_ERROR_BUFFER_TOO_SMALL | (-10) The caller-provided buffer is too small. |
Definition at line 2686 of file metadata.c.
References AARU_MAGIC, AARUF_ERROR_BUFFER_TOO_SMALL, AARUF_ERROR_METADATA_NOT_PRESENT, AARUF_ERROR_NOT_AARUFORMAT, AARUF_STATUS_OK, FATAL, MetadataBlockHeader::identifier, aaruformat_context::magic, aaruformat_context::media_model, MetadataBlockHeader::mediaModelLength, aaruformat_context::metadata_block_header, MetadataBlock, and TRACE.
| int32_t aaruf_get_media_part_number | ( | const void * | context, |
| uint8_t * | buffer, | ||
| int32_t * | length ) |
Retrieves the media part number recorded in the MetadataBlock.
Provides access to the UTF-16LE encoded part number identifying the precise catalog or ordering code for the physical medium. Part numbers help archivists procure exact replacements and document specific media variants used during acquisition.
| context | Pointer to a valid aaruformat context. |
| buffer | Destination buffer for the part number string. May be NULL while querying size. |
| length | Pointer to an int32_t that supplies the buffer size on input and is updated with the actual part number length on output. |
| AARUF_STATUS_OK | (0) Part number metadata was returned successfully. |
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context pointer is invalid. |
| AARUF_ERROR_METADATA_NOT_PRESENT | (-30) No part number metadata exists. |
| AARUF_ERROR_BUFFER_TOO_SMALL | (-10) The provided buffer was insufficient; *length contains the required size. |
Definition at line 2896 of file metadata.c.
References AARU_MAGIC, AARUF_ERROR_BUFFER_TOO_SMALL, AARUF_ERROR_METADATA_NOT_PRESENT, AARUF_ERROR_NOT_AARUFORMAT, AARUF_STATUS_OK, FATAL, MetadataBlockHeader::identifier, aaruformat_context::magic, aaruformat_context::media_part_number, MetadataBlockHeader::mediaPartNumberLength, aaruformat_context::metadata_block_header, MetadataBlock, and TRACE.
| int32_t aaruf_get_media_sequence | ( | const void * | context, |
| int32_t * | sequence, | ||
| int32_t * | last_sequence ) |
Retrieves the media sequence metadata for multi-volume image sets.
Reads the media sequence fields stored in the MetadataBlock header and returns the current media number together with the final media number for the complete set. This information indicates the position of the imaged medium within a multi-volume collection (for example, "disc 2 of 5"). The function operates entirely on in-memory structures populated during aaruf_open(); no additional disk I/O is performed.
| context | Pointer to an initialized aaruformat context opened for reading or writing. |
| sequence | Pointer that receives the current media sequence number (typically 1-based). |
| last_sequence | Pointer that receives the total number of media in the set. |
| AARUF_STATUS_OK | (0) Metadata was present and the output parameters were populated. |
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The provided context pointer is NULL or not an aaruformat context (magic mismatch). |
| AARUF_ERROR_METADATA_NOT_PRESENT | (-30) The MetadataBlock was not present in the image, making sequence data unavailable. |
Definition at line 2337 of file metadata.c.
References AARU_MAGIC, AARUF_ERROR_METADATA_NOT_PRESENT, AARUF_ERROR_NOT_AARUFORMAT, AARUF_STATUS_OK, FATAL, MetadataBlockHeader::identifier, MetadataBlockHeader::lastMediaSequence, aaruformat_context::magic, MetadataBlockHeader::mediaSequence, aaruformat_context::metadata_block_header, MetadataBlock, and TRACE.
| int32_t aaruf_get_media_serial_number | ( | const void * | context, |
| uint8_t * | buffer, | ||
| int32_t * | length ) |
Retrieves the media serial number recorded in the image metadata.
Copies the UTF-16LE encoded serial number identifying the specific physical medium. Serial numbers are particularly important for forensic tracking and archival provenance, enabling correlation between the physical item and its digital representation.
| context | Pointer to a valid aaruformat context. |
| buffer | Destination buffer for the serial number. May be NULL to determine required size. |
| length | Pointer to an int32_t that on input holds the buffer size and on output receives the actual serial number length. |
| AARUF_STATUS_OK | (0) Serial number metadata was copied into buffer. |
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context pointer is invalid. |
| AARUF_ERROR_METADATA_NOT_PRESENT | (-30) No serial number metadata was stored in the image. |
| AARUF_ERROR_BUFFER_TOO_SMALL | (-10) The provided buffer was too small. |
Definition at line 2756 of file metadata.c.
References AARU_MAGIC, AARUF_ERROR_BUFFER_TOO_SMALL, AARUF_ERROR_METADATA_NOT_PRESENT, AARUF_ERROR_NOT_AARUFORMAT, AARUF_STATUS_OK, FATAL, MetadataBlockHeader::identifier, aaruformat_context::magic, aaruformat_context::media_serial_number, MetadataBlockHeader::mediaSerialNumberLength, aaruformat_context::metadata_block_header, MetadataBlock, and TRACE.
| int32_t aaruf_get_media_tag_type_for_datatype | ( | const int32_t | type | ) |
Converts an image data type to an Aaru media tag type.
Maps the given image data type to the corresponding Aaru media tag type.
| type | Image data type identifier. |
Definition at line 31 of file helpers.c.
References AACS_CPRM_MKB, AACS_DataKeys, AACS_LBAExtents, AACS_MediaIdentifier, AACS_MKB, AACS_SerialNumber, AACS_VolumeIdentifier, AacsDataKeys, AacsLbaExtents, AacsMediaIdentifier, AacsMediaKeyBlock, AacsSerialNumber, AacsVolumeIdentifier, ATA_IDENTIFY, AtaIdentify, ATAPI_IDENTIFY, AtapiIdentify, BD_BCA, BD_CartridgeStatus, BD_DDS, BD_DI, BD_SpareArea, BlurayBca, BlurayCartridgeStatus, BlurayDds, BlurayDi, BluraySpareArea, CD_ATIP, CD_FirstTrackPregap, CD_FullTOC, CD_LeadIn, CD_LeadOut, CD_MCN, CD_PMA, CD_SessionInfo, CD_TEXT, CD_TOC, CompactDiscAtip, CompactDiscFirstTrackPregap, CompactDiscLeadIn, CompactDiscLeadInCdText, CompactDiscLeadOut, CompactDiscMediaCatalogueNumber, CompactDiscPartialToc, CompactDiscPma, CompactDiscSessionInfo, CompactDiscToc, CprmMediaKeyBlock, DCB, DVD_ADIP, DVD_BCA, DVD_CMI, DVD_DiscKey, DVD_DiscKey_Decrypted, DVD_DMI, DVD_MediaIdentifier, DVD_MKB, DVD_PFI, DvdAdip, DvdBca, DvdDiscControlBlock, DvdDiscKey, DvdDiscKeyDecrypted, DVDDL_JumpIntervalSize, DVDDL_LayerCapacity, DVDDL_ManualLayerJumpLBA, DVDDL_MiddleZoneAddress, DvdDlJumpIntervalSize, DvdDlLayerCapacity, DvdDlManualLayerJumpLba, DvdDlMiddleZoneAddress, DvdDmi, DvdLeadInCmi, DvdMediaIdentifier, DvdMediaKeyBlock, DvdPfi, DVDR_MediaIdentifier, DVDR_PFI, DVDR_PreRecordedInfo, DVDR_RMD, DVDRAM_DDS, DVDRAM_MediumStatus, DVDRAM_SpareArea, DvdRamDds, DvdRamMediumStatus, DvdRamSpareArea, DvdRMediaIdentifier, DvdRPfi, DvdRPrerecordedInfo, DvdRRmd, Floppy_LeadOut, FloppyLeadOut, HDDVD_CPI, HDDVD_MediumStatus, HdDvdCpi, HdDvdMediumStatus, Hybrid_RecognizedLayers, HybridRecognizedLayers, MMC_CID, MMC_CSD, MMC_DiscInformation, MMC_ExtendedCSD, MMC_OCR, MMC_POWResourcesInformation, MMC_TrackResourcesInformation, MMC_WriteProtection, MultiMediaCardCid, MultiMediaCardCsd, MultiMediaCardExtendedCsd, MultiMediaCardOcr, PCMCIA_CIS, PcmciaCis, SCSI_INQUIRY, SCSI_MODEPAGE_2A, SCSI_MODESENSE_10, SCSI_MODESENSE_6, ScsiInquiry, ScsiMmcDiscInformation, ScsiMmcPowResourcesInformation, ScsiMmcTrackResourcesInformation, ScsiMmcWriteProtection, ScsiModePage2A, ScsiModeSense10, ScsiModeSense6, SD_CID, SD_CSD, SD_OCR, SD_SCR, SecureDigitalCid, SecureDigitalCsd, SecureDigitalOcr, SecureDigitalScr, USB_Descriptors, UsbDescriptors, Xbox_DMI, Xbox_PFI, Xbox_SecuritySector, XboxDmi, XboxPfi, and XboxSecuritySector.
Referenced by process_data_block().
| int32_t aaruf_get_media_title | ( | const void * | context, |
| uint8_t * | buffer, | ||
| int32_t * | length ) |
Retrieves the media title or label captured during image creation.
Returns the UTF-16LE encoded media title string, representing markings or labels present on the original physical media. This function allows applications to present or archive the media title alongside the image, preserving contextual information from the physical artifact.
| context | Pointer to a valid aaruformat context. |
| buffer | Destination buffer for the UTF-16LE title string. May be NULL when querying size. |
| length | Pointer to an int32_t that on input holds the buffer capacity in bytes and on output receives the actual title length. |
| AARUF_STATUS_OK | (0) The media title was available and copied to buffer. |
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context pointer is invalid. |
| AARUF_ERROR_METADATA_NOT_PRESENT | (-30) No media title metadata exists. |
| AARUF_ERROR_BUFFER_TOO_SMALL | (-10) The supplied buffer was insufficient. |
Definition at line 2546 of file metadata.c.
References AARU_MAGIC, AARUF_ERROR_BUFFER_TOO_SMALL, AARUF_ERROR_METADATA_NOT_PRESENT, AARUF_ERROR_NOT_AARUFORMAT, AARUF_STATUS_OK, FATAL, MetadataBlockHeader::identifier, aaruformat_context::magic, aaruformat_context::media_title, MetadataBlockHeader::mediaTitleLength, aaruformat_context::metadata_block_header, MetadataBlock, and TRACE.
| int32_t aaruf_get_negative_sectors | ( | const void * | context, |
| uint16_t * | sectors ) |
Retrieves the number of negative (pre-gap) sectors in the AaruFormat image.
Returns the count of negative sectors that precede the standard user data area. Negative sectors are used to capture pre-gap data, lead-in areas, and other metadata that exists before the main user-accessible storage region. This is particularly important for optical media (CD, DVD, BD) where the lead-in contains the Table of Contents (TOC) and other essential disc structures, and for audio CDs where pre-gap sectors contain silence or hidden tracks. For most hard disk and floppy disk images, this value is typically zero.
| context | Pointer to a valid aaruformat context (must be properly initialized). |
| sectors | Pointer to a uint16_t that receives the negative sector count on success. |
| AARUF_STATUS_OK | (0) Successfully retrieved the negative sector count. This is returned when:
|
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context is invalid. This occurs when:
|
Definition at line 3417 of file metadata.c.
References AARU_MAGIC, AARUF_ERROR_NOT_AARUFORMAT, AARUF_STATUS_OK, FATAL, aaruformat_context::magic, DdtHeader2::negative, TRACE, and aaruformat_context::user_data_ddt_header.
| int32_t aaruf_get_overflow_sectors | ( | const void * | context, |
| uint16_t * | sectors ) |
Retrieves the number of overflow (post-gap) sectors in the AaruFormat image.
Returns the count of overflow sectors that follow the standard user data area. Overflow sectors are used to capture post-gap data, lead-out areas, and other metadata that exists after the main user-accessible storage region. This is particularly important for optical media (CD, DVD, BD) where the lead-out marks the physical end of the recorded data and contains disc finalization information, and for multi-session discs where gaps between sessions need to be preserved. For most hard disk and floppy disk images, this value is typically zero.
| context | Pointer to a valid aaruformat context (must be properly initialized). |
| sectors | Pointer to a uint16_t that receives the overflow sector count on success. |
| AARUF_STATUS_OK | (0) Successfully retrieved the overflow sector count. This is returned when:
|
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context is invalid. This occurs when:
|
Definition at line 3552 of file metadata.c.
References AARU_MAGIC, AARUF_ERROR_NOT_AARUFORMAT, AARUF_STATUS_OK, FATAL, aaruformat_context::magic, DdtHeader2::overflow, TRACE, and aaruformat_context::user_data_ddt_header.
| int32_t aaruf_get_tape_file | ( | const void * | context, |
| const uint8_t | partition, | ||
| const uint32_t | file, | ||
| uint64_t * | starting_block, | ||
| uint64_t * | ending_block ) |
Retrieves the block range for a specific tape file from an Aaru tape image.
Queries the tape file hash table to locate a file by its partition and file number, returning the first and last block addresses that define the file's extent on the tape medium. This function provides the core lookup mechanism for accessing logical files stored in tape images.
Tape File Identification: Each tape file is uniquely identified by a combination of:
These two values are combined into a 64-bit composite key: key = (partition << 32) | file_number
This composite key is used to perform a hash table lookup in the context's tapeFiles table, which was previously populated by process_tape_files_block() during image initialization.
Block Range Semantics: The returned block range [FirstBlock, LastBlock] is inclusive on both ends:
Block addresses are absolute positions within the tape image's logical block space, not relative to the partition or file.
Typical Usage Flow:
Error Handling: The function performs validation in the following order:
If any validation fails, an appropriate error code is returned and the output parameters (starting_block, ending_block) are left unmodified.
Thread Safety: This function performs read-only operations on the context and is safe to call from multiple threads concurrently, provided the context is not being modified by other operations (e.g., during image opening/closing).
Performance Characteristics:
| context | Pointer to an initialized aaruformat context. Must not be NULL. The context must have been successfully opened with aaruf_open() and contain a valid tape file hash table. The context is treated as const and is not modified by this operation. | |
| partition | The partition number (0-255) containing the requested file. For single-partition tapes, this is typically 0. Multi-partition tapes may have files in different partitions with potentially overlapping file numbers. | |
| file | The file number within the specified partition. File numbers are typically sequential starting from 0 or 1, but gaps may exist if files were deleted or the tape was written non-sequentially. | |
| [out] | starting_block | Pointer to receive the first block address of the file. Must not be NULL. Only modified on success. The value written represents the inclusive start of the file's block range. |
| [out] | ending_block | Pointer to receive the last block address of the file. Must not be NULL. Only modified on success. The value written represents the inclusive end of the file's block range. |
| AARUF_STATUS_OK | (0) Successfully retrieved tape file information. Both output parameters have been populated with valid block addresses. The requested partition/file combination exists in the image's file table. |
| AARUF_ERROR_NOT_AARUFORMAT | (-1) Invalid context or context validation failed. This is returned when:
|
| AARUF_ERROR_TAPE_FILE_NOT_FOUND | (-28) The requested partition/file combination does not exist in the image's tape file table. This is returned when:
|
Definition at line 569 of file tape.c.
References AARU_MAGIC, AARUF_ERROR_NOT_AARUFORMAT, AARUF_ERROR_TAPE_FILE_NOT_FOUND, AARUF_STATUS_OK, FATAL, TapeFileHashEntry::fileEntry, TapeFileEntry::FirstBlock, TapeFileEntry::LastBlock, aaruformat_context::magic, aaruformat_context::tape_files, and TRACE.
| int32_t aaruf_get_tape_partition | ( | const void * | context, |
| const uint8_t | partition, | ||
| uint64_t * | starting_block, | ||
| uint64_t * | ending_block ) |
Retrieves the block range for a specific tape partition from an Aaru tape image.
Queries the tape partition hash table to locate a partition by its partition number, returning the first and last block addresses that define the partition's extent on the tape medium. This function provides the core lookup mechanism for accessing partition layout information in tape images.
Tape Partition Identification: Each tape partition is uniquely identified by its partition number (0-255). Most tapes have a single partition (partition 0), but multi-partition formats like LTO, DLT, and AIT support multiple partitions with independent block address spaces.
The partition number is used as the hash table key to perform a lookup in the context's tapePartitions table, which was previously populated by process_tape_partitions_block() during image initialization.
Block Range Semantics: The returned block range [FirstBlock, LastBlock] is inclusive on both ends:
Block addresses are local to each partition. Different partitions may have overlapping logical block numbers (e.g., both partition 0 and partition 1 can have blocks 0-1000). When accessing blocks, both the partition number and block number are required for unique identification.
Typical Usage Flow:
Error Handling: The function performs validation in the following order:
If any validation fails, an appropriate error code is returned and the output parameters (starting_block, ending_block) are left unmodified.
Thread Safety: This function performs read-only operations on the context and is safe to call from multiple threads concurrently, provided the context is not being modified by other operations (e.g., during image opening/closing).
Performance Characteristics:
Partition Layout Information: The partition metadata is essential for:
| context | Pointer to an initialized aaruformat context. Must not be NULL. The context must have been successfully opened with aaruf_open() and contain a valid tape partition hash table. The context is treated as const and is not modified by this operation. | |
| partition | The partition number (0-255) to query. For single-partition tapes, this is typically 0. Multi-partition tapes may have multiple partitions numbered sequentially from 0. | |
| [out] | starting_block | Pointer to receive the first block address of the partition. Must not be NULL. Only modified on success. The value written represents the inclusive start of the partition's block range (often 0, but format-dependent). |
| [out] | ending_block | Pointer to receive the last block address of the partition. Must not be NULL. Only modified on success. The value written represents the inclusive end of the partition's block range. |
| AARUF_STATUS_OK | (0) Successfully retrieved tape partition information. Both output parameters have been populated with valid block addresses. The requested partition exists in the image's partition table. |
| AARUF_ERROR_NOT_AARUFORMAT | (-1) Invalid context or context validation failed. This is returned when:
|
| AARUF_ERROR_TAPE_PARTITION_NOT_FOUND | (-29) The requested partition number does not exist in the image's tape partition table. This is returned when:
|
Definition at line 982 of file tape.c.
References AARU_MAGIC, AARUF_ERROR_NOT_AARUFORMAT, AARUF_ERROR_TAPE_PARTITION_NOT_FOUND, AARUF_STATUS_OK, FATAL, TapePartitionEntry::FirstBlock, TapePartitionEntry::LastBlock, aaruformat_context::magic, TapePartitionHashEntry::partitionEntry, aaruformat_context::tape_partitions, and TRACE.
| int32_t aaruf_get_tracks | ( | const void * | context, |
| uint8_t * | buffer, | ||
| size_t * | length ) |
Retrieve the array of track descriptors contained in an opened AaruFormat image.
Provides the caller with a contiguous array of all track entries found in the image. The function follows a two-step usage pattern allowing callers to query the required buffer size before performing the actual copy.
Usage pattern:
The returned data is a raw copy of internal TrackEntry structures (host endianness). The caller does not assume ownership of internal memory; only the caller-provided buffer should be freed by the caller.
Preconditions (
Thread safety:
Buffer sizing logic:
Error strategy:
| context | Opaque pointer that MUST point to a valid aaruformatContext. |
| buffer | Destination buffer for a copy of all TrackEntry structures, or NULL to query size. |
| length | In/Out: On entry capacity of buffer (ignored if buffer == NULL). On return required or copied size in bytes. Must not be NULL. |
| AARUF_STATUS_OK | Success; buffer filled. |
| AARUF_ERROR_NOT_AARUFORMAT | context is NULL or not a valid libaaruformat context. |
| AARUF_ERROR_TRACK_NOT_FOUND | No tracks present (entries == 0 or internal array NULL). |
| AARUF_ERROR_BUFFER_TOO_SMALL | Sizing query / provided buffer insufficient; *length updated. |
Usage example (conceptual):
Definition at line 281 of file optical.c.
References AARU_MAGIC, AARUF_ERROR_BUFFER_TOO_SMALL, AARUF_ERROR_NOT_AARUFORMAT, AARUF_ERROR_TRACK_NOT_FOUND, AARUF_STATUS_OK, TracksHeader::entries, FATAL, aaruformat_context::magic, TRACE, aaruformat_context::track_entries, and aaruformat_context::tracks_header.
| int32_t aaruf_get_user_sectors | ( | const void * | context, |
| uint64_t * | sectors ) |
Retrieves the total number of user-accessible sectors in the AaruFormat image.
Returns the count of standard user data sectors in the image, excluding any negative (pre-gap) or overflow (post-gap) sectors. This represents the primary addressable sector range that contains the main user data, typically corresponding to the logical capacity of the storage medium as it would be seen by an operating system or file system. For optical media, this excludes lead-in and lead-out areas. For hard disks, this represents the standard LBA-addressable range.
| context | Pointer to a valid aaruformat context (must be properly initialized). |
| sectors | Pointer to a uint64_t that receives the total user sector count on success. |
| AARUF_STATUS_OK | (0) Successfully retrieved the user sector count. This is returned when:
|
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context is invalid. This occurs when:
|
Definition at line 3292 of file metadata.c.
References AARU_MAGIC, AARUF_ERROR_NOT_AARUFORMAT, AARUF_STATUS_OK, DdtHeader2::blocks, FATAL, aaruformat_context::magic, TRACE, and aaruformat_context::user_data_ddt_header.
| int32_t aaruf_get_xml_mediatype | ( | int32_t | type | ) |
Definition at line 339 of file helpers.c.
References BDR, BDRE, BDREXL, BDROM, BDRXL, BlockMedia, CBHD, CD, CD32, CDDA, CDEG, CDG, CDI, CDIREADY, CDMIDI, CDMO, CDMRW, CDPLUS, CDR, CDROM, CDROMXA, CDRW, CDTV, CDV, DDCD, DDCDR, DDCDRW, DTSCD, DVDDownload, DVDPR, DVDPRDL, DVDPRW, DVDPRWDL, DVDR, DVDRAM, DVDRDL, DVDROM, DVDRW, DVDRWDL, EVD, FDDVD, FMTOWNS, FVD, GDR, GDROM, GOD, HDDVDR, HDDVDRAM, HDDVDRDL, HDDVDROM, HDDVDRW, HDDVDRWDL, HDVMD, HVD, JaguarCD, LD, LDROM, LDROM2, LVROM, MEGACD, MegaLD, MilCD, NeoGeoCD, Nuon, OpticalDisc, PCD, PCFX, Pippin, Playdia, PS1CD, PS2CD, PS2DVD, PS3BD, PS3DVD, PS4BD, SACD, SATURNCD, SuperCDROM2, SVCD, SVOD, ThreeDO, UMD, VCD, VCDHD, VideoNow, VideoNowColor, VideoNowXp, WOD, WUOD, XGD, XGD2, XGD3, and XGD4.
Referenced by aaruf_create(), and aaruf_open().
| int aaruf_identify | ( | const char * | filename | ) |
Identifies a file as an AaruFormat image using a file path.
Opens the file at the given path and determines if it is an AaruFormat image by examining the file header for valid AaruFormat signatures and version information. This function provides a simple file-based interface that handles file opening, identification, and cleanup automatically. It delegates the actual identification logic to aaruf_identify_stream().
| filename | Path to the file to identify (must be accessible and readable). |
| 100 | Maximum confidence - Definitive AaruFormat image. This is returned when:
|
| 0 | Not recognized - File is not an AaruFormat image. This is returned when:
|
| Positive | errno values - File access errors from system calls. Common values include:
|
Definition at line 84 of file identify.c.
References aaruf_identify_stream().
| int aaruf_identify_stream | ( | FILE * | image_stream | ) |
Identifies a file as an AaruFormat image using an open stream.
Determines if the provided stream is an AaruFormat image by reading and validating the file header at the beginning of the stream. This function performs the core identification logic by checking for valid AaruFormat signatures and version compatibility. It's designed to work with any FILE stream, making it suitable for integration with existing file handling code.
| image_stream | Open FILE stream positioned at any location (will be repositioned to start). |
| 100 | Maximum confidence - Definitive AaruFormat image. This is returned when:
|
| 0 | Not recognized - Stream is not an AaruFormat image. This is returned when:
|
Definition at line 163 of file identify.c.
References AARU_MAGIC, AARUF_VERSION, DIC_MAGIC, AaruHeader::identifier, and AaruHeader::imageMajorVersion.
Referenced by aaruf_identify().
| int32_t aaruf_lzma_decode_buffer | ( | uint8_t * | dst_buffer, |
| size_t * | dst_size, | ||
| const uint8_t * | src_buffer, | ||
| size_t * | src_len, | ||
| const uint8_t * | props, | ||
| const size_t | props_size ) |
Decodes an LZMA-compressed buffer.
Decompresses data from the source buffer into the destination buffer using LZMA.
| dst_buffer | Pointer to the destination buffer. |
| dst_size | Pointer to the size of the destination buffer; updated with the actual size. |
| src_buffer | Pointer to the source (compressed) buffer. |
| src_len | Pointer to the size of the source buffer; updated with the actual size read. |
| props | Pointer to the LZMA properties. |
| props_size | Size of the LZMA properties. |
Definition at line 39 of file lzma.c.
References AARU_CALL, and AARU_EXPORT.
Referenced by aaruf_read_sector(), decode_ddt_multi_level_v2(), process_data_block(), process_ddt_v1(), and process_ddt_v2().
| int32_t aaruf_lzma_encode_buffer | ( | uint8_t * | dst_buffer, |
| size_t * | dst_size, | ||
| const uint8_t * | src_buffer, | ||
| const size_t | src_len, | ||
| uint8_t * | out_props, | ||
| size_t * | out_props_size, | ||
| const int32_t | level, | ||
| const uint32_t | dict_size, | ||
| const int32_t | lc, | ||
| const int32_t | lp, | ||
| const int32_t | pb, | ||
| const int32_t | fb, | ||
| const int32_t | num_threads ) |
Encodes a buffer using LZMA compression.
Compresses data from the source buffer into the destination buffer using LZMA.
| dst_buffer | Pointer to the destination buffer. |
| dst_size | Pointer to the size of the destination buffer; updated with the actual size. |
| src_buffer | Pointer to the source (uncompressed) buffer. |
| src_len | Size of the source buffer. |
| out_props | Pointer to the output LZMA properties. |
| out_props_size | Pointer to the size of the output LZMA properties. |
| level | Compression level. |
| dict_size | Dictionary size. |
| lc | LZMA literal context bits. |
| lp | LZMA literal position bits. |
| pb | LZMA position bits. |
| fb | Number of fast bytes. |
| num_threads | Number of threads to use. |
Definition at line 65 of file lzma.c.
References AARU_CALL, and AARU_EXPORT.
Referenced by aaruf_close_current_block(), set_ddt_multi_level_v2(), write_cached_secondary_ddt(), write_dvd_long_sector_blocks(), write_dvd_title_key_decrypted_block(), write_media_tags(), write_mode2_subheaders_block(), write_sector_prefix(), write_sector_prefix_ddt(), write_sector_subchannel(), write_sector_suffix(), write_sector_suffix_ddt(), and write_single_level_ddt().
| void aaruf_md5_buffer | ( | const void * | data, |
| unsigned long | size, | ||
| unsigned char * | result ) |
Definition at line 508 of file md5.c.
References AARU_CALL, AARU_EXPORT, aaruf_md5_final(), aaruf_md5_init(), and aaruf_md5_update().
| void aaruf_md5_final | ( | md5_ctx * | ctx, |
| unsigned char * | result ) |
Definition at line 475 of file md5.c.
References md5_ctx::a, AARU_CALL, AARU_EXPORT, md5_ctx::b, body(), md5_ctx::buffer, md5_ctx::c, md5_ctx::d, md5_ctx::hi, md5_ctx::lo, and OUT.
Referenced by aaruf_md5_buffer(), and write_checksum_block().
| void aaruf_md5_init | ( | md5_ctx * | ctx | ) |
Definition at line 425 of file md5.c.
References md5_ctx::a, AARU_CALL, AARU_EXPORT, md5_ctx::b, md5_ctx::c, md5_ctx::d, md5_ctx::hi, and md5_ctx::lo.
Referenced by aaruf_create(), and aaruf_md5_buffer().
| void aaruf_md5_update | ( | md5_ctx * | ctx, |
| const void * | data, | ||
| unsigned long | size ) |
Definition at line 436 of file md5.c.
References AARU_CALL, AARU_EXPORT, AARU_RESTRICT, body(), md5_ctx::buffer, md5_ctx::hi, LIKELY, md5_ctx::lo, and UNLIKELY.
Referenced by aaruf_md5_buffer(), aaruf_write_sector(), and aaruf_write_sector_long().
| void * aaruf_open | ( | const char * | filepath | ) |
Opens an existing AaruFormat image file.
Opens the specified image file and returns a pointer to the initialized aaruformat context. This function performs comprehensive validation of the image file format, reads and processes all index entries, initializes data structures for reading operations, and sets up caches for optimal performance. It supports multiple AaruFormat versions and handles various block types including data blocks, deduplication tables, metadata, and checksums.
| filepath | Path to the image file to open. |
| aaruformatContext* | Successfully opened and initialized context. The returned pointer contains:
|
| NULL | Opening failed. The specific error can be determined by checking errno, which will be set to:
|
< Size in bytes (UTF-16LE) of application name field (32 UTF-16 code units).
< Size in bytes (UTF-16LE) of application name field (32 UTF-16 code units).
< Size in bytes (UTF-16LE) of application name field (32 UTF-16 code units).
Definition at line 125 of file open.c.
References AARU_HEADER_APP_NAME_LEN, AARU_MAGIC, aaruf_close(), aaruf_ecc_cd_init(), AARUF_ERROR_CANNOT_READ_INDEX, AARUF_ERROR_FILE_TOO_SMALL, AARUF_ERROR_INCOMPATIBLE_VERSION, AARUF_ERROR_NOT_AARUFORMAT, AARUF_ERROR_NOT_ENOUGH_MEMORY, aaruf_get_xml_mediatype(), AARUF_STATUS_OK, AARUF_VERSION, AARUF_VERSION_V2, AaruMetadataJsonBlock, ImageInfo::Application, AaruHeaderV2::application, AaruHeaderV2::applicationMajorVersion, AaruHeaderV2::applicationMinorVersion, ImageInfo::ApplicationVersion, aaruformat_context::block_cache, aaruformat_context::block_header_cache, BlockMedia, IndexEntry::blockType, CacheHeader::cache, ChecksumBlock, CicmBlock, cleanup_open_failure(), ImageInfo::CreationTime, AaruHeaderV2::creationTime, aaruformat_context::cylinders, DataBlock, IndexEntry::dataType, DeDuplicationTable, DeDuplicationTable2, DIC_MAGIC, DumpHardwareBlock, aaruformat_context::ecc_cd_context, FATAL, aaruformat_context::geometry_block, GeometryBlock, aaruformat_context::header, aaruformat_context::heads, AaruHeaderV2::identifier, GeometryBlockHeader::identifier, aaruformat_context::image_info, AaruHeaderV2::imageMajorVersion, AaruHeaderV2::imageMinorVersion, ImageInfo::ImageSize, aaruformat_context::imageStream, IndexBlock, IndexBlock2, IndexBlock3, AaruHeaderV2::indexOffset, ImageInfo::LastModificationTime, AaruHeaderV2::lastWrittenTime, LIBAARUFORMAT_MAJOR_VERSION, LIBAARUFORMAT_MINOR_VERSION, aaruformat_context::library_major_version, aaruformat_context::library_minor_version, aaruformat_context::magic, MAX_CACHE_SIZE, CacheHeader::max_items, MaxSectorTag, ImageInfo::MediaType, AaruHeaderV2::mediaType, MetadataBlock, ImageInfo::MetadataMediaType, IndexEntry::offset, process_aaru_metadata_json_block(), process_checksum_block(), process_cicm_block(), process_data_block(), process_ddt_v1(), process_ddt_v2(), process_dumphw_block(), process_geometry_block(), process_index_v1(), process_index_v2(), process_index_v3(), process_metadata_block(), process_tape_files_block(), process_tape_partitions_block(), process_tracks_block(), aaruformat_context::readableSectorTags, ImageInfo::Sectors, aaruformat_context::sectors_per_track, ImageInfo::SectorSize, aaruformat_context::shift, TapeFileBlock, TapePartitionBlock, TRACE, TracksBlock, and ImageInfo::Version.
| int32_t aaruf_read_media_tag | ( | void * | context, |
| uint8_t * | data, | ||
| const int32_t | tag, | ||
| uint32_t * | length ) |
Reads a media tag from the AaruFormat image.
Reads the specified media tag from the image and stores it in the provided buffer. Media tags contain metadata information about the storage medium such as disc information, lead-in/lead-out data, manufacturer-specific information, or other medium-specific metadata. This function uses a hash table lookup for efficient tag retrieval and supports buffer size querying when data pointer is NULL.
| context | Pointer to the aaruformat context. |
| data | Pointer to the buffer to store the tag data. Can be NULL to query tag length. |
| tag | Tag identifier to read (specific to media type and format). |
| length | Pointer to the length of the buffer on input; updated with actual tag length on output. |
| AARUF_STATUS_OK | (0) Successfully read the media tag. This is returned when:
|
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context is invalid. This occurs when:
|
| AARUF_ERROR_MEDIA_TAG_NOT_PRESENT | (-11) The requested media tag does not exist. This occurs when:
|
| AARUF_ERROR_BUFFER_TOO_SMALL | (-10) The provided buffer is insufficient. This occurs when:
|
Definition at line 85 of file read.c.
References AARU_MAGIC, AARUF_ERROR_BUFFER_TOO_SMALL, AARUF_ERROR_INCORRECT_DATA_SIZE, AARUF_ERROR_MEDIA_TAG_NOT_PRESENT, AARUF_ERROR_NOT_AARUFORMAT, AARUF_STATUS_OK, mediaTagEntry::data, FATAL, mediaTagEntry::length, aaruformat_context::magic, aaruformat_context::mediaTags, and TRACE.
| int32_t aaruf_read_sector | ( | void * | context, |
| const uint64_t | sector_address, | ||
| bool | negative, | ||
| uint8_t * | data, | ||
| uint32_t * | length ) |
Reads a sector from the AaruFormat image.
Reads user data from the specified sector address in the image. This function reads only the user data portion of the sector, without any additional metadata or ECC/EDC information. It handles block-based deduplication, compression (LZMA/FLAC), and caching for optimal performance. The function supports both DDT v1 and v2 formats for sector-to-block mapping.
| context | Pointer to the aaruformat context. |
| sector_address | The logical sector address to read from. |
| negative | Indicates if the sector address is negative. |
| data | Pointer to buffer where sector data will be stored. Can be NULL to query length. |
| length | Pointer to variable containing buffer size on input, actual data length on output. |
| AARUF_STATUS_OK | (0) Successfully read the sector data. This is returned when:
|
| AARUF_STATUS_SECTOR_NOT_DUMPED | (1) The sector was not dumped during imaging. This occurs when:
|
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context is invalid. This occurs when:
|
| AARUF_ERROR_SECTOR_OUT_OF_BOUNDS | (-8) The sector address exceeds image bounds. This occurs when:
|
| AARUF_ERROR_BUFFER_TOO_SMALL | (-10) The provided buffer is insufficient. This occurs when:
|
| AARUF_ERROR_NOT_ENOUGH_MEMORY | (-9) Memory allocation failed. This occurs when:
|
| AARUF_ERROR_CANNOT_READ_HEADER | (-6) Block header reading failed. This occurs when:
|
| AARUF_ERROR_CANNOT_READ_BLOCK | (-7) Block data reading failed. This occurs when:
|
| AARUF_ERROR_CANNOT_DECOMPRESS_BLOCK | (-17) Decompression failed. This occurs when:
|
| AARUF_ERROR_UNSUPPORTED_COMPRESSION | (-13) Unsupported compression algorithm. This occurs when:
|
| Other | error codes may be propagated from DDT decoding functions:
|
Definition at line 250 of file read.c.
References AARU_MAGIC, AARUF_ERROR_BUFFER_TOO_SMALL, AARUF_ERROR_CANNOT_DECOMPRESS_BLOCK, AARUF_ERROR_CANNOT_READ_BLOCK, AARUF_ERROR_CANNOT_READ_HEADER, AARUF_ERROR_INCORRECT_DATA_SIZE, AARUF_ERROR_NOT_AARUFORMAT, AARUF_ERROR_NOT_ENOUGH_MEMORY, AARUF_ERROR_SECTOR_OUT_OF_BOUNDS, AARUF_ERROR_UNSUPPORTED_COMPRESSION, aaruf_flac_decode_redbook_buffer(), aaruf_lzma_decode_buffer(), AARUF_STATUS_OK, AARUF_STATUS_SECTOR_NOT_DUMPED, add_to_cache_uint64(), aaruformat_context::block_cache, aaruformat_context::block_header_cache, BlockHeader::cmpLength, BlockHeader::compression, aaruformat_context::ddt_version, decode_ddt_entry_v1(), decode_ddt_entry_v2(), FATAL, find_in_cache_uint64(), Flac, aaruformat_context::image_info, aaruformat_context::imageStream, BlockHeader::length, Lzma, LZMA_PROPERTIES_LENGTH, aaruformat_context::magic, DdtHeader2::negative, None, DdtHeader2::overflow, ImageInfo::Sectors, ImageInfo::SectorSize, BlockHeader::sectorSize, SectorStatusNotDumped, TRACE, and aaruformat_context::user_data_ddt_header.
Referenced by aaruf_read_sector_long(), and aaruf_read_track_sector().
| int32_t aaruf_read_sector_long | ( | void * | context, |
| const uint64_t | sector_address, | ||
| bool | negative, | ||
| uint8_t * | data, | ||
| uint32_t * | length ) |
Reads a complete sector with all metadata from the AaruFormat image.
Reads the complete sector data including user data, ECC/EDC, subchannel data, and other metadata depending on the media type. For optical discs, this returns a full 2352-byte sector with sync, header, user data, and ECC/EDC. For block media with tags, this includes both the user data and tag information. The function handles complex sector reconstruction including ECC correction and format-specific metadata assembly.
| context | Pointer to the aaruformat context. |
| sector_address | The logical sector address to read from. |
| negative | Indicates if the sector address is negative. |
| data | Pointer to buffer where complete sector data will be stored. Can be NULL to query length. |
| length | Pointer to variable containing buffer size on input, actual data length on output. |
| AARUF_STATUS_OK | (0) Successfully read the complete sector with metadata. This is returned when:
|
| AARUF_STATUS_SECTOR_NOT_DUMPED | (1) The sector or metadata was not dumped. This can occur when:
|
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context is invalid. This occurs when:
|
| AARUF_ERROR_INCORRECT_MEDIA_TYPE | (-5) The media type doesn't support long sector reading. This occurs when:
|
| AARUF_ERROR_BUFFER_TOO_SMALL | (-10) The buffer is insufficient for complete sector data. This occurs when:
|
| AARUF_ERROR_NOT_ENOUGH_MEMORY | (-9) Memory allocation failed. This occurs when:
|
| AARUF_ERROR_TRACK_NOT_FOUND | (-12) Cannot locate the sector's track. This occurs when:
|
| AARUF_ERROR_INVALID_TRACK_FORMAT | (-14) The track has an unsupported format. This occurs when:
|
| AARUF_ERROR_REACHED_UNREACHABLE_CODE | (-15) Internal logic error. This occurs when:
|
| All | error codes from aaruf_read_sector() may be propagated:
|
Definition at line 815 of file read.c.
References AARU_MAGIC, aaruf_ecc_cd_reconstruct(), aaruf_ecc_cd_reconstruct_prefix(), AARUF_ERROR_BUFFER_TOO_SMALL, AARUF_ERROR_INCORRECT_DATA_SIZE, AARUF_ERROR_INCORRECT_MEDIA_TYPE, AARUF_ERROR_INVALID_TRACK_FORMAT, AARUF_ERROR_NOT_AARUFORMAT, AARUF_ERROR_NOT_ENOUGH_MEMORY, AARUF_ERROR_REACHED_UNREACHABLE_CODE, AARUF_ERROR_SECTOR_OUT_OF_BOUNDS, AARUF_ERROR_TRACK_NOT_FOUND, aaruf_read_sector(), AARUF_STATUS_OK, AARUF_STATUS_SECTOR_NOT_DUMPED, AppleFileWare, AppleProfile, AppleSonyDS, AppleSonySS, AppleWidget, Audio, BlockMedia, CD_DFIX_MASK, CD_XFIX_MASK, CdMode1, CdMode2Form1, CdMode2Form2, CdMode2Formless, Correct, Data, aaruformat_context::data_tracks, DVDDownload, DVDPR, DVDPRDL, DVDPRW, DVDPRWDL, DVDR, DVDRAM, DVDRDL, DVDROM, DVDRW, DVDRWDL, aaruformat_context::ecc_cd_context, FATAL, aaruformat_context::image_info, aaruformat_context::magic, ImageInfo::MediaType, ImageInfo::MetadataMediaType, aaruformat_context::mode2_subheaders, Mode2Form1Ok, Mode2Form2NoCrc, Mode2Form2Ok, DdtHeader2::negative, NotDumped, aaruformat_context::number_of_data_tracks, Nuon, OpticalDisc, DdtHeader2::overflow, PriamDataTower, PS2DVD, PS3DVD, SACD, aaruformat_context::sector_cpr_mai, aaruformat_context::sector_edc, aaruformat_context::sector_id, aaruformat_context::sector_ied, aaruformat_context::sector_prefix, aaruformat_context::sector_prefix_corrected, aaruformat_context::sector_prefix_ddt, aaruformat_context::sector_prefix_ddt2, aaruformat_context::sector_subchannel, aaruformat_context::sector_suffix, aaruformat_context::sector_suffix_corrected, aaruformat_context::sector_suffix_ddt, aaruformat_context::sector_suffix_ddt2, ImageInfo::Sectors, SectorStatusMode1Correct, SectorStatusMode2Form1Ok, SectorStatusMode2Form2NoCrc, SectorStatusMode2Form2Ok, SectorStatusNotDumped, TrackEntry::start, TRACE, TrackEntry::type, and aaruformat_context::user_data_ddt_header.
| int32_t aaruf_read_sector_tag | ( | const void * | context, |
| const uint64_t | sector_address, | ||
| const bool | negative, | ||
| uint8_t * | buffer, | ||
| uint32_t * | length, | ||
| const int32_t | tag ) |
Reads a specific sector tag from the AaruFormat image.
Reads sector-level metadata tags such as subchannel data, track information, DVD sector metadata, or Apple/Priam proprietary tags from the specified sector. Sector tags are ancillary data stored separately from the main user data and provide format-specific metadata like track flags, ISRC codes, DVD encryption information, or ECC/EDC data. This function validates tag type against media type and ensures the tag data is present in the image before returning it.
| context | Pointer to the aaruformat context. |
| sector_address | The logical sector address to read the tag from. |
| negative | Indicates if the sector address is negative (pre-track area). |
| buffer | Pointer to buffer where tag data will be stored. Can be NULL to query tag length. |
| length | Pointer to variable containing buffer size on input, actual tag length on output. |
| tag | Tag identifier specifying which sector tag to read (see SectorTagType enum). |
| AARUF_STATUS_OK | (0) Successfully read the sector tag. This is returned when:
|
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context is invalid. This occurs when:
|
| AARUF_ERROR_SECTOR_OUT_OF_BOUNDS | (-5) The sector address exceeds image bounds. This occurs when:
|
| AARUF_ERROR_INCORRECT_MEDIA_TYPE | (-12) Tag type incompatible with media type. This occurs when:
|
| AARUF_ERROR_INCORRECT_DATA_SIZE | (-26) The provided buffer has incorrect size. This occurs when:
|
| AARUF_ERROR_SECTOR_TAG_NOT_PRESENT | (-16) The requested tag is not stored in the image. This occurs when:
|
| AARUF_ERROR_TRACK_NOT_FOUND | (-13) Track information not found for the sector. This occurs when:
|
| AARUF_ERROR_INVALID_TAG | (-27) The tag identifier is not recognized or supported. This occurs when:
|
Block Media Tags (BlockMedia only):
Definition at line 1463 of file read.c.
References AARU_MAGIC, AARUF_ERROR_INCORRECT_DATA_SIZE, AARUF_ERROR_INCORRECT_MEDIA_TYPE, AARUF_ERROR_INVALID_TAG, AARUF_ERROR_NOT_AARUFORMAT, AARUF_ERROR_SECTOR_OUT_OF_BOUNDS, AARUF_ERROR_SECTOR_TAG_NOT_PRESENT, AARUF_ERROR_TRACK_NOT_FOUND, AARUF_STATUS_OK, AppleProfileTag, AppleSonyTag, BlockMedia, CdSectorSubchannel, CdTrackFlags, CdTrackIsrc, DvdCmi, DvdSectorEdc, DvdSectorIed, DvdSectorInformation, DvdSectorNumber, DvdTitleKeyDecrypted, TracksHeader::entries, FATAL, TrackEntry::flags, aaruformat_context::image_info, TrackEntry::isrc, aaruformat_context::magic, ImageInfo::MetadataMediaType, DdtHeader2::negative, OpticalDisc, DdtHeader2::overflow, PriamDataTowerTag, aaruformat_context::sector_cpr_mai, aaruformat_context::sector_decrypted_title_key, aaruformat_context::sector_edc, aaruformat_context::sector_id, aaruformat_context::sector_ied, aaruformat_context::sector_subchannel, ImageInfo::Sectors, TrackEntry::start, TRACE, aaruformat_context::track_entries, aaruformat_context::tracks_header, and aaruformat_context::user_data_ddt_header.
| int32_t aaruf_read_track_sector | ( | void * | context, |
| uint8_t * | data, | ||
| const uint64_t | sector_address, | ||
| uint32_t * | length, | ||
| const uint8_t | track ) |
Reads a sector from a specific track in the AaruFormat image.
Reads user data from the specified sector address within a particular track. This function is specifically designed for optical disc images where sectors are organized by tracks. The sector address is relative to the start of the track. It validates the media type, locates the specified track by sequence number, calculates the absolute sector address, and delegates to aaruf_read_sector().
| context | Pointer to the aaruformat context. |
| data | Pointer to buffer where sector data will be stored. |
| sector_address | The sector address relative to the track start. |
| length | Pointer to variable containing buffer size on input, actual data length on output. |
| track | The track sequence number to read from. |
| AARUF_STATUS_OK | (0) Successfully read the sector data from the specified track. This is returned when:
|
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context is invalid. This occurs when:
|
| AARUF_ERROR_INCORRECT_MEDIA_TYPE | (-5) The media is not an optical disc. This occurs when:
|
| AARUF_ERROR_TRACK_NOT_FOUND | (-12) The specified track does not exist. This occurs when:
|
| All | other error codes from aaruf_read_sector() may be returned:
|
Definition at line 663 of file read.c.
References AARU_MAGIC, AARUF_ERROR_INCORRECT_DATA_SIZE, AARUF_ERROR_INCORRECT_MEDIA_TYPE, AARUF_ERROR_NOT_AARUFORMAT, AARUF_ERROR_TRACK_NOT_FOUND, aaruf_read_sector(), aaruformat_context::data_tracks, FATAL, aaruformat_context::image_info, aaruformat_context::magic, ImageInfo::MetadataMediaType, aaruformat_context::number_of_data_tracks, OpticalDisc, TrackEntry::sequence, TrackEntry::start, and TRACE.
| int32_t aaruf_set_aaru_json_metadata | ( | void * | context, |
| uint8_t * | data, | ||
| size_t | length ) |
Sets the Aaru metadata JSON for the image during creation.
Embeds Aaru metadata JSON into the image being created. The Aaru metadata JSON format is a structured, machine-readable representation of comprehensive image metadata including media information, imaging session details, hardware configuration, optical disc tracks and sessions, checksums, and preservation metadata. This function stores the JSON payload in its original form without parsing or validation, allowing callers to provide pre-generated JSON conforming to the Aaru metadata schema. The JSON data will be written to the image file during aaruf_close() as an AaruMetadataJsonBlock.
The function accepts raw UTF-8 encoded JSON data as an opaque byte array and creates an internal copy that persists for the lifetime of the context. If Aaru JSON metadata was previously set on this context, the old data is freed and replaced with the new JSON. The JSON is treated as opaque binary data by the library; no parsing, interpretation, or schema validation is performed during the set operation.
| context | Pointer to the aaruformat context (must be a valid, write-enabled image context). |
| data | Pointer to the Aaru metadata JSON data in UTF-8 encoding (opaque byte array). The JSON should conform to the Aaru metadata schema, though this is not validated. Must not be NULL. |
| length | Length of the JSON data in bytes. The payload may or may not be null-terminated; the length should reflect the actual JSON data size. |
| AARUF_STATUS_OK | (0) Successfully set Aaru metadata JSON. This is returned when:
|
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context is invalid. This occurs when:
|
| AARUF_READ_ONLY | (-13) The context is not opened for writing. This occurs when:
|
| AARUF_ERROR_NOT_ENOUGH_MEMORY | (-8) Memory allocation failed. This occurs when:
|
Definition at line 2258 of file metadata.c.
References AARU_MAGIC, AARUF_ERROR_NOT_AARUFORMAT, AARUF_ERROR_NOT_ENOUGH_MEMORY, AARUF_READ_ONLY, AARUF_STATUS_OK, AaruMetadataJsonBlock, FATAL, AaruMetadataJsonBlockHeader::identifier, aaruformat_context::is_writing, aaruformat_context::json_block, aaruformat_context::json_block_header, AaruMetadataJsonBlockHeader::length, aaruformat_context::magic, and TRACE.
| int32_t aaruf_set_comments | ( | void * | context, |
| const uint8_t * | data, | ||
| const int32_t | length ) |
Sets user comments or notes for the image.
Records arbitrary user-provided comments, notes, or annotations associated with the AaruFormat image. This metadata field allows users to document the image's purpose, provenance, condition, or any other relevant information. Comments are stored in UTF-16LE encoding and can contain multi-line text, special characters, and detailed descriptions.
| context | Pointer to the aaruformat context (must be a valid, write-enabled image context). |
| data | Pointer to the comments string data in UTF-16LE encoding (opaque byte array). |
| length | Length of the comments data in bytes (must include full UTF-16LE character sequences). |
| AARUF_STATUS_OK | (0) Successfully set comments. This is returned when:
|
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context is invalid. This occurs when:
|
| AARUF_READ_ONLY | (-13) The context is not opened for writing. This occurs when:
|
| AARUF_ERROR_NOT_ENOUGH_MEMORY | (-8) Memory allocation failed. This occurs when:
|
Definition at line 607 of file metadata.c.
References AARU_MAGIC, AARUF_ERROR_NOT_AARUFORMAT, AARUF_ERROR_NOT_ENOUGH_MEMORY, AARUF_READ_ONLY, AARUF_STATUS_OK, aaruformat_context::comments, MetadataBlockHeader::commentsLength, FATAL, MetadataBlockHeader::identifier, aaruformat_context::is_writing, aaruformat_context::magic, aaruformat_context::metadata_block_header, MetadataBlock, and TRACE.
| int32_t aaruf_set_creator | ( | void * | context, |
| const uint8_t * | data, | ||
| const int32_t | length ) |
Sets the creator (person/operator) information for the image.
Records the name of the person or operator who created the AaruFormat image. This metadata identifies the individual responsible for the imaging process, which is valuable for provenance tracking, accountability, and understanding the human context in which the image was created. The creator name is stored in UTF-16LE encoding and preserved exactly as provided by the caller.
| context | Pointer to the aaruformat context (must be a valid, write-enabled image context). |
| data | Pointer to the creator name string data in UTF-16LE encoding (opaque byte array). |
| length | Length of the creator data in bytes (must include full UTF-16LE character sequences). |
| AARUF_STATUS_OK | (0) Successfully set creator information. This is returned when:
|
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context is invalid. This occurs when:
|
| AARUF_READ_ONLY | (-13) The context is not opened for writing. This occurs when:
|
| AARUF_ERROR_NOT_ENOUGH_MEMORY | (-8) Memory allocation failed. This occurs when:
|
Definition at line 493 of file metadata.c.
References AARU_MAGIC, AARUF_ERROR_NOT_AARUFORMAT, AARUF_ERROR_NOT_ENOUGH_MEMORY, AARUF_READ_ONLY, AARUF_STATUS_OK, aaruformat_context::creator, MetadataBlockHeader::creatorLength, FATAL, MetadataBlockHeader::identifier, aaruformat_context::is_writing, aaruformat_context::magic, aaruformat_context::metadata_block_header, MetadataBlock, and TRACE.
| int32_t aaruf_set_drive_firmware_revision | ( | void * | context, |
| const uint8_t * | data, | ||
| const int32_t | length ) |
Sets the drive firmware revision for the image.
Records the firmware version or revision of the drive or device used to read or write the physical storage media. Firmware revisions can significantly affect drive behavior, error handling, performance, and compatibility. This metadata is crucial for understanding the imaging environment, troubleshooting issues, and ensuring reproducibility. Different firmware versions of the same drive model can behave quite differently, making this information essential for comprehensive documentation. The firmware revision is stored in UTF-16LE encoding.
| context | Pointer to the aaruformat context (must be a valid, write-enabled image context). |
| data | Pointer to the drive firmware revision string data in UTF-16LE encoding (opaque byte array). |
| length | Length of the drive firmware revision data in bytes (must include full UTF-16LE character sequences). |
| AARUF_STATUS_OK | (0) Successfully set drive firmware revision. This is returned when:
|
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context is invalid. This occurs when:
|
| AARUF_READ_ONLY | (-13) The context is not opened for writing. This occurs when:
|
| AARUF_ERROR_NOT_ENOUGH_MEMORY | (-8) Memory allocation failed. This occurs when:
|
Definition at line 1793 of file metadata.c.
References AARU_MAGIC, AARUF_ERROR_NOT_AARUFORMAT, AARUF_ERROR_NOT_ENOUGH_MEMORY, AARUF_READ_ONLY, AARUF_STATUS_OK, aaruformat_context::drive_firmware_revision, MetadataBlockHeader::driveFirmwareRevisionLength, FATAL, MetadataBlockHeader::identifier, aaruformat_context::is_writing, aaruformat_context::magic, aaruformat_context::metadata_block_header, MetadataBlock, and TRACE.
| int32_t aaruf_set_drive_manufacturer | ( | void * | context, |
| const uint8_t * | data, | ||
| const int32_t | length ) |
Sets the drive manufacturer information for the image.
Records the name of the company that manufactured the drive or device used to read or write the physical storage media. This metadata provides valuable context about the imaging process, as different drives may have different capabilities, error handling characteristics, and compatibility with specific media types. The manufacturer name is stored in UTF-16LE encoding.
| context | Pointer to the aaruformat context (must be a valid, write-enabled image context). |
| data | Pointer to the drive manufacturer string data in UTF-16LE encoding (opaque byte array). |
| length | Length of the drive manufacturer data in bytes (must include full UTF-16LE character sequences). |
| AARUF_STATUS_OK | (0) Successfully set drive manufacturer. This is returned when:
|
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context is invalid. This occurs when:
|
| AARUF_READ_ONLY | (-13) The context is not opened for writing. This occurs when:
|
| AARUF_ERROR_NOT_ENOUGH_MEMORY | (-8) Memory allocation failed. This occurs when:
|
Definition at line 1412 of file metadata.c.
References AARU_MAGIC, AARUF_ERROR_NOT_AARUFORMAT, AARUF_ERROR_NOT_ENOUGH_MEMORY, AARUF_READ_ONLY, AARUF_STATUS_OK, aaruformat_context::drive_manufacturer, MetadataBlockHeader::driveManufacturerLength, FATAL, MetadataBlockHeader::identifier, aaruformat_context::is_writing, aaruformat_context::magic, aaruformat_context::metadata_block_header, MetadataBlock, and TRACE.
| int32_t aaruf_set_drive_model | ( | void * | context, |
| const uint8_t * | data, | ||
| const int32_t | length ) |
Sets the drive model information for the image.
Records the specific model or product designation of the drive or device used to read or write the physical storage media. This metadata provides detailed information about the imaging equipment, which can be important for understanding the capabilities, limitations, and characteristics of the imaging process. Different drive models within the same manufacturer's product line may have significantly different features and performance characteristics. The model information is stored in UTF-16LE encoding.
| context | Pointer to the aaruformat context (must be a valid, write-enabled image context). |
| data | Pointer to the drive model string data in UTF-16LE encoding (opaque byte array). |
| length | Length of the drive model data in bytes (must include full UTF-16LE character sequences). |
| AARUF_STATUS_OK | (0) Successfully set drive model. This is returned when:
|
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context is invalid. This occurs when:
|
| AARUF_READ_ONLY | (-13) The context is not opened for writing. This occurs when:
|
| AARUF_ERROR_NOT_ENOUGH_MEMORY | (-8) Memory allocation failed. This occurs when:
|
Definition at line 1534 of file metadata.c.
References AARU_MAGIC, AARUF_ERROR_NOT_AARUFORMAT, AARUF_ERROR_NOT_ENOUGH_MEMORY, AARUF_READ_ONLY, AARUF_STATUS_OK, aaruformat_context::drive_model, MetadataBlockHeader::driveModelLength, FATAL, MetadataBlockHeader::identifier, aaruformat_context::is_writing, aaruformat_context::magic, aaruformat_context::metadata_block_header, MetadataBlock, and TRACE.
| int32_t aaruf_set_drive_serial_number | ( | void * | context, |
| const uint8_t * | data, | ||
| const int32_t | length ) |
Sets the drive serial number for the image.
Records the unique serial number of the drive or device used to read or write the physical storage media. This metadata provides a unique identifier for the specific piece of hardware used in the imaging process, which is particularly important for forensic work, equipment tracking, and quality assurance. The serial number enables correlation between multiple images created with the same drive and can help identify drive-specific issues or characteristics. The serial number is stored in UTF-16LE encoding.
| context | Pointer to the aaruformat context (must be a valid, write-enabled image context). |
| data | Pointer to the drive serial number string data in UTF-16LE encoding (opaque byte array). |
| length | Length of the drive serial number data in bytes (must include full UTF-16LE character sequences). |
| AARUF_STATUS_OK | (0) Successfully set drive serial number. This is returned when:
|
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context is invalid. This occurs when:
|
| AARUF_READ_ONLY | (-13) The context is not opened for writing. This occurs when:
|
| AARUF_ERROR_NOT_ENOUGH_MEMORY | (-8) Memory allocation failed. This occurs when:
|
Definition at line 1658 of file metadata.c.
References AARU_MAGIC, AARUF_ERROR_NOT_AARUFORMAT, AARUF_ERROR_NOT_ENOUGH_MEMORY, AARUF_READ_ONLY, AARUF_STATUS_OK, aaruformat_context::drive_serial_number, MetadataBlockHeader::driveSerialNumberLength, FATAL, MetadataBlockHeader::identifier, aaruformat_context::is_writing, aaruformat_context::magic, aaruformat_context::metadata_block_header, MetadataBlock, and TRACE.
| int32_t aaruf_set_dumphw | ( | void * | context, |
| uint8_t * | data, | ||
| size_t | length ) |
Sets the dump hardware block for the image during creation.
Embeds dump hardware information into the image being created. The dump hardware block documents the hardware and software environments used to create the image, recording one or more "dump environments" – typically combinations of physical devices (drives, controllers, adapters) and the software stacks that performed the read operations. This metadata is essential for understanding the imaging context, validating acquisition integrity, reproducing imaging conditions, and supporting forensic or archival documentation requirements.
Each environment entry includes hardware identification (manufacturer, model, revision, firmware, serial number), software identification (name, version, operating system), and optional extent ranges that specify which logical sectors or units were contributed by that particular environment. This structure supports complex imaging scenarios where multiple devices or software configurations were used to create a composite image.
The function accepts a complete, pre-serialized DumpHardwareBlock in the on-disk binary format (as returned by aaruf_get_dumphw() or manually constructed). The block is validated for correct identifier, length consistency, and CRC64 integrity before being parsed and stored in the context. The function deserializes the binary block, extracts all entries with their variable-length UTF-8 strings and extent arrays, and creates null-terminated in-memory copies for internal use.
Validation performed:
Parsing process:
Memory management: If any memory allocation fails during parsing, all previously allocated memory for the new data is freed via the free_copy_and_error label, and AARUF_ERROR_NOT_ENOUGH_MEMORY is returned. Any existing dump hardware data in the context is freed before storing new data, ensuring no memory leaks when replacing dump hardware information.
| context | Pointer to the aaruformat context (must be a valid, write-enabled image context). |
| data | Pointer to the dump hardware block data in on-disk binary format. Must contain a complete DumpHardwareBlock starting with DumpHardwareHeader followed by all entries, strings, and extent arrays. Must not be NULL. |
| length | Length of the dump hardware block data in bytes. Must equal sizeof(DumpHardwareHeader) + header.length for validation to succeed. |
| AARUF_STATUS_OK | (0) Successfully set dump hardware block. This is returned when:
|
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context is invalid. This occurs when:
|
| AARUF_READ_ONLY | (-13) The context is not opened for writing. This occurs when:
|
| AARUF_ERROR_CANNOT_READ_BLOCK | (-6) Invalid block identifier. This occurs when:
|
| AARUF_ERROR_INCORRECT_DATA_SIZE | (-11) Invalid data or length. This occurs when:
|
| AARUF_ERROR_INVALID_BLOCK_CRC | (-10) CRC64 checksum mismatch. This occurs when:
|
| AARUF_ERROR_NOT_ENOUGH_MEMORY | (-8) Memory allocation failed. This occurs when:
|
Definition at line 531 of file dump.c.
References AARU_MAGIC, aaruf_crc64_data(), AARUF_ERROR_CANNOT_READ_BLOCK, AARUF_ERROR_INCORRECT_DATA_SIZE, AARUF_ERROR_INVALID_BLOCK_CRC, AARUF_ERROR_NOT_AARUFORMAT, AARUF_ERROR_NOT_ENOUGH_MEMORY, AARUF_READ_ONLY, AARUF_STATUS_OK, compare_extents(), COPY_STRING_FIELD, DumpHardwareHeader::crc64, aaruformat_context::dump_hardware_entries_with_data, aaruformat_context::dump_hardware_header, DumpHardwareBlock, DumpHardwareHeader::entries, DumpHardwareEntriesWithData::entry, DumpHardwareEntriesWithData::extents, DumpHardwareEntry::extents, FATAL, free_dump_hardware_entries(), DumpHardwareHeader::identifier, aaruformat_context::is_writing, DumpHardwareHeader::length, aaruformat_context::magic, and TRACE.
| int32_t aaruf_set_geometry | ( | void * | context, |
| const uint32_t | cylinders, | ||
| const uint32_t | heads, | ||
| const uint32_t | sectors_per_track ) |
Sets the logical CHS geometry for the AaruFormat image.
Configures the Cylinder-Head-Sector (CHS) geometry information for the image being created or modified. This function populates both the geometry block (used for storage in the image file) and the image information structure (used for runtime calculations). The geometry block contains legacy-style logical addressing parameters that describe how the storage medium should be logically organized in terms of cylinders, heads (tracks per cylinder), and sectors per track. This information is crucial for creating images that will be used with software requiring CHS addressing or for accurately preserving the original medium's logical structure.
| context | Pointer to the aaruformat context (must be a valid, write-enabled image context). |
| cylinders | The number of cylinders to set for the geometry. |
| heads | The number of heads (tracks per cylinder) to set for the geometry. |
| sectors_per_track | The number of sectors per track to set for the geometry. |
| AARUF_STATUS_OK | (0) Successfully set geometry information. This is returned when:
|
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context is invalid. This occurs when:
|
| AARUF_READ_ONLY | (-13) The context is not opened for writing. This occurs when:
|
Definition at line 229 of file metadata.c.
References AARU_MAGIC, AARUF_ERROR_NOT_AARUFORMAT, AARUF_READ_ONLY, AARUF_STATUS_OK, aaruformat_context::cylinders, GeometryBlockHeader::cylinders, FATAL, aaruformat_context::geometry_block, GeometryBlock, aaruformat_context::heads, GeometryBlockHeader::heads, GeometryBlockHeader::identifier, aaruformat_context::is_writing, aaruformat_context::magic, aaruformat_context::sectors_per_track, GeometryBlockHeader::sectorsPerTrack, and TRACE.
| int32_t aaruf_set_media_barcode | ( | void * | context, |
| const uint8_t * | data, | ||
| const int32_t | length ) |
Sets the media barcode information for the image.
Records the barcode affixed to the physical storage media or its packaging. Barcodes are commonly used in professional archival and library environments for automated inventory management, tracking, and retrieval systems. This metadata enables correlation between physical media location systems and digital image files. The barcode is stored in UTF-16LE encoding.
| context | Pointer to the aaruformat context (must be a valid, write-enabled image context). |
| data | Pointer to the media barcode string data in UTF-16LE encoding (opaque byte array). |
| length | Length of the media barcode data in bytes (must include full UTF-16LE character sequences). |
| AARUF_STATUS_OK | (0) Successfully set media barcode. This is returned when:
|
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context is invalid. This occurs when:
|
| AARUF_READ_ONLY | (-13) The context is not opened for writing. This occurs when:
|
| AARUF_ERROR_NOT_ENOUGH_MEMORY | (-8) Memory allocation failed. This occurs when:
|
Definition at line 1176 of file metadata.c.
References AARU_MAGIC, AARUF_ERROR_NOT_AARUFORMAT, AARUF_ERROR_NOT_ENOUGH_MEMORY, AARUF_READ_ONLY, AARUF_STATUS_OK, FATAL, MetadataBlockHeader::identifier, aaruformat_context::is_writing, aaruformat_context::magic, aaruformat_context::media_barcode, MetadataBlockHeader::mediaBarcodeLength, aaruformat_context::metadata_block_header, MetadataBlock, and TRACE.
| int32_t aaruf_set_media_manufacturer | ( | void * | context, |
| const uint8_t * | data, | ||
| const int32_t | length ) |
Sets the media manufacturer information for the image.
Records the name of the company that manufactured the physical storage media. This metadata is valuable for preservation and forensic purposes, as it can help identify the media type, quality characteristics, and manufacturing period. The manufacturer name is stored in UTF-16LE encoding.
| context | Pointer to the aaruformat context (must be a valid, write-enabled image context). |
| data | Pointer to the media manufacturer string data in UTF-16LE encoding (opaque byte array). |
| length | Length of the media manufacturer data in bytes (must include full UTF-16LE character sequences). |
| AARUF_STATUS_OK | (0) Successfully set media manufacturer. This is returned when:
|
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context is invalid. This occurs when:
|
| AARUF_READ_ONLY | (-13) The context is not opened for writing. This occurs when:
|
| AARUF_ERROR_NOT_ENOUGH_MEMORY | (-8) Memory allocation failed. This occurs when:
|
Definition at line 832 of file metadata.c.
References AARU_MAGIC, AARUF_ERROR_NOT_AARUFORMAT, AARUF_ERROR_NOT_ENOUGH_MEMORY, AARUF_READ_ONLY, AARUF_STATUS_OK, FATAL, MetadataBlockHeader::identifier, aaruformat_context::is_writing, aaruformat_context::magic, aaruformat_context::media_manufacturer, MetadataBlockHeader::mediaManufacturerLength, aaruformat_context::metadata_block_header, MetadataBlock, and TRACE.
| int32_t aaruf_set_media_model | ( | void * | context, |
| const uint8_t * | data, | ||
| const int32_t | length ) |
Sets the media model or product designation for the image.
Records the specific model, product line, or type designation of the physical storage media. This is more specific than the manufacturer and identifies the exact product variant. This metadata helps in identifying specific media characteristics, performance specifications, and compatibility information. The model information is stored in UTF-16LE encoding.
| context | Pointer to the aaruformat context (must be a valid, write-enabled image context). |
| data | Pointer to the media model string data in UTF-16LE encoding (opaque byte array). |
| length | Length of the media model data in bytes (must include full UTF-16LE character sequences). |
| AARUF_STATUS_OK | (0) Successfully set media model. This is returned when:
|
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context is invalid. This occurs when:
|
| AARUF_READ_ONLY | (-13) The context is not opened for writing. This occurs when:
|
| AARUF_ERROR_NOT_ENOUGH_MEMORY | (-8) Memory allocation failed. This occurs when:
|
Definition at line 939 of file metadata.c.
References AARU_MAGIC, AARUF_ERROR_NOT_AARUFORMAT, AARUF_ERROR_NOT_ENOUGH_MEMORY, AARUF_READ_ONLY, AARUF_STATUS_OK, FATAL, MetadataBlockHeader::identifier, aaruformat_context::is_writing, aaruformat_context::magic, aaruformat_context::media_model, MetadataBlockHeader::mediaModelLength, aaruformat_context::metadata_block_header, MetadataBlock, and TRACE.
| int32_t aaruf_set_media_part_number | ( | void * | context, |
| const uint8_t * | data, | ||
| const int32_t | length ) |
Sets the media part number or model designation for the image.
Records the manufacturer's part number or catalog designation for the specific type of physical storage media. This is distinct from the media model in that it represents the exact ordering or catalog number used for procurement and inventory purposes. Part numbers are particularly important for sourcing compatible replacement media and for precise identification in technical documentation. The part number is stored in UTF-16LE encoding.
| context | Pointer to the aaruformat context (must be a valid, write-enabled image context). |
| data | Pointer to the media part number string data in UTF-16LE encoding (opaque byte array). |
| length | Length of the media part number data in bytes (must include full UTF-16LE character sequences). |
| AARUF_STATUS_OK | (0) Successfully set media part number. This is returned when:
|
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context is invalid. This occurs when:
|
| AARUF_READ_ONLY | (-13) The context is not opened for writing. This occurs when:
|
| AARUF_ERROR_NOT_ENOUGH_MEMORY | (-8) Memory allocation failed. This occurs when:
|
Definition at line 1297 of file metadata.c.
References AARU_MAGIC, AARUF_ERROR_NOT_AARUFORMAT, AARUF_ERROR_NOT_ENOUGH_MEMORY, AARUF_READ_ONLY, AARUF_STATUS_OK, FATAL, MetadataBlockHeader::identifier, aaruformat_context::is_writing, aaruformat_context::magic, aaruformat_context::media_part_number, MetadataBlockHeader::mediaPartNumberLength, aaruformat_context::metadata_block_header, MetadataBlock, and TRACE.
| int32_t aaruf_set_media_sequence | ( | void * | context, |
| const int32_t | sequence, | ||
| const int32_t | last_sequence ) |
Sets the media sequence information for multi-volume media sets.
Configures the sequence numbering for media that is part of a larger set, such as multi-disk software distributions, backup sets spanning multiple tapes, or optical disc sets. This function records both the current media's position in the sequence and the total number of media in the complete set. This metadata is essential for proper ordering and completeness verification when working with multi-volume archives.
| context | Pointer to the aaruformat context (must be a valid, write-enabled image context). |
| sequence | The sequence number of this media (1-based index indicating position in the set). |
| last_sequence | The total number of media in the complete set (indicates the final sequence number). |
| AARUF_STATUS_OK | (0) Successfully set media sequence information. This is returned when:
|
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context is invalid. This occurs when:
|
| AARUF_READ_ONLY | (-13) The context is not opened for writing. This occurs when:
|
Definition at line 363 of file metadata.c.
References AARU_MAGIC, AARUF_ERROR_NOT_AARUFORMAT, AARUF_READ_ONLY, AARUF_STATUS_OK, FATAL, MetadataBlockHeader::identifier, aaruformat_context::is_writing, MetadataBlockHeader::lastMediaSequence, aaruformat_context::magic, MetadataBlockHeader::mediaSequence, aaruformat_context::metadata_block_header, MetadataBlock, and TRACE.
| int32_t aaruf_set_media_serial_number | ( | void * | context, |
| const uint8_t * | data, | ||
| const int32_t | length ) |
Sets the media serial number for the image.
Records the unique serial number assigned to the physical storage media by the manufacturer. This metadata provides a unique identifier for the specific piece of media, which is invaluable for tracking, authentication, and forensic analysis. Not all media types have serial numbers; this is most common with professional-grade media and some consumer optical discs. The serial number is stored in UTF-16LE encoding.
| context | Pointer to the aaruformat context (must be a valid, write-enabled image context). |
| data | Pointer to the media serial number string data in UTF-16LE encoding (opaque byte array). |
| length | Length of the media serial number data in bytes (must include full UTF-16LE character sequences). |
| AARUF_STATUS_OK | (0) Successfully set media serial number. This is returned when:
|
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context is invalid. This occurs when:
|
| AARUF_READ_ONLY | (-13) The context is not opened for writing. This occurs when:
|
| AARUF_ERROR_NOT_ENOUGH_MEMORY | (-8) Memory allocation failed. This occurs when:
|
Definition at line 1054 of file metadata.c.
References AARU_MAGIC, AARUF_ERROR_NOT_AARUFORMAT, AARUF_ERROR_NOT_ENOUGH_MEMORY, AARUF_READ_ONLY, AARUF_STATUS_OK, FATAL, MetadataBlockHeader::identifier, aaruformat_context::is_writing, aaruformat_context::magic, aaruformat_context::media_serial_number, MetadataBlockHeader::mediaSerialNumberLength, aaruformat_context::metadata_block_header, MetadataBlock, and TRACE.
| int32_t aaruf_set_media_title | ( | void * | context, |
| const uint8_t * | data, | ||
| const int32_t | length ) |
Sets the media title or label for the image.
Records the title, label, or name printed or written on the physical storage media. This metadata is particularly useful for identifying discs, tapes, or other media that have user-applied labels or manufacturer-printed titles. The title is stored in UTF-16LE encoding to support international characters and special symbols.
| context | Pointer to the aaruformat context (must be a valid, write-enabled image context). |
| data | Pointer to the media title string data in UTF-16LE encoding (opaque byte array). |
| length | Length of the media title data in bytes (must include full UTF-16LE character sequences). |
| AARUF_STATUS_OK | (0) Successfully set media title. This is returned when:
|
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context is invalid. This occurs when:
|
| AARUF_READ_ONLY | (-13) The context is not opened for writing. This occurs when:
|
| AARUF_ERROR_NOT_ENOUGH_MEMORY | (-8) Memory allocation failed. This occurs when:
|
Definition at line 720 of file metadata.c.
References AARU_MAGIC, AARUF_ERROR_NOT_AARUFORMAT, AARUF_ERROR_NOT_ENOUGH_MEMORY, AARUF_READ_ONLY, AARUF_STATUS_OK, FATAL, MetadataBlockHeader::identifier, aaruformat_context::is_writing, aaruformat_context::magic, aaruformat_context::media_title, MetadataBlockHeader::mediaTitleLength, aaruformat_context::metadata_block_header, MetadataBlock, and TRACE.
| int32_t aaruf_set_tape_file | ( | void * | context, |
| const uint8_t | partition, | ||
| const uint32_t | file, | ||
| const uint64_t | starting_block, | ||
| const uint64_t | ending_block ) |
Sets or updates the block range for a specific tape file in an Aaru tape image.
Creates or modifies a tape file entry in the context's hash table, defining the logical file's extent on the tape medium by its partition number, file number, and block range. This function is the write-mode counterpart to aaruf_get_tape_file() and is used when creating or modifying tape images to establish the file structure metadata.
Tape File Registration: When writing a tape image, this function should be called for each logical file to register its location. Each file is uniquely identified by:
These values are combined into a 64-bit composite key: key = (partition << 32) | file_number
The file entry (including the block range) is then stored in the context's tapeFiles hash table and will be written to the image's TapeFileBlock during finalization.
Block Range Definition: The block range [starting_block, ending_block] defines the file's extent:
Block addresses must be absolute positions within the tape image's logical block space. The caller is responsible for ensuring:
Typical Usage Flow:
Update/Replace Behavior: If a file entry with the same partition/file combination already exists:
This allows updating file metadata or correcting errors without manual deletion.
Error Handling: The function performs validation in the following order:
If any validation fails, an appropriate error code is returned and no modifications are made to the context's tape file table.
Thread Safety: This function modifies the shared context's hash table and is NOT thread-safe. Concurrent calls to aaruf_set_tape_file() or other functions that modify ctx->tapeFiles may result in data corruption or memory leaks. The caller must ensure exclusive access through external synchronization if needed.
Memory Management:
Performance Characteristics:
| context | Pointer to an initialized aaruformat context. Must not be NULL. The context must have been opened with write access (isWriting=true). The context's tapeFiles hash table will be updated with the new entry. |
| partition | The partition number (0-255) where the file is located. For single-partition tapes, this is typically 0. Multi-partition tapes can have files in different partitions with potentially overlapping file numbers. |
| file | The file number within the specified partition. File numbers are typically sequential (0, 1, 2, ...) but gaps are allowed. The same file number can exist in different partitions without conflict. |
| starting_block | The first block address of the file (inclusive). This should be the absolute block number in the image where the file's first byte begins. Must be <= ending_block (not validated). |
| ending_block | The last block address of the file (inclusive). This should be the absolute block number in the image where the file's last byte ends. Must be >= starting_block (not validated). |
| AARUF_STATUS_OK | (0) Successfully set tape file information. The hash table has been updated with the file entry. If an entry with the same partition/file combination existed, it has been replaced. The metadata will be written to the TapeFileBlock when the image is closed. |
| AARUF_ERROR_NOT_AARUFORMAT | (-1) Invalid context or context validation failed. This is returned when:
|
| AARUF_READ_ONLY | (-22) The context is not opened for writing. This is returned when ctx->isWriting is false, indicating the image was opened in read-only mode. Tape file metadata cannot be modified in read-only mode. No modifications are made to the context. |
| AARUF_ERROR_NOT_ENOUGH_MEMORY | (-9) Memory allocation failed. The system could not allocate memory for the hash table entry (tapeFileHashEntry). This is a critical error indicating low memory conditions. No modifications are made to the context. |
Definition at line 770 of file tape.c.
References AARU_MAGIC, AARUF_ERROR_NOT_AARUFORMAT, AARUF_ERROR_NOT_ENOUGH_MEMORY, AARUF_READ_ONLY, AARUF_STATUS_OK, FATAL, TapeFileEntry::File, TapeFileHashEntry::fileEntry, TapeFileEntry::FirstBlock, aaruformat_context::is_writing, TapeFileHashEntry::key, TapeFileEntry::LastBlock, aaruformat_context::magic, TapeFileEntry::Partition, aaruformat_context::tape_files, and TRACE.
| int32_t aaruf_set_tape_partition | ( | void * | context, |
| const uint8_t | partition, | ||
| const uint64_t | starting_block, | ||
| const uint64_t | ending_block ) |
Sets or updates the block range for a specific tape partition in an Aaru tape image.
Creates or modifies a tape partition entry in the context's hash table, defining the physical partition's extent on the tape medium by its partition number and block range. This function is the write-mode counterpart to aaruf_get_tape_partition() and is used when creating or modifying tape images to establish the partition structure metadata.
Tape Partition Registration: When writing a tape image, this function should be called for each physical partition to register its block range. Each partition is uniquely identified by its partition number (0-255), and most tapes have a single partition (partition 0), though formats like LTO, DLT, and AIT support multiple partitions.
The partition entry (including the block range) is stored in the context's tapePartitions hash table and will be written to the image's TapePartitionBlock during finalization.
Block Range Definition: The block range [starting_block, ending_block] defines the partition's extent:
Block addresses are local to each partition. The caller is responsible for ensuring:
Typical Usage Flow:
Update/Replace Behavior: If a partition entry with the same partition number already exists:
This allows updating partition metadata or correcting errors without manual deletion.
Error Handling: The function performs validation in the following order:
If any validation fails, an appropriate error code is returned and no modifications are made to the context's tape partition table.
Thread Safety: This function modifies the shared context's hash table and is NOT thread-safe. Concurrent calls to aaruf_set_tape_partition() or other functions that modify ctx->tapePartitions may result in data corruption or memory leaks. The caller must ensure exclusive access through external synchronization if needed.
Memory Management:
Performance Characteristics:
Partition Organization: Proper partition metadata is essential for:
| context | Pointer to an initialized aaruformat context. Must not be NULL. The context must have been opened with write access (isWriting=true). The context's tapePartitions hash table will be updated with the new entry. |
| partition | The partition number (0-255) to set. For single-partition tapes, this is typically 0. Multi-partition tapes use sequential numbers (0, 1, 2, ...) though the numbering scheme is format-specific. |
| starting_block | The first block address of the partition (inclusive). This defines where the partition begins in the tape's block address space. Often 0 for the first partition, but format-dependent. Must be <= ending_block (not validated). |
| ending_block | The last block address of the partition (inclusive). This defines where the partition ends in the tape's block address space. Must be >= starting_block (not validated). |
| AARUF_STATUS_OK | (0) Successfully set tape partition information. The hash table has been updated with the partition entry. If an entry with the same partition number existed, it has been replaced. The metadata will be written to the TapePartitionBlock when the image is closed. |
| AARUF_ERROR_NOT_AARUFORMAT | (-1) Invalid context or context validation failed. This is returned when:
|
| AARUF_READ_ONLY | (-22) The context is not opened for writing. This is returned when ctx->isWriting is false, indicating the image was opened in read-only mode. Tape partition metadata cannot be modified in read-only mode. No modifications are made to the context. |
| AARUF_ERROR_NOT_ENOUGH_MEMORY | (-9) Memory allocation failed. The system could not allocate memory for the hash table entry (TapePartitionHashEntry). This is a critical error indicating low memory conditions. No modifications are made to the context. |
Definition at line 1196 of file tape.c.
References AARU_MAGIC, AARUF_ERROR_NOT_AARUFORMAT, AARUF_ERROR_NOT_ENOUGH_MEMORY, AARUF_READ_ONLY, AARUF_STATUS_OK, FATAL, TapePartitionEntry::FirstBlock, aaruformat_context::is_writing, TapePartitionHashEntry::key, TapePartitionEntry::LastBlock, aaruformat_context::magic, TapePartitionEntry::Number, TapePartitionHashEntry::partitionEntry, aaruformat_context::tape_partitions, and TRACE.
| int32_t aaruf_set_tracks | ( | void * | context, |
| TrackEntry * | tracks, | ||
| const int | count ) |
Replace (or clear) the in-memory track table for an AaruFormat image context.
Copies an array of caller-provided TrackEntry structures into the internal context, replacing any previously stored track metadata. A CRC64 is recomputed over the new table and stored in the associated TracksHeader. Passing a count of 0 clears existing track information.
Typical usage:
Memory ownership:
Validation performed:
context must be non-NULL and reference aaruformatContext with magic == AARU_MAGIC.tracks must be non-NULL when count > 0.count must be >= 0. (Negative values produce AARUF_ERROR_INVALID_TRACK_FORMAT.)Concurrency & thread-safety:
Side effects:
Error handling & atomicity:
| context | Opaque pointer that MUST point to a valid aaruformatContext returned by an open/create call. |
| tracks | Pointer to an array of TrackEntry structures to copy. Must not be NULL if count > 0. Ignored (may be NULL) when count == 0. |
| count | Number of TrackEntry elements in tracks. If 0, existing tracks are cleared. Must be >= 0 and (recommended) <= UINT16_MAX. |
| AARUF_STATUS_OK | Success (tracks replaced or cleared). |
| AARUF_ERROR_NOT_AARUFORMAT | context is NULL or not a recognized libaaruformat context. |
| AARUF_ERROR_INVALID_TRACK_FORMAT | Invalid input (tracks NULL with count > 0, or count < 0). |
| AARUF_ERROR_NOT_ENOUGH_MEMORY | Memory allocation failed while copying tracks. |
Usage example (conceptual):
Definition at line 392 of file optical.c.
References AARU_MAGIC, aaruf_crc64_data(), AARUF_ERROR_INVALID_TRACK_FORMAT, AARUF_ERROR_NOT_AARUFORMAT, AARUF_ERROR_NOT_ENOUGH_MEMORY, AARUF_STATUS_OK, TracksHeader::crc64, aaruformat_context::data_tracks, TracksHeader::entries, FATAL, ImageInfo::HasPartitions, ImageInfo::HasSessions, TracksHeader::identifier, aaruformat_context::image_info, aaruformat_context::magic, aaruformat_context::number_of_data_tracks, TrackEntry::sequence, TRACE, aaruformat_context::track_entries, aaruformat_context::tracks_header, and TracksBlock.
| void aaruf_sha1_buffer | ( | const void * | data, |
| unsigned long | size, | ||
| unsigned char * | result ) |
Definition at line 155 of file sha1.c.
References AARU_CALL, AARU_EXPORT, aaruf_sha1_final(), aaruf_sha1_init(), and aaruf_sha1_update().
| void aaruf_sha1_final | ( | sha1_ctx * | ctx, |
| unsigned char * | result ) |
Definition at line 124 of file sha1.c.
References AARU_CALL, AARU_EXPORT, aaruf_sha1_update(), sha1_ctx::buffer, sha1_ctx::count, and sha1_ctx::state.
Referenced by aaruf_sha1_buffer(), and write_checksum_block().
| void aaruf_sha1_init | ( | sha1_ctx * | ctx | ) |
Definition at line 34 of file sha1.c.
References AARU_CALL, AARU_EXPORT, sha1_ctx::buffer, sha1_ctx::count, and sha1_ctx::state.
Referenced by aaruf_create(), and aaruf_sha1_buffer().
| void aaruf_sha1_update | ( | sha1_ctx * | ctx, |
| const void * | data, | ||
| unsigned long | size ) |
Definition at line 89 of file sha1.c.
References AARU_CALL, AARU_EXPORT, sha1_ctx::buffer, sha1_ctx::count, sha1_transform(), and sha1_ctx::state.
Referenced by aaruf_sha1_buffer(), aaruf_sha1_final(), aaruf_write_sector(), and aaruf_write_sector_long().
| void aaruf_sha256_buffer | ( | const void * | data, |
| unsigned long | size, | ||
| unsigned char * | result ) |
Definition at line 141 of file sha256.c.
References AARU_CALL, AARU_EXPORT, aaruf_sha256_final(), aaruf_sha256_init(), and aaruf_sha256_update().
| void aaruf_sha256_final | ( | sha256_ctx * | ctx, |
| unsigned char * | result ) |
Definition at line 115 of file sha256.c.
References AARU_CALL, AARU_EXPORT, aaruf_sha256_update(), sha256_ctx::bitcount, sha256_ctx::buffer, and sha256_ctx::state.
Referenced by aaruf_sha256_buffer(), and write_checksum_block().
| void aaruf_sha256_init | ( | sha256_ctx * | ctx | ) |
Definition at line 76 of file sha256.c.
References AARU_CALL, AARU_EXPORT, sha256_ctx::bitcount, sha256_ctx::buffer, and sha256_ctx::state.
Referenced by aaruf_create(), and aaruf_sha256_buffer().
| void aaruf_sha256_update | ( | sha256_ctx * | ctx, |
| const void * | data, | ||
| unsigned long | size ) |
Definition at line 90 of file sha256.c.
References AARU_CALL, AARU_EXPORT, sha256_ctx::bitcount, sha256_ctx::buffer, sha256_transform(), and sha256_ctx::state.
Referenced by aaruf_sha256_buffer(), aaruf_sha256_final(), aaruf_write_sector(), and aaruf_write_sector_long().
| int aaruf_spamsum_final | ( | spamsum_ctx * | ctx, |
| uint8_t * | result ) |
Definition at line 191 of file spamsum.c.
References AARU_CALL, AARU_EXPORT, b64, spamsum_ctx::bh, spamsum_ctx::bh_end, spamsum_ctx::bh_start, blockhash_ctx::d_len, blockhash_ctx::digest, FUZZY_MAX_RESULT, blockhash_ctx::h, blockhash_ctx::half_digest, blockhash_ctx::half_h, NUM_BLOCKHASHES, ROLL_SUM, SPAMSUM_LENGTH, and SSDEEP_BS.
Referenced by write_checksum_block().
| void aaruf_spamsum_free | ( | spamsum_ctx * | ctx | ) |
Frees a spamsum (fuzzy hash) context.
| ctx | Pointer to the spamsum context to free. |
Definition at line 75 of file spamsum.c.
References AARU_CALL, and AARU_EXPORT.
Referenced by cleanup_failed_create(), and write_checksum_block().
| spamsum_ctx * aaruf_spamsum_init | ( | void | ) |
Definition at line 37 of file spamsum.c.
References AARU_CALL, AARU_EXPORT, spamsum_ctx::bh, spamsum_ctx::bh_end, blockhash_ctx::h, blockhash_ctx::half_h, and HASH_INIT.
Referenced by aaruf_create().
| int aaruf_spamsum_update | ( | spamsum_ctx * | ctx, |
| const uint8_t * | data, | ||
| const uint32_t | len ) |
Updates the spamsum context with new data.
| ctx | Pointer to the spamsum context. |
| data | Pointer to the data to process. |
| len | Length of the data in bytes. |
Definition at line 59 of file spamsum.c.
References AARU_CALL, AARU_EXPORT, fuzzy_engine_step(), and spamsum_ctx::total_size.
Referenced by aaruf_write_sector(), and aaruf_write_sector_long().
| int32_t aaruf_verify_image | ( | void * | context | ) |
Verifies the integrity of an AaruFormat image file.
Checks the integrity of all blocks and deduplication tables in the image by validating CRC64 checksums for each indexed block. This function performs comprehensive verification of data blocks, DDT v1 and v2 tables, tracks blocks, and other structural components. It reads blocks in chunks to optimize memory usage during verification and supports version-specific CRC endianness handling.
| context | Pointer to the aaruformat context. |
| AARUF_STATUS_OK | (0) Successfully verified image integrity. This is returned when:
|
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context is invalid. This occurs when:
|
| AARUF_ERROR_CANNOT_READ_HEADER | (-6) Failed to read critical headers. This occurs when:
|
| AARUF_ERROR_CANNOT_READ_INDEX | (-4) Index processing or validation failed. This occurs when:
|
| AARUF_ERROR_NOT_ENOUGH_MEMORY | (-9) Memory allocation failed. This occurs when:
|
| AARUF_ERROR_CANNOT_READ_BLOCK | (-7) Block reading failed. This occurs when:
|
| AARUF_ERROR_INVALID_BLOCK_CRC | (-18) CRC verification failed. This occurs when:
|
Definition at line 130 of file verify.c.
References AARU_MAGIC, aaruf_crc64_final(), aaruf_crc64_free(), aaruf_crc64_init(), AARUF_ERROR_CANNOT_READ_BLOCK, AARUF_ERROR_CANNOT_READ_HEADER, AARUF_ERROR_CANNOT_READ_INDEX, AARUF_ERROR_INVALID_BLOCK_CRC, AARUF_ERROR_NOT_AARUFORMAT, AARUF_ERROR_NOT_ENOUGH_MEMORY, AARUF_STATUS_OK, AARUF_VERSION_V1, IndexEntry::blockType, bswap_64, BlockHeader::cmpCrc64, DdtHeader2::cmpCrc64, DdtHeader::cmpCrc64, BlockHeader::cmpLength, DdtHeader2::cmpLength, DdtHeader::cmpLength, TracksHeader::crc64, DataBlock, DeDuplicationTable, DeDuplicationTable2, TracksHeader::entries, FATAL, aaruformat_context::header, AaruHeaderV2::imageMajorVersion, aaruformat_context::imageStream, IndexBlock, IndexBlock2, IndexBlock3, AaruHeaderV2::indexOffset, aaruformat_context::magic, IndexEntry::offset, process_index_v1(), process_index_v2(), process_index_v3(), TRACE, TracksBlock, update_crc64_from_stream(), verify_index_v1(), verify_index_v2(), verify_index_v3(), and VERIFY_SIZE.
| int32_t aaruf_write_media_tag | ( | void * | context, |
| const uint8_t * | data, | ||
| const int32_t | type, | ||
| const uint32_t | length ) |
Writes a media tag to the AaruFormat image, storing medium-specific metadata and descriptors.
This function stores arbitrary media-specific metadata (media tags) in the AaruFormat image context for later serialization during image finalization. Media tags represent higher-level descriptors and metadata structures that characterize the storage medium beyond sector data, including disc information structures, lead-in/lead-out data, manufacturer identifiers, drive capabilities, and format-specific metadata. The function uses a hash table for efficient tag storage and retrieval, automatically replacing existing tags of the same type and managing memory for tag data.
Supported Media Tag Categories:
Optical Disc Metadata (CD/DVD/BD/HD DVD):
Recordable Media Structures:
Copy Protection and Security:
Device and Drive Information:
Flash and Solid-State Media:
Gaming Console Media:
Specialized Structures:
Data Processing Pipeline:
Memory Management Strategy:
Tag Type Identification: The type parameter accepts MediaTagType enumeration values (0-68) that identify the semantic meaning of the tag data. The library does not validate tag data structure or size against the type identifier - callers are responsible for providing correctly formatted tag data matching the declared type. Type values are preserved as-is and used during serialization to identify tag purpose during image reading.
Replacement Behavior: When a media tag of the same type already exists in the context:
Serialization and Persistence: Media tags written via this function are not immediately written to the image file. Instead, they are accumulated in the context's mediaTags hash table and serialized during aaruf_close() as part of the image finalization process. The serialization creates a metadata block in the image file that preserves all media tags with their type identifiers and data lengths.
Thread Safety and Concurrency: This function is NOT thread-safe. The context contains mutable shared state including:
Performance Considerations:
Typical Usage Scenarios:
Validation and Error Handling:
Data Format Requirements: The function accepts arbitrary binary data without format validation. Callers must ensure:
Integration with Image Creation Workflow: Media tags should typically be written after creating the image context (aaruf_create()) but before writing sector data. However, tags can be added or updated at any point during the writing process. Common workflow:
| context | Pointer to a valid aaruformatContext with magic == AARU_MAGIC opened for writing. Must be created via aaruf_create() and not yet closed. The context's isWriting flag must be true, indicating write mode is active. |
| data | Pointer to the media tag data buffer to write. Must be a valid non-NULL pointer to a buffer containing the complete tag data. The function performs a deep copy of this data, so the caller retains ownership and may free or modify the source buffer after this call returns. The data format must match the structure expected for the specified type parameter. |
| type | Integer identifier specifying the type of media tag (MediaTagType enumeration). Values range from 0 (CD_TOC) to 68 (CD_LeadIn). The type identifies the semantic meaning of the tag data and is preserved in the image file for interpretation during reading. The library does not validate that the data structure matches the declared type - caller responsibility to ensure correctness. |
| length | Length in bytes of the media tag data buffer. Must be greater than zero. Specifies how many bytes to copy from the data buffer. No maximum length enforced, but extremely large tags may cause memory allocation failures. |
| AARUF_STATUS_OK | (0) Successfully wrote the media tag. This is returned when:
|
| AARUF_ERROR_NOT_AARUFORMAT | (-1) Invalid context provided. This occurs when:
|
| AARUF_READ_ONLY | (-22) Attempting to write to read-only image. This occurs when:
|
| AARUF_ERROR_INCORRECT_DATA_SIZE | (-8) Invalid data or length parameters. This occurs when:
|
| AARUF_ERROR_NOT_ENOUGH_MEMORY | (-9) Memory allocation failed. This occurs when:
|
Definition at line 1780 of file write.c.
References AARU_MAGIC, AARUF_ERROR_INCORRECT_DATA_SIZE, AARUF_ERROR_NOT_AARUFORMAT, AARUF_ERROR_NOT_ENOUGH_MEMORY, AARUF_READ_ONLY, AARUF_STATUS_OK, mediaTagEntry::data, FATAL, aaruformat_context::is_writing, mediaTagEntry::length, aaruformat_context::magic, aaruformat_context::mediaTags, TRACE, and mediaTagEntry::type.
| int32_t aaruf_write_sector | ( | void * | context, |
| uint64_t | sector_address, | ||
| bool | negative, | ||
| const uint8_t * | data, | ||
| uint8_t | sector_status, | ||
| uint32_t | length ) |
Writes a sector to the AaruFormat image.
Writes the given data to the specified sector address in the image, with the given status and length. This function handles buffering data into blocks, automatically closing blocks when necessary (sector size changes or block size limits are reached), and managing the deduplication table (DDT) entries.
| context | Pointer to the aaruformat context. |
| sector_address | Logical sector address to write. |
| negative | Indicates if the sector address is negative. |
| data | Pointer to the data buffer to write. |
| sector_status | Status of the sector to write. |
| length | Length of the data buffer. |
| AARUF_STATUS_OK | (0) Successfully wrote the sector data. This is returned when:
|
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context is invalid. This occurs when:
|
| AARUF_READ_ONLY | (-22) Attempting to write to a read-only image. This occurs when:
|
| AARUF_ERROR_NOT_ENOUGH_MEMORY | (-9) Memory allocation failed. This occurs when:
|
| AARUF_ERROR_CANNOT_WRITE_BLOCK_HEADER | (-23) Failed to write block header to the image file. This can occur during automatic block closure when:
|
| AARUF_ERROR_CANNOT_WRITE_BLOCK_DATA | (-24) Failed to write block data to the image file. This can occur during automatic block closure when:
|
| AARUF_ERROR_CANNOT_SET_DDT_ENTRY | (-25) Failed to update the deduplication table (DDT) entry. This occurs when:
|
Definition at line 98 of file write.c.
References AARU_MAGIC, aaruf_close_current_block(), AARUF_ERROR_CANNOT_SET_DDT_ENTRY, AARUF_ERROR_NOT_AARUFORMAT, AARUF_ERROR_NOT_ENOUGH_MEMORY, AARUF_ERROR_SECTOR_OUT_OF_BOUNDS, aaruf_md5_update(), AARUF_READ_ONLY, aaruf_sha1_update(), aaruf_sha256_update(), aaruf_spamsum_update(), AARUF_STATUS_OK, Audio, aaruformat_context::blake3_context, aaruformat_context::calculating_blake3, aaruformat_context::calculating_md5, aaruformat_context::calculating_sha1, aaruformat_context::calculating_sha256, aaruformat_context::calculating_spamsum, BlockHeader::compression, aaruformat_context::compression_enabled, aaruformat_context::current_block_header, aaruformat_context::current_block_offset, aaruformat_context::current_track_type, Data, DataBlock, DdtHeader2::dataShift, aaruformat_context::deduplicate, TrackEntry::end, TracksHeader::entries, FATAL, Flac, BlockHeader::identifier, aaruformat_context::image_info, insert_map(), aaruformat_context::is_writing, JaguarCD, aaruformat_context::last_written_block, lookup_map(), Lzma, aaruformat_context::magic, aaruformat_context::md5_context, ImageInfo::MediaType, ImageInfo::MetadataMediaType, DdtHeader2::negative, aaruformat_context::next_block_position, None, OpticalDisc, DdtHeader2::overflow, aaruformat_context::rewinded, aaruformat_context::sector_hash_map, ImageInfo::Sectors, BlockHeader::sectorSize, TrackEntry::sequence, TrackEntry::session, set_ddt_entry_v2(), aaruformat_context::sha1_context, aaruformat_context::sha256_context, aaruformat_context::spamsum_context, TrackEntry::start, TRACE, aaruformat_context::track_entries, aaruformat_context::tracks_header, BlockHeader::type, TrackEntry::type, aaruformat_context::user_data_ddt_header, UserData, VideoNow, VideoNowColor, VideoNowXp, aaruformat_context::writing_buffer, aaruformat_context::writing_buffer_position, and aaruformat_context::writing_long.
Referenced by aaruf_write_sector_long().
| int32_t aaruf_write_sector_long | ( | void * | context, |
| uint64_t | sector_address, | ||
| bool | negative, | ||
| const uint8_t * | data, | ||
| uint8_t | sector_status, | ||
| uint32_t | length ) |
Writes a full ("long") raw sector from optical or block media, parsing structure and validating content.
This function processes complete raw sectors including structural metadata, error correction codes, and subchannel information. It is the primary entry point for ingesting raw sector data where the caller provides the complete sector including synchronization patterns, headers, user data, and error correction information. The function intelligently parses the sector structure based on media type and track information, validates correctness, and delegates user data writing to aaruf_write_sector().
Supported Media Types and Sector Formats:
Optical Disc Media (2352-byte sectors):
Block Media (512+ byte sectors with tags):
Data Processing Pipeline:
Memory Management Strategy:
Address Space Management: The function handles three logical address regions:
Sector Status Classification: Status codes stored in high nibble of mini-DDT entries:
Deduplication Integration: Long sector processing does not directly perform deduplication - this occurs in the delegated aaruf_write_sector() call for the extracted user data portion. The prefix/suffix/subheader metadata is stored separately and not subject to deduplication.
Hash Calculation Behavior:
Error Recovery and Validation:
Thread Safety and Concurrency: This function is NOT thread-safe. The context contains mutable shared state including:
Performance Considerations:
| context | Pointer to a valid aaruformatContext with magic == AARU_MAGIC opened for writing. |
| sector_address | Logical Block Address (LBA) for the sector. For negative regions, this is the negative-space address; for user/overflow regions, this is the standard 0-based LBA. |
| negative | true if sector_address refers to the negative (pre-gap) region; false for user or overflow regions. |
| data | Pointer to the complete raw sector buffer. Must contain:
|
| sector_status | Initial sector status hint from caller. May be overridden based on validation results when delegating to aaruf_write_sector(). |
| length | Length in bytes of the data buffer. Must be exactly 2352 for optical discs. For block media: 512 (no tags), 524 (Sony), 532 (Profile), or 536 (Priam). |
| AARUF_STATUS_OK | (0) Sector successfully processed and user data written. This occurs when:
|
| AARUF_ERROR_NOT_AARUFORMAT | (-1) Invalid context provided. This occurs when:
|
| AARUF_READ_ONLY | (-22) Attempting to write to read-only image. This occurs when:
|
| AARUF_ERROR_SECTOR_OUT_OF_BOUNDS | (-7) Sector address outside valid ranges. This occurs when:
|
| AARUF_ERROR_INCORRECT_DATA_SIZE | (-8) Invalid sector size for media type. This occurs when:
|
| AARUF_ERROR_NOT_ENOUGH_MEMORY | (-9) Memory allocation failed. This occurs when:
|
| AARUF_ERROR_INCORRECT_MEDIA_TYPE | (-26) Unsupported media type for long sectors. This occurs when:
|
| AARUF_ERROR_CANNOT_SET_DDT_ENTRY | (-25) DDT update failed. Propagated from aaruf_write_sector() when:
|
| AARUF_ERROR_CANNOT_WRITE_BLOCK_HEADER | (-23) Block header write failed. Propagated from aaruf_write_sector() when:
|
| AARUF_ERROR_CANNOT_WRITE_BLOCK_DATA | (-24) Block data write failed. Propagated from aaruf_write_sector() when:
|
Definition at line 532 of file write.c.
References AARU_MAGIC, aaruf_ecc_cd_is_suffix_correct(), aaruf_ecc_cd_is_suffix_correct_mode2(), aaruf_edc_cd_compute(), AARUF_ERROR_INCORRECT_DATA_SIZE, AARUF_ERROR_INCORRECT_MEDIA_TYPE, AARUF_ERROR_NOT_AARUFORMAT, AARUF_ERROR_NOT_ENOUGH_MEMORY, AARUF_ERROR_SECTOR_OUT_OF_BOUNDS, aaruf_md5_update(), AARUF_READ_ONLY, aaruf_sha1_update(), aaruf_sha256_update(), aaruf_spamsum_update(), aaruf_write_sector(), AppleFileWare, AppleProfile, AppleSonyDS, AppleSonySS, AppleWidget, Audio, aaruformat_context::blake3_context, BlockMedia, bytes_to_priam_tag(), bytes_to_profile_tag(), bytes_to_sony_tag(), aaruformat_context::calculating_blake3, aaruformat_context::calculating_md5, aaruformat_context::calculating_sha1, aaruformat_context::calculating_sha256, aaruformat_context::calculating_spamsum, CdMode1, CdMode2Form1, CdMode2Form2, CdMode2Formless, Data, DVDDownload, DVDPR, DVDPRDL, DVDPRW, DVDPRWDL, DVDR, DVDRAM, DVDRDL, DVDROM, DVDRW, DVDRWDL, aaruformat_context::ecc_cd_context, TrackEntry::end, TracksHeader::entries, FATAL, aaruformat_context::image_info, aaruformat_context::is_writing, aaruformat_context::last_written_block, aaruformat_context::magic, aaruformat_context::md5_context, ImageInfo::MediaType, ImageInfo::MetadataMediaType, aaruformat_context::mode2_subheaders, DdtHeader2::negative, Nuon, OpticalDisc, DdtHeader2::overflow, priam_tag_to_bytes(), priam_tag_to_profile(), priam_tag_to_sony(), PriamDataTower, profile_tag_to_bytes(), profile_tag_to_priam(), profile_tag_to_sony(), PS2DVD, PS3DVD, aaruformat_context::rewinded, SACD, aaruformat_context::sector_cpr_mai, aaruformat_context::sector_edc, aaruformat_context::sector_id, aaruformat_context::sector_ied, aaruformat_context::sector_prefix, aaruformat_context::sector_prefix_ddt2, aaruformat_context::sector_prefix_length, aaruformat_context::sector_prefix_offset, aaruformat_context::sector_subchannel, aaruformat_context::sector_suffix, aaruformat_context::sector_suffix_ddt2, aaruformat_context::sector_suffix_length, aaruformat_context::sector_suffix_offset, ImageInfo::Sectors, SectorStatusErrored, SectorStatusMode1Correct, SectorStatusMode2Form1Ok, SectorStatusMode2Form2NoCrc, SectorStatusMode2Form2Ok, SectorStatusNotDumped, TrackEntry::sequence, aaruformat_context::sha1_context, aaruformat_context::sha256_context, sony_tag_to_bytes(), sony_tag_to_priam(), sony_tag_to_profile(), aaruformat_context::spamsum_context, TrackEntry::start, TRACE, aaruformat_context::track_entries, aaruformat_context::tracks_header, TrackEntry::type, aaruformat_context::user_data_ddt_header, and aaruformat_context::writing_long.
| int32_t aaruf_write_sector_tag | ( | void * | context, |
| const uint64_t | sector_address, | ||
| const bool | negative, | ||
| const uint8_t * | data, | ||
| const size_t | length, | ||
| const int32_t | tag ) |
Writes per-sector tag data (auxiliary metadata) for a specific sector.
This function stores auxiliary metadata associated with individual sectors, such as CD subchannel data, DVD auxiliary fields, track metadata, or proprietary tag formats used by specific storage systems. Unlike media tags (which apply to the entire medium), sector tags are per-sector metadata that provide additional context, error correction, copy protection, or device-specific information for each individual sector.
The function validates the tag type against the media type, verifies the data size matches the expected length for that tag type, allocates buffers as needed, and stores the tag data at the appropriate offset within the tag buffer. Some tags (like track flags and ISRC) update track metadata rather than per-sector buffers.
Supported tag types and their characteristics:
Optical Disc (CD/DVD) Tags:
Block Media (Proprietary Format) Tags:
Sector addressing: The function supports both positive and negative sector addressing:
Buffer allocation: Tag buffers are allocated on-demand when the first tag of a given type is written. Buffers are sized to accommodate all sectors (negative + normal + overflow) and persist for the lifetime of the context. Memory is freed during aaruf_close().
| context | Pointer to the aaruformat context (must be a valid, write-enabled image context). |
| sector_address | The logical sector number to write the tag for. Must be within valid bounds for the image (0 to Sectors-1 for positive, 0 to negative-1 when using negative addressing). |
| negative | If true, sector_address refers to a negative (lead-in) sector; if false, it refers to a positive sector (main data or overflow area). |
| data | Pointer to the tag data to write. Must not be NULL. The data size must exactly match the expected size for the tag type. |
| length | Length of the tag data in bytes. Must match the required size for the tag type. |
| tag | Tag type identifier (from the tag enumeration). Determines which buffer to write to and the expected data size. |
| AARUF_STATUS_OK | (0) Successfully wrote sector tag. This is returned when:
|
| AARUF_ERROR_NOT_AARUFORMAT | (-1) The context is invalid. This occurs when:
|
| AARUF_READ_ONLY | (-13) The context is not opened for writing. This occurs when:
|
| AARUF_ERROR_SECTOR_OUT_OF_BOUNDS | (-4) Sector address is invalid. This occurs when:
|
| AARUF_ERROR_INCORRECT_DATA_SIZE | (-11) Invalid data or length. This occurs when:
|
| AARUF_ERROR_INCORRECT_MEDIA_TYPE | (-26) Invalid media type for tag. This occurs when:
|
| AARUF_ERROR_NOT_ENOUGH_MEMORY | (-8) Memory allocation failed. This occurs when:
|
| AARUF_ERROR_TRACK_NOT_FOUND | (-25) Track not found for sector. This occurs when:
|
| AARUF_ERROR_INVALID_TAG | (-27) Unsupported or unknown tag type. This occurs when:
|
Definition at line 2048 of file write.c.
References AARU_MAGIC, AARUF_ERROR_INCORRECT_DATA_SIZE, AARUF_ERROR_INCORRECT_MEDIA_TYPE, AARUF_ERROR_INVALID_TAG, AARUF_ERROR_NOT_AARUFORMAT, AARUF_ERROR_NOT_ENOUGH_MEMORY, AARUF_ERROR_SECTOR_OUT_OF_BOUNDS, AARUF_ERROR_TRACK_NOT_FOUND, AARUF_READ_ONLY, AARUF_STATUS_OK, AppleProfileTag, AppleSonyTag, BlockMedia, CdSectorSubchannel, CdTrackFlags, CdTrackIsrc, DvdCmi, DvdSectorEdc, DvdSectorIed, DvdSectorInformation, DvdSectorNumber, DvdTitleKeyDecrypted, TracksHeader::entries, FATAL, TrackEntry::flags, aaruformat_context::image_info, aaruformat_context::is_writing, TrackEntry::isrc, aaruformat_context::magic, ImageInfo::MetadataMediaType, DdtHeader2::negative, OpticalDisc, DdtHeader2::overflow, PriamDataTowerTag, aaruformat_context::sector_cpr_mai, aaruformat_context::sector_decrypted_title_key, aaruformat_context::sector_edc, aaruformat_context::sector_id, aaruformat_context::sector_ied, aaruformat_context::sector_subchannel, ImageInfo::Sectors, TrackEntry::start, TRACE, aaruformat_context::track_entries, aaruformat_context::tracks_header, and aaruformat_context::user_data_ddt_header.
|
inline |
Definition at line 84 of file spamsum.c.
References AARU_LOCAL, b64, spamsum_ctx::bh, spamsum_ctx::bh_start, blockhash_ctx::d_len, blockhash_ctx::digest, fuzzy_try_fork_blockhash(), fuzzy_try_reduce_blockhash(), blockhash_ctx::h, blockhash_ctx::half_digest, blockhash_ctx::half_h, HASH_INIT, roll_hash(), ROLL_SUM, SPAMSUM_LENGTH, SSDEEP_BS, and SUM_HASH.
Referenced by aaruf_spamsum_update().
|
inline |
Definition at line 175 of file spamsum.c.
References AARU_LOCAL, spamsum_ctx::bh, spamsum_ctx::bh_end, blockhash_ctx::d_len, blockhash_ctx::digest, blockhash_ctx::h, blockhash_ctx::half_digest, blockhash_ctx::half_h, and NUM_BLOCKHASHES.
Referenced by fuzzy_engine_step().
|
inline |
Definition at line 155 of file spamsum.c.
References AARU_LOCAL, spamsum_ctx::bh, spamsum_ctx::bh_end, spamsum_ctx::bh_start, blockhash_ctx::d_len, SPAMSUM_LENGTH, SSDEEP_BS, and spamsum_ctx::total_size.
Referenced by fuzzy_engine_step().
|
inline |
Definition at line 137 of file spamsum.c.
References AARU_LOCAL, roll_state::h1, roll_state::h2, roll_state::h3, roll_state::n, spamsum_ctx::roll, ROLLING_WINDOW, and roll_state::window.
Referenced by fuzzy_engine_step().