|
libaaruformat 1.0
Aaru Data Preservation Suite - Format Library
|
#include <errno.h>#include <inttypes.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <aaruformat.h>#include "erasure_internal.h"#include "internal.h"#include "log.h"#include "utarray.h"Go to the source code of this file.
Functions | |
| static void | aaruf_set_open_error (const int error_code) |
| static void | cleanup_open_failure (aaruformat_context *ctx) |
| void * | aaruf_open (const char *filepath, const bool resume_mode, const char *options) |
| Opens an existing AaruFormat image file. | |
| void * aaruf_open | ( | const char * | filepath, |
| const bool | resume_mode, | ||
| const char * | options ) |
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 (and optionally writing in resume mode), 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.
Operational Modes:
Read-Only Mode (resume_mode = false):
Resume/Write Mode (resume_mode = true):
Index and Block Processing: The function processes all indexed blocks from the image:
Non-critical block processing errors are logged but don't prevent opening (logging only). Critical errors (especially DDT processing failures) cause the open operation to fail. Unknown block types are logged but silently ignored for forward compatibility.
| filepath | Path to the image file to open. Must be a valid readable path. When opening in resume mode (resume_mode=true), the file must also be writable. The file must contain a valid AaruFormat header and index. |
| resume_mode | Boolean flag controlling the operational mode:
|
| options | String with opening/resume options in key=value format, semicolon-separated. Used primarily in resume mode to configure checksum and compression parameters. Supported options (resume mode only):
|
| 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 236 of file open.c.
References AARU_CALL, AARU_EXPORT, AARU_HEADER_APP_NAME_LEN, AARU_MAGIC, AARU_RECOVERY_FOOTER_MAGIC, aaruf_close(), aaruf_crc64_data(), aaruf_ecc_cd_init(), AARUF_ERROR_CANNOT_CREATE_FILE, AARUF_ERROR_CANNOT_READ_INDEX, AARUF_ERROR_FILE_TOO_SMALL, AARUF_ERROR_INCOMPATIBLE_FEATURES, AARUF_ERROR_INCOMPATIBLE_VERSION, AARUF_ERROR_NOT_AARUFORMAT, AARUF_ERROR_NOT_ENOUGH_MEMORY, aaruf_finalize_write(), aaruf_fseek(), aaruf_ftell(), aaruf_get_xml_mediatype(), AARUF_KNOWN_INCOMPAT_FEATURES, AARUF_KNOWN_ROCOMPAT_FEATURES, aaruf_open(), aaruf_set_open_error(), AARUF_STATUS_OK, AARUF_VERSION, AARUF_VERSION_V2, AaruMetadataJsonBlock, ImageInfo::Application, AaruHeaderV2::application, AaruHeaderV2::applicationMajorVersion, AaruHeaderV2::applicationMinorVersion, ImageInfo::ApplicationVersion, AaruRecoveryFooter::backupHeader, AaruHeaderV2::biggestSectorSize, aaruformat_context::block_cache, aaruformat_context::block_header_cache, AaruHeaderV2::blockAlignmentShift, DdtHeader2::blockAlignmentShift, BlockMedia, DdtHeader2::blocks, IndexEntry::blockType, CacheHeader::cache, ChecksumBlock, CicmBlock, cleanup_open_failure(), aaru_options::compress, aaruformat_context::compression_enabled, create_map(), ImageInfo::CreationTime, AaruHeaderV2::creationTime, CacheHeader::cur_bytes, aaruformat_context::cylinders, DataBlock, DataPositionMeasurementBlock, IndexEntry::dataType, aaru_options::deduplicate, aaruformat_context::deduplicate, DeDuplicationTable, DeDuplicationTable2, DIC_MAGIC, aaru_options::dictionary, DumpHardwareBlock, ec_load_ecmb(), aaruformat_context::ecc_cd_context, FATAL, AaruHeaderV2::featureCompatibleRo, AaruHeaderV2::featureIncompatible, aaruformat_context::finalize_write, FluxDataBlock, AaruRecoveryFooter::footerMagic, CacheHeader::free_func, aaruformat_context::geometry_block, GeometryBlock, get_filetime_uint64(), aaruformat_context::header, AaruRecoveryFooter::headerCrc64, aaruformat_context::heads, AaruHeaderV2::identifier, GeometryBlockHeader::identifier, aaruformat_context::image_info, AaruHeaderV2::imageMajorVersion, AaruHeaderV2::imageMinorVersion, ImageInfo::ImageSize, aaruformat_context::imageStream, aaruformat_context::index_entries, IndexBlock, IndexBlock2, IndexBlock3, AaruHeaderV2::indexOffset, aaruformat_context::is_writing, kDataTypeCdSectorPrefix, kDataTypeCdSectorPrefixCorrected, kDataTypeCdSectorSuffix, kDataTypeCdSectorSuffixCorrected, kDataTypeUserData, kSectorTagCdEcc, kSectorTagCdEccP, kSectorTagCdEccQ, kSectorTagCdEdc, kSectorTagCdHeader, kSectorTagCdSubHeader, kSectorTagCdSync, ImageInfo::LastModificationTime, AaruHeaderV2::lastWrittenTime, LIBAARUFORMAT_MAJOR_VERSION, LIBAARUFORMAT_MINOR_VERSION, aaruformat_context::library_major_version, aaruformat_context::library_minor_version, aaruformat_context::lzma_dict_size, aaruformat_context::magic, CacheHeader::max_bytes, MAX_CACHE_SIZE, MAX_HEADER_CACHE_SIZE, MaxSectorTag, ImageInfo::MediaType, AaruHeaderV2::mediaType, MetadataBlock, ImageInfo::MetadataMediaType, aaruformat_context::next_block_position, aaruformat_context::no_user_data_ddt, IndexEntry::offset, parse_options(), process_aaru_metadata_json_block(), process_checksum_block(), process_cicm_block(), process_data_block(), process_ddt_v1(), process_ddt_v2(), process_dpm_block(), 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, aaruformat_context::rewinded, aaruformat_context::sector_hash_map, aaruformat_context::sector_prefix_length, aaruformat_context::sector_prefix_offset, aaruformat_context::sector_suffix_length, aaruformat_context::sector_suffix_offset, ImageInfo::Sectors, aaruformat_context::sectors_per_track, ImageInfo::SectorSize, TapeFileBlock, TapePartitionBlock, TRACE, TracksBlock, aaruformat_context::user_data_ddt_header, and ImageInfo::Version.
Referenced by aaruf_open().
|
inlinestatic |
Definition at line 36 of file open.c.
References aaruf_set_open_error().
Referenced by aaruf_open(), and aaruf_set_open_error().
|
static |
Definition at line 44 of file open.c.
References cleanup_open_failure(), aaruformat_context::imageStream, and aaruformat_context::readableSectorTags.
Referenced by aaruf_open(), and cleanup_open_failure().