63 header.
length > UINT32_MAX)
85 TRACE(
"Entering recover_dpm_block(%p)", ctx);
89 uint8_t *recovered = NULL;
97 TRACE(
"Exiting recover_dpm_block() = AARUF_ERROR_CANNOT_READ_BLOCK");
106 memcpy(&header, recovered,
sizeof(
DpmHeader));
110 if(header.
length <= UINT32_MAX && size >= block_length &&
113 uint8_t *block = malloc(block_length);
119 memcpy(block, recovered, block_length);
131 TRACE(
"Exiting recover_dpm_block() = %d", status);
150 TRACE(
"Entering process_dpm_block(%p, %p)", ctx, entry);
154 FATAL(
"Invalid context or image stream.");
156 TRACE(
"Exiting process_dpm_block()");
163 FATAL(
"Could not seek to %" PRIu64
" as indicated by index entry...", entry->
offset);
165 TRACE(
"Exiting process_dpm_block()");
176 TRACE(
"Could not read DPM header, trying to recover it...");
179 TRACE(
"Exiting process_dpm_block()");
184 header.
length > UINT32_MAX)
186 TRACE(
"Incorrect DPM header at position %" PRIu64
", trying to recover it...", entry->
offset);
189 TRACE(
"Exiting process_dpm_block()");
194 uint8_t *block = malloc(block_length);
198 TRACE(
"Could not allocate memory for DPM block, continuing...");
200 TRACE(
"Exiting process_dpm_block()");
204 memcpy(block, &header,
sizeof(
DpmHeader));
209 TRACE(
"Could not read DPM block or it is corrupted, trying to recover it...");
213 TRACE(
"Exiting process_dpm_block()");
224 TRACE(
"Found DPM block at %" PRIu64
" with %u entries.", entry->
offset, header.
entries);
226 TRACE(
"Exiting process_dpm_block()");
uint64_t aaruf_crc64_data(const uint8_t *data, uint32_t len)
@ DataPositionMeasurementBlock
Block containing data position measurements (reserved / TODO).
int32_t ec_recover_meta_block(aaruformat_context *ctx, uint64_t block_offset, uint8_t **recovered_data, uint32_t *recovered_size)
Attempt to recover a metadata/media-tag block at a given file offset.
#define AARUF_STATUS_OK
Sector present and read without uncorrectable errors.
#define AARUF_ERROR_CANNOT_READ_BLOCK
Generic block read failure (seek/read error).
#define AARUF_ERROR_INCORRECT_DATA_SIZE
Data size does not match expected size.
#define AARUF_ERROR_INVALID_BLOCK_CRC
CRC64 mismatch indicating corruption.
uint64_t dpm_payload_length(const DpmHeader *header)
Computes the payload length a Data Position Measurement header describes.
static int aaruf_fseek(FILE *stream, aaru_off_t offset, int origin)
static aaru_off_t aaruf_ftell(FILE *stream)
void process_dpm_block(aaruformat_context *ctx, const IndexEntry *entry)
Processes a Data Position Measurement block from the image stream.
int32_t validate_dpm_block(const uint8_t *data, size_t length)
Validates a serialized Data Position Measurement block.
int32_t recover_dpm_block(aaruformat_context *ctx)
Recovers a damaged Data Position Measurement block with erasure coding.
A rotation calibration done while measuring.
uint64_t ImageSize
Size of the image payload in bytes (excludes headers/metadata).
Single index entry describing a block's type, (optional) data classification, and file offset.
uint64_t offset
Absolute byte offset in the image where the referenced block header begins.
Master context representing an open or in‑creation Aaru image.
size_t dpm_block_length
Length of dpm_block in bytes, 0 if not present.
uint64_t dpm_damaged_offset
Offset of a DPM block that failed to load, to recover it with erasure coding, or 0.
FILE * imageStream
Underlying FILE* stream (binary mode).
ImageInfo image_info
Exposed high-level image info summary.
uint8_t * dpm_block
Data Position Measurement block, header included.