81 bool has_cached_secondary_ddt =
86 TRACE(
"Writing cached secondary DDT table to file");
93 if(end_of_file & alignment_mask)
96 uint64_t aligned_position = end_of_file + alignment_mask & ~alignment_mask;
99 fseek(ctx->
imageStream, aligned_position, SEEK_SET);
100 end_of_file = aligned_position;
102 TRACE(
"Aligned DDT write position from %ld to %" PRIu64
" (alignment shift: %d)",
103 ftell(ctx->
imageStream) - (aligned_position - end_of_file), aligned_position,
122 ddt_header.
blocks = items_per_ddt_entry;
123 ddt_header.
entries = items_per_ddt_entry;
127 ddt_header.
length = items_per_ddt_entry *
sizeof(uint64_t);
131 if(crc64_context != NULL)
137 ddt_header.
crc64 = crc64;
140 uint8_t *buffer = NULL;
150 buffer = malloc((
size_t)ddt_header.
length * 2);
153 TRACE(
"Failed to allocate memory for secondary DDT v2 compression");
157 size_t dst_size = (size_t)ddt_header.
length * 2 * 2;
164 ddt_header.
cmpLength = (uint32_t)dst_size;
193 const uint64_t new_secondary_table_block_offset =
199 TRACE(
"Updating index for cached secondary DDT");
208 for(
unsigned int k = 0; k < utarray_len(ctx->
index_entries); k++)
214 TRACE(
"Found old DDT index entry at position %u, removing", k);
225 new_ddt_entry.
offset = end_of_file;
229 TRACE(
"Added new DDT index entry at offset %" PRIu64, end_of_file);
237 size_t primary_written_bytes = 0;
240 if(primary_written_bytes != 1)
242 TRACE(
"Could not flush primary DDT table to file.");
249 TRACE(
"Failed to write cached secondary DDT data");
252 TRACE(
"Failed to write cached secondary DDT header");
289 TRACE(
"Writing cached primary DDT table back to file");
293 if(crc64_context != NULL)
313 TRACE(
"Calculated CRC64 for primary DDT: 0x%16lX", crc64);
320 if(headerWritten != 1)
322 TRACE(
"Failed to write primary DDT header to file");
330 size_t written_bytes = 0;
333 if(written_bytes == 1)
335 TRACE(
"Successfully wrote primary DDT header and table to file (%" PRIu64
" entries, %zu bytes)",
339 TRACE(
"Removing any previously existing primary DDT index entries");
340 for(
int k = utarray_len(ctx->
index_entries) - 1; k >= 0; k--)
345 TRACE(
"Found existing primary DDT index entry at position %d, removing", k);
351 TRACE(
"Adding primary DDT to index");
362 TRACE(
"Failed to write primary DDT table to file");
388 TRACE(
"Writing single-level DDT table to file");
409 uint8_t *cmp_buffer = NULL;
421 if(cmp_buffer == NULL)
423 TRACE(
"Failed to allocate memory for secondary DDT v2 compression");
460 if(ddt_position & alignment_mask)
462 const uint64_t aligned_position = ddt_position + alignment_mask & ~alignment_mask;
463 fseek(ctx->
imageStream, aligned_position, SEEK_SET);
464 ddt_position = aligned_position;
468 if(header_written != 1)
470 TRACE(
"Failed to write single-level DDT header to file");
475 size_t written_bytes = 0;
481 if(written_bytes == 1)
483 TRACE(
"Successfully wrote single-level DDT header and table to file (%" PRIu64
484 " entries, %zu bytes, %zu compressed bytes)",
488 TRACE(
"Removing any previously existing single-level DDT index entries");
489 for(
int k = utarray_len(ctx->
index_entries) - 1; k >= 0; k--)
494 TRACE(
"Found existing single-level DDT index entry at position %d, removing", k);
500 TRACE(
"Adding single-level DDT to index");
504 single_ddt_entry.
offset = ddt_position;
508 TRACE(
"Added single-level DDT index entry at offset %" PRIu64, ddt_position);
511 TRACE(
"Failed to write single-level DDT table data to file");
628 uint64_t max_key = 0;
630 HASH_ITER(hh, ctx->
tape_ddt, entry, tmp)
631 if(entry->
key > max_key) max_key = entry->
key;
653 TRACE(
"Failed to allocate memory for tape DDT table");
658 HASH_ITER(hh, ctx->
tape_ddt, entry, tmp)
683 uint64_t alignment_mask;
684 uint64_t aligned_position;
720 if(!has_checksums)
return;
729 if(checksum_position & alignment_mask)
731 aligned_position = checksum_position + alignment_mask & ~alignment_mask;
732 fseek(ctx->
imageStream, aligned_position, SEEK_SET);
733 checksum_position = aligned_position;
737 fseek(ctx->
imageStream,
sizeof(checksum_header), SEEK_CUR);
741 TRACE(
"Writing MD5 checksum entry");
753 TRACE(
"Writing SHA1 checksum entry");
765 TRACE(
"Writing SHA256 checksum entry");
777 TRACE(
"Writing SpamSum checksum entry");
789 TRACE(
"Writing BLAKE3 checksum entry");
791 blake3_entry.
length = BLAKE3_OUT_LEN;
800 fseek(ctx->
imageStream, checksum_position, SEEK_SET);
801 TRACE(
"Writing checksum header");
805 TRACE(
"Removing any previously existing checksum block index entries");
806 for(
int k = utarray_len(ctx->
index_entries) - 1; k >= 0; k--)
811 TRACE(
"Found existing checksum block index entry at position %d, removing", k);
817 TRACE(
"Adding checksum block to index");
821 checksum_index_entry.
offset = checksum_position;
823 utarray_push_back(ctx->
index_entries, &checksum_index_entry);
825 TRACE(
"Added checksum block index entry at offset %" PRIu64, checksum_position);
847 if(tracks_position & alignment_mask)
849 uint64_t aligned_position = tracks_position + alignment_mask & ~alignment_mask;
850 fseek(ctx->
imageStream, aligned_position, SEEK_SET);
851 tracks_position = aligned_position;
854 TRACE(
"Writing tracks block at position %ld", tracks_position);
859 size_t written_entries =
867 TRACE(
"Removing any previously existing tracks block index entries");
868 for(
int k = utarray_len(ctx->
index_entries) - 1; k >= 0; k--)
873 TRACE(
"Found existing tracks block index entry at position %d, removing", k);
879 TRACE(
"Adding tracks block to index");
884 tracks_index_entry.
offset = tracks_position;
887 TRACE(
"Added tracks block index entry at offset %" PRIu64, tracks_position);
910 long mode2_subheaders_position = ftell(ctx->
imageStream);
913 if(mode2_subheaders_position & alignment_mask)
915 uint64_t aligned_position = mode2_subheaders_position + alignment_mask & ~alignment_mask;
916 fseek(ctx->
imageStream, aligned_position, SEEK_SET);
917 mode2_subheaders_position = aligned_position;
920 TRACE(
"Writing MODE 2 subheaders block at position %ld", mode2_subheaders_position);
932 uint8_t *buffer = NULL;
942 buffer = malloc((
size_t)subheaders_block.
length * 2);
945 TRACE(
"Failed to allocate memory for MODE 2 subheaders compression");
949 size_t dst_size = (size_t)subheaders_block.
length * 2 * 2;
954 subheaders_block.
cmpLength = (uint32_t)dst_size;
972 const size_t length_to_write = subheaders_block.
cmpLength;
981 const size_t written_bytes = fwrite(buffer, length_to_write, 1, ctx->
imageStream);
982 if(written_bytes == 1)
984 TRACE(
"Successfully wrote MODE 2 subheaders block (%" PRIu64
" bytes)", subheaders_block.
cmpLength);
987 TRACE(
"Removing any previously existing MODE 2 subheaders block index entries");
988 for(
int k = utarray_len(ctx->
index_entries) - 1; k >= 0; k--)
993 TRACE(
"Found existing MODE 2 subheaders block index entry at position %d, removing", k);
999 TRACE(
"Adding MODE 2 subheaders block to index");
1003 mode2_subheaders_index_entry.
offset = mode2_subheaders_position;
1004 utarray_push_back(ctx->
index_entries, &mode2_subheaders_index_entry);
1006 TRACE(
"Added MODE 2 subheaders block index entry at offset %" PRIu64, mode2_subheaders_position);
1043 if(prefix_position & alignment_mask)
1045 uint64_t aligned_position = prefix_position + alignment_mask & ~alignment_mask;
1046 fseek(ctx->
imageStream, aligned_position, SEEK_SET);
1047 prefix_position = aligned_position;
1050 TRACE(
"Writing sector prefix block at position %ld", prefix_position);
1060 uint8_t *buffer = NULL;
1070 buffer = malloc((
size_t)prefix_block.
length * 2);
1073 TRACE(
"Failed to allocate memory for CD sector prefix compression");
1077 size_t dst_size = (size_t)prefix_block.
length * 2 * 2;
1082 prefix_block.
cmpLength = (uint32_t)dst_size;
1100 const size_t length_to_write = prefix_block.
cmpLength;
1109 const size_t written_bytes = fwrite(buffer, length_to_write, 1, ctx->
imageStream);
1110 if(written_bytes == 1)
1112 TRACE(
"Successfully wrote CD sector prefix block (%" PRIu64
" bytes)", prefix_block.
cmpLength);
1115 TRACE(
"Removing any previously existing CD sector prefix block index entries");
1116 for(
int k = utarray_len(ctx->
index_entries) - 1; k >= 0; k--)
1121 TRACE(
"Found existing CD sector prefix block index entry at position %d, removing", k);
1127 TRACE(
"Adding CD sector prefix block to index");
1131 prefix_index_entry.
offset = prefix_position;
1134 TRACE(
"Added CD sector prefix block index entry at offset %" PRIu64, prefix_position);
1180 if(suffix_position & alignment_mask)
1182 const uint64_t aligned_position = suffix_position + alignment_mask & ~alignment_mask;
1183 fseek(ctx->
imageStream, aligned_position, SEEK_SET);
1184 suffix_position = aligned_position;
1187 TRACE(
"Writing sector suffix block at position %ld", suffix_position);
1197 uint8_t *buffer = NULL;
1207 buffer = malloc((
size_t)suffix_block.
length * 2);
1210 TRACE(
"Failed to allocate memory for CD sector suffix compression");
1214 size_t dst_size = (size_t)suffix_block.
length * 2 * 2;
1219 suffix_block.
cmpLength = (uint32_t)dst_size;
1237 const size_t length_to_write = suffix_block.
cmpLength;
1246 const size_t written_bytes = fwrite(buffer, length_to_write, 1, ctx->
imageStream);
1247 if(written_bytes == 1)
1249 TRACE(
"Successfully wrote CD sector suffix block (%" PRIu64
" bytes)", suffix_block.
cmpLength);
1252 TRACE(
"Removing any previously existing CD sector suffix block index entries");
1253 for(
int k = utarray_len(ctx->
index_entries) - 1; k >= 0; k--)
1258 TRACE(
"Found existing CD sector suffix block index entry at position %d, removing", k);
1264 TRACE(
"Adding CD sector suffix block to index");
1268 suffix_index_entry.
offset = suffix_position;
1271 TRACE(
"Added CD sector suffix block index entry at offset %" PRIu64, suffix_position);
1310 long prefix_ddt_position = ftell(ctx->
imageStream);
1313 if(prefix_ddt_position & alignment_mask)
1315 const uint64_t aligned_position = prefix_ddt_position + alignment_mask & ~alignment_mask;
1316 fseek(ctx->
imageStream, aligned_position, SEEK_SET);
1317 prefix_ddt_position = aligned_position;
1320 TRACE(
"Writing sector prefix DDT v2 at position %ld", prefix_ddt_position);
1335 ddt_header2.
start = 0;
1336 ddt_header2.
length = ddt_header2.
entries *
sizeof(uint64_t);
1340 uint8_t *buffer = NULL;
1350 buffer = malloc((
size_t)ddt_header2.
length * 2);
1353 TRACE(
"Failed to allocate memory for sector prefix DDT v2 compression");
1357 size_t dst_size = (size_t)ddt_header2.
length * 2 * 2;
1360 lzma_properties, &props_size, 9, ctx->
lzma_dict_size, 4, 0, 2, 273, 8);
1362 ddt_header2.
cmpLength = (uint32_t)dst_size;
1380 const size_t length_to_write = ddt_header2.
cmpLength;
1389 const size_t written_bytes = fwrite(buffer, length_to_write, 1, ctx->
imageStream);
1390 if(written_bytes == 1)
1392 TRACE(
"Successfully wrote sector prefix DDT v2 (%" PRIu64
" bytes)", ddt_header2.
cmpLength);
1395 TRACE(
"Removing any previously existing sector prefix DDT v2 index entries");
1396 for(
int k = utarray_len(ctx->
index_entries) - 1; k >= 0; k--)
1401 TRACE(
"Found existing sector prefix DDT v2 index entry at position %d, removing", k);
1407 TRACE(
"Adding sector prefix DDT v2 to index");
1411 prefix_ddt_index_entry.
offset = prefix_ddt_position;
1412 utarray_push_back(ctx->
index_entries, &prefix_ddt_index_entry);
1414 TRACE(
"Added sector prefix DDT v2 index entry at offset %" PRIu64, prefix_ddt_position);
1469 long suffix_ddt_position = ftell(ctx->
imageStream);
1472 if(suffix_ddt_position & alignment_mask)
1474 const uint64_t aligned_position = suffix_ddt_position + alignment_mask & ~alignment_mask;
1475 fseek(ctx->
imageStream, aligned_position, SEEK_SET);
1476 suffix_ddt_position = aligned_position;
1479 TRACE(
"Writing sector suffix DDT v2 at position %ld", suffix_ddt_position);
1494 ddt_header2.
start = 0;
1495 ddt_header2.
length = ddt_header2.
entries *
sizeof(uint64_t);
1499 uint8_t *buffer = NULL;
1509 buffer = malloc((
size_t)ddt_header2.
length * 2);
1512 TRACE(
"Failed to allocate memory for sector suffix DDT v2 compression");
1516 size_t dst_size = (size_t)ddt_header2.
length * 2 * 2;
1519 lzma_properties, &props_size, 9, ctx->
lzma_dict_size, 4, 0, 2, 273, 8);
1521 ddt_header2.
cmpLength = (uint32_t)dst_size;
1539 const size_t length_to_write = ddt_header2.
cmpLength;
1548 const size_t written_bytes = fwrite(buffer, length_to_write, 1, ctx->
imageStream);
1549 if(written_bytes == 1)
1551 TRACE(
"Successfully wrote sector suffix DDT v2 (%" PRIu64
" bytes)", ddt_header2.
cmpLength);
1554 TRACE(
"Removing any previously existing sector suffix DDT v2 block index entries");
1555 for(
int k = utarray_len(ctx->
index_entries) - 1; k >= 0; k--)
1560 TRACE(
"Found existing sector suffix DDT v2 index entry at position %d, removing", k);
1566 TRACE(
"Adding sector suffix DDT v2 to index");
1570 suffix_ddt_index_entry.
offset = suffix_ddt_position;
1571 utarray_push_back(ctx->
index_entries, &suffix_ddt_index_entry);
1573 TRACE(
"Added sector suffix DDT v2 index entry at offset %" PRIu64, suffix_ddt_position);
1645 if(block_position & alignment_mask)
1647 const uint64_t aligned_position = block_position + alignment_mask & ~alignment_mask;
1648 fseek(ctx->
imageStream, aligned_position, SEEK_SET);
1649 block_position = aligned_position;
1652 TRACE(
"Writing sector subchannel block at position %ld", block_position);
1658 bool owns_buffer =
false;
1671 uint8_t *cst_buffer = malloc(subchannel_block.
length);
1673 if(cst_buffer == NULL)
1675 TRACE(
"Failed to allocate memory for Claunia Subchannel Transform output");
1679 uint8_t *dst_buffer = malloc(subchannel_block.
length);
1681 if(dst_buffer == NULL)
1683 TRACE(
"Failed to allocate memory for LZMA output");
1689 size_t dst_size = subchannel_block.
length;
1697 if(dst_size < subchannel_block.
length)
1700 subchannel_block.
cmpLength = (uint32_t)dst_size;
1701 buffer = dst_buffer;
1731 TRACE(
"Incorrect media type, not writing sector subchannel block");
1737 uint8_t *dst_buffer = malloc(subchannel_block.
length);
1739 if(dst_buffer == NULL)
1741 TRACE(
"Failed to allocate memory for LZMA output");
1745 size_t dst_size = subchannel_block.
length;
1749 lzma_properties, &props_size, 9, ctx->
lzma_dict_size, 4, 0, 2, 273, 8);
1751 if(dst_size < subchannel_block.
length)
1753 subchannel_block.
cmpLength = (uint32_t)dst_size;
1754 buffer = dst_buffer;
1766 TRACE(
"Incorrect media type, not writing sector subchannel block");
1777 const size_t length_to_write = subchannel_block.
cmpLength;
1786 const size_t written_bytes = fwrite(buffer, length_to_write, 1, ctx->
imageStream);
1787 if(written_bytes == 1)
1789 TRACE(
"Successfully wrote sector subchannel block (%" PRIu64
" bytes)", subchannel_block.
cmpLength);
1792 TRACE(
"Removing any previously existing subchannel block index entries");
1793 for(
int k = utarray_len(ctx->
index_entries) - 1; k >= 0; k--)
1798 TRACE(
"Found existing subchannel block index entry at position %d, removing", k);
1804 TRACE(
"Adding sector subchannel block to index");
1807 subchannel_index_entry.
dataType = subchannel_block.
type;
1808 subchannel_index_entry.
offset = block_position;
1809 utarray_push_back(ctx->
index_entries, &subchannel_index_entry);
1811 TRACE(
"Added sector subchannel block index entry at offset %" PRIu64, block_position);
1815 if(owns_buffer) free(buffer);
1959 uint64_t total_sectors =
1966 if(id_position & alignment_mask)
1968 const uint64_t aligned_position = id_position + alignment_mask & ~alignment_mask;
1969 fseek(ctx->
imageStream, aligned_position, SEEK_SET);
1970 id_position = aligned_position;
1972 TRACE(
"Writing DVD sector ID block at position %ld", id_position);
1977 id_block.
length = (uint32_t)total_sectors * 4;
1982 uint8_t *buffer = NULL;
1992 buffer = malloc((
size_t)id_block.
length * 2);
1995 TRACE(
"Failed to allocate memory for DVD sector ID compression");
1999 size_t dst_size = (size_t)id_block.
length * 2 * 2;
2004 id_block.
cmpLength = (uint32_t)dst_size;
2022 size_t length_to_write = id_block.
cmpLength;
2031 const size_t written_bytes = fwrite(buffer, length_to_write, 1, ctx->
imageStream);
2032 if(written_bytes == 1)
2034 TRACE(
"Successfully wrote DVD sector ID block (%" PRIu64
" bytes)", id_block.
cmpLength);
2037 TRACE(
"Removing any previously existing DVD sector ID block index entries");
2038 for(
int k = utarray_len(ctx->
index_entries) - 1; k >= 0; k--)
2043 TRACE(
"Found existing DVD sector ID block index entry at position %d, removing", k);
2049 TRACE(
"Adding DVD sector ID block to index");
2053 id_index_entry.
offset = id_position;
2056 TRACE(
"Added DVD sector ID block index entry at offset %" PRIu64, id_position);
2065 if(ied_position & alignment_mask)
2067 const uint64_t aligned_position = ied_position + alignment_mask & ~alignment_mask;
2068 fseek(ctx->
imageStream, aligned_position, SEEK_SET);
2069 ied_position = aligned_position;
2071 TRACE(
"Writing DVD sector IED block at position %ld", ied_position);
2076 ied_block.
length = (uint32_t)total_sectors * 2;
2089 buffer = malloc((
size_t)ied_block.
length * 2);
2092 TRACE(
"Failed to allocate memory for DVD sector IED compression");
2096 size_t dst_size = (size_t)ied_block.
length * 2 * 2;
2101 ied_block.
cmpLength = (uint32_t)dst_size;
2128 const size_t written_bytes = fwrite(buffer, length_to_write, 1, ctx->
imageStream);
2129 if(written_bytes == 1)
2131 TRACE(
"Successfully wrote DVD sector IED block (%" PRIu64
" bytes)", ied_block.
cmpLength);
2134 TRACE(
"Removing any previously existing DVD sector IED block index entries");
2135 for(
int k = utarray_len(ctx->
index_entries) - 1; k >= 0; k--)
2140 TRACE(
"Found existing DVD sector IED block index entry at position %d, removing", k);
2146 TRACE(
"Adding DVD sector IED block to index");
2150 ied_index_entry.
offset = ied_position;
2153 TRACE(
"Added DVD sector IED block index entry at offset %" PRIu64, ied_position);
2162 if(cpr_mai_position & alignment_mask)
2164 const uint64_t aligned_position = cpr_mai_position + alignment_mask & ~alignment_mask;
2165 fseek(ctx->
imageStream, aligned_position, SEEK_SET);
2166 cpr_mai_position = aligned_position;
2168 TRACE(
"Writing DVD sector CPR/MAI block at position %ld", cpr_mai_position);
2173 cpr_mai_block.
length = (uint32_t)total_sectors * 6;
2186 buffer = malloc((
size_t)cpr_mai_block.
length * 2);
2189 TRACE(
"Failed to allocate memory for DVD sector CPR/MAI compression");
2193 size_t dst_size = (size_t)cpr_mai_block.
length * 2 * 2;
2198 cpr_mai_block.
cmpLength = (uint32_t)dst_size;
2216 length_to_write = cpr_mai_block.
cmpLength;
2225 const size_t written_bytes = fwrite(buffer, length_to_write, 1, ctx->
imageStream);
2226 if(written_bytes == 1)
2228 TRACE(
"Successfully wrote DVD sector CPR/MAI block (%" PRIu64
" bytes)", cpr_mai_block.
cmpLength);
2231 TRACE(
"Removing any previously existing DVD sector CPR/MAI block index entries");
2232 for(
int k = utarray_len(ctx->
index_entries) - 1; k >= 0; k--)
2237 TRACE(
"Found existing DVD sector CPR/MAI block index entry at position %d, removing", k);
2243 TRACE(
"Adding DVD sector CPR/MAI block to index");
2247 cpr_mai_index_entry.
offset = cpr_mai_position;
2248 utarray_push_back(ctx->
index_entries, &cpr_mai_index_entry);
2250 TRACE(
"Added DVD sector CPR/MAI block index entry at offset %" PRIu64, cpr_mai_position);
2259 if(edc_position & alignment_mask)
2261 const uint64_t aligned_position = edc_position + alignment_mask & ~alignment_mask;
2262 fseek(ctx->
imageStream, aligned_position, SEEK_SET);
2263 edc_position = aligned_position;
2265 TRACE(
"Writing DVD sector EDC block at position %ld", edc_position);
2270 edc_block.
length = (uint32_t)total_sectors * 4;
2283 buffer = malloc((
size_t)edc_block.
length * 2);
2286 TRACE(
"Failed to allocate memory for DVD sector EDC compression");
2290 size_t dst_size = (size_t)edc_block.
length * 2 * 2;
2295 edc_block.
cmpLength = (uint32_t)dst_size;
2322 const size_t written_bytes = fwrite(buffer, length_to_write, 1, ctx->
imageStream);
2323 if(written_bytes == 1)
2325 TRACE(
"Successfully wrote DVD sector EDC block (%" PRIu64
" bytes)", edc_block.
cmpLength);
2328 TRACE(
"Removing any previously existing DVD sector EDC block index entries");
2329 for(
int k = utarray_len(ctx->
index_entries) - 1; k >= 0; k--)
2334 TRACE(
"Found existing DVD sector EDC block index entry at position %d, removing", k);
2340 TRACE(
"Adding DVD sector EDC block to index");
2344 edc_index_entry.
offset = edc_position;
2347 TRACE(
"Added DVD sector EDC block index entry at offset %" PRIu64, edc_position);
2458 if(block_position & alignment_mask)
2460 const uint64_t aligned_position = block_position + alignment_mask & ~alignment_mask;
2461 fseek(ctx->
imageStream, aligned_position, SEEK_SET);
2462 block_position = aligned_position;
2464 TRACE(
"Writing DVD decrypted title key block at position %ld", block_position);
2469 decrypted_title_key_block.
length =
2473 decrypted_title_key_block.
crc64 =
2476 uint8_t *buffer = NULL;
2482 decrypted_title_key_block.
cmpCrc64 = decrypted_title_key_block.
crc64;
2486 buffer = malloc((
size_t)decrypted_title_key_block.
length * 2);
2489 TRACE(
"Failed to allocate memory for DVD decrypted title key compression");
2493 size_t dst_size = (size_t)decrypted_title_key_block.
length * 2 * 2;
2496 lzma_properties, &props_size, 9, ctx->
lzma_dict_size, 4, 0, 2, 273, 8);
2498 decrypted_title_key_block.
cmpLength = (uint32_t)dst_size;
2500 if(decrypted_title_key_block.
cmpLength >= decrypted_title_key_block.
length)
2510 decrypted_title_key_block.
cmpLength = decrypted_title_key_block.
length;
2511 decrypted_title_key_block.
cmpCrc64 = decrypted_title_key_block.
crc64;
2516 const size_t length_to_write = decrypted_title_key_block.
cmpLength;
2526 const size_t written_bytes = fwrite(buffer, length_to_write, 1, ctx->
imageStream);
2527 if(written_bytes == 1)
2529 TRACE(
"Successfully wrote DVD decrypted title key block (%" PRIu64
" bytes)",
2533 TRACE(
"Removing any previously existing DVD decrypted title key block index entries");
2534 for(
int k = utarray_len(ctx->
index_entries) - 1; k >= 0; k--)
2539 TRACE(
"Found existing DVD decrypted title key block index entry at position %d, removing", k);
2545 TRACE(
"Adding DVD decrypted title key block to index");
2549 decrypted_title_key_index_entry.
offset = block_position;
2550 utarray_push_back(ctx->
index_entries, &decrypted_title_key_index_entry);
2552 TRACE(
"Added DVD decrypted title key block index entry at offset %" PRIu64, block_position);
2637 HASH_ITER(hh, ctx->
mediaTags, media_tag, tmp_media_tag)
2642 if(tag_position & alignment_mask)
2644 const uint64_t aligned_position = tag_position + alignment_mask & ~alignment_mask;
2645 fseek(ctx->
imageStream, aligned_position, SEEK_SET);
2646 tag_position = aligned_position;
2660 uint8_t *buffer = NULL;
2665 buffer = media_tag->
data;
2670 buffer = malloc((
size_t)tag_block.
length * 2);
2673 TRACE(
"Failed to allocate memory for media tag compression");
2677 size_t dst_size = (size_t)tag_block.
length * 2 * 2;
2682 tag_block.
cmpLength = (uint32_t)dst_size;
2688 buffer = media_tag->
data;
2700 const size_t length_to_write = tag_block.
cmpLength;
2709 const size_t written_bytes = fwrite(buffer, length_to_write, 1, ctx->
imageStream);
2710 if(written_bytes == 1)
2712 TRACE(
"Successfully wrote media tag block type %d (%" PRIu64
" bytes)", tag_block.
type,
2716 TRACE(
"Removing any previously existing media tag type %d block index entries", tag_block.
type);
2717 for(
int k = utarray_len(ctx->
index_entries) - 1; k >= 0; k--)
2722 TRACE(
"Found existing media tag type %d block index entry at position %d, removing",
2729 TRACE(
"Adding media tag type %d block to index", tag_block.
type);
2733 tag_index_entry.
offset = tag_position;
2736 TRACE(
"Added media tag block type %d index entry at offset %" PRIu64, tag_block.
type, tag_position);
2913 size_t tape_file_count = 0;
2914 HASH_ITER(hh, ctx->
tape_files, tape_file, tmp_tape_file) tape_file_count++;
2917 const size_t buffer_size = tape_file_count *
sizeof(
TapeFileEntry);
2921 TRACE(
"Failed to allocate memory for tape file entries");
2924 memset(buffer, 0, buffer_size);
2926 HASH_ITER(hh, ctx->
tape_files, tape_file, tmp_tape_file)
2928 if(index >= tape_file_count)
break;
2936 tape_file_block.
length = (uint32_t)buffer_size;
2943 if(block_position & alignment_mask)
2945 const uint64_t aligned_position = block_position + alignment_mask & ~alignment_mask;
2946 fseek(ctx->
imageStream, aligned_position, SEEK_SET);
2947 block_position = aligned_position;
2949 TRACE(
"Writing tape file block at position %ld", block_position);
2952 const size_t written_bytes = fwrite(buffer, tape_file_block.
length, 1, ctx->
imageStream);
2953 if(written_bytes == 1)
2955 TRACE(
"Successfully wrote tape file block (%" PRIu64
" bytes)", tape_file_block.
length);
2958 TRACE(
"Removing any previously existing tape file block index entries");
2959 for(
int k = utarray_len(ctx->
index_entries) - 1; k >= 0; k--)
2964 TRACE(
"Found existing tape file block index entry at position %d, removing", k);
2970 TRACE(
"Adding tape file block to index");
2974 index_entry.
offset = block_position;
2977 TRACE(
"Added tape file block index entry at offset %" PRIu64, block_position);
3159 size_t tape_partition_count = 0;
3160 HASH_ITER(hh, ctx->
tape_partitions, tape_partition, tmp_tape_partition) tape_partition_count++;
3167 TRACE(
"Failed to allocate memory for tape partition entries");
3170 memset(buffer, 0, buffer_size);
3172 HASH_ITER(hh, ctx->
tape_partitions, tape_partition, tmp_tape_partition)
3174 if(index >= tape_partition_count)
break;
3182 tape_partition_block.
length = (uint32_t)buffer_size;
3189 if(block_position & alignment_mask)
3191 const uint64_t aligned_position = block_position + alignment_mask & ~alignment_mask;
3192 fseek(ctx->
imageStream, aligned_position, SEEK_SET);
3193 block_position = aligned_position;
3195 TRACE(
"Writing tape partition block at position %ld", block_position);
3198 const size_t written_bytes = fwrite(buffer, tape_partition_block.
length, 1, ctx->
imageStream);
3199 if(written_bytes == 1)
3201 TRACE(
"Successfully wrote tape partition block (%" PRIu64
" bytes)", tape_partition_block.
length);
3204 TRACE(
"Removing any previously existing tape partition block index entries");
3205 for(
int k = utarray_len(ctx->
index_entries) - 1; k >= 0; k--)
3210 TRACE(
"Found existing tape partition block index entry at position %d, removing", k);
3216 TRACE(
"Adding tape partition block to index");
3220 index_entry.
offset = block_position;
3223 TRACE(
"Added tape partition block index entry at offset %" PRIu64, block_position);
3298 if(block_position & alignment_mask)
3300 const uint64_t aligned_position = block_position + alignment_mask & ~alignment_mask;
3301 fseek(ctx->
imageStream, aligned_position, SEEK_SET);
3302 block_position = aligned_position;
3305 TRACE(
"Writing geometry block at position %ld", block_position);
3310 TRACE(
"Successfully wrote geometry block");
3313 TRACE(
"Removing any previously existing geometry block index entries");
3314 for(
int k = utarray_len(ctx->
index_entries) - 1; k >= 0; k--)
3319 TRACE(
"Found existing geometry block index entry at position %d, removing", k);
3325 TRACE(
"Adding geometry block to index");
3329 index_entry.
offset = block_position;
3332 TRACE(
"Added geometry block index entry at offset %" PRIu64, block_position);
3464 if(buffer == NULL)
return;
3552 if(block_position & alignment_mask)
3554 const uint64_t aligned_position = block_position + alignment_mask & ~alignment_mask;
3555 fseek(ctx->
imageStream, aligned_position, SEEK_SET);
3556 block_position = aligned_position;
3561 TRACE(
"Writing metadata block at position %ld", block_position);
3565 TRACE(
"Successfully wrote metadata block");
3568 TRACE(
"Removing any previously existing metadata block index entries");
3569 for(
int k = utarray_len(ctx->
index_entries) - 1; k >= 0; k--)
3574 TRACE(
"Found existing metadata block index entry at position %d, removing", k);
3580 TRACE(
"Adding metadata block to index");
3584 index_entry.
offset = block_position;
3587 TRACE(
"Added metadata block index entry at offset %" PRIu64, block_position);
3747 uint8_t *buffer = calloc(1, required_length);
3749 if(buffer == NULL)
return;
3766 if(offset + entry_size > required_length)
3768 FATAL(
"Calculated size exceeds provided buffer length");
3850 if(block_position & alignment_mask)
3852 const uint64_t aligned_position = block_position + alignment_mask & ~alignment_mask;
3853 fseek(ctx->
imageStream, aligned_position, SEEK_SET);
3854 block_position = aligned_position;
3856 TRACE(
"Writing dump hardware block at position %ld", block_position);
3857 if(fwrite(buffer, required_length, 1, ctx->
imageStream) == 1)
3859 TRACE(
"Successfully wrote dump hardware block");
3862 TRACE(
"Removing any previously existing dump hardware block index entries");
3863 for(
int k = utarray_len(ctx->
index_entries) - 1; k >= 0; k--)
3868 TRACE(
"Found existing dump hardware block index entry at position %d, removing", k);
3874 TRACE(
"Adding dump hardware block to index");
3878 index_entry.
offset = block_position;
3881 TRACE(
"Added dump hardware block index entry at offset %" PRIu64, block_position);
3990 if(block_position & alignment_mask)
3992 const uint64_t aligned_position = block_position + alignment_mask & ~alignment_mask;
3993 fseek(ctx->
imageStream, aligned_position, SEEK_SET);
3994 block_position = aligned_position;
3997 TRACE(
"Writing CICM XML block at position %ld", block_position);
4001 TRACE(
"Successfully wrote CICM XML block");
4004 TRACE(
"Removing any previously existing CICM XML block index entries");
4005 for(
int k = utarray_len(ctx->
index_entries) - 1; k >= 0; k--)
4010 TRACE(
"Found existing CICM XML block index entry at position %d, removing", k);
4016 TRACE(
"Adding CICM XML block to index");
4020 index_entry.
offset = block_position;
4023 TRACE(
"Added CICM XML block index entry at offset %" PRIu64, block_position);
4141 if(block_position & alignment_mask)
4143 const uint64_t aligned_position = block_position + alignment_mask & ~alignment_mask;
4144 fseek(ctx->
imageStream, aligned_position, SEEK_SET);
4145 block_position = aligned_position;
4148 TRACE(
"Writing Aaru metadata JSON block at position %ld", block_position);
4152 TRACE(
"Successfully wrote Aaru metadata JSON block");
4155 TRACE(
"Removing any previously existing Aaru metadata JSON block index entries");
4156 for(
int k = utarray_len(ctx->
index_entries) - 1; k >= 0; k--)
4161 TRACE(
"Found existing Aaru metadata JSON block index entry at position %d, removing", k);
4167 TRACE(
"Adding Aaru metadata JSON block to index");
4171 index_entry.
offset = block_position;
4174 TRACE(
"Added Aaru metadata JSON block index entry at offset %" PRIu64, block_position);
4197 TRACE(
"Writing index at the end of the file");
4203 if(index_position & alignment_mask)
4205 uint64_t aligned_position = index_position + alignment_mask & ~alignment_mask;
4206 fseek(ctx->
imageStream, aligned_position, SEEK_SET);
4207 index_position = aligned_position;
4208 TRACE(
"Aligned index position to %" PRIu64, aligned_position);
4217 TRACE(
"Writing index with %" PRIu64
" entries at position %ld", index_header.
entries, index_position);
4221 if(index_crc64_context != NULL && index_header.
entries > 0)
4226 TRACE(
"Calculated index CRC64: 0x%16lX", index_header.
crc64);
4229 index_header.
crc64 = 0;
4234 TRACE(
"Successfully wrote index header");
4239 size_t entries_written = 0;
4247 TRACE(
"Wrote index entry: blockType=0x%08X dataType=%u offset=%" PRIu64, entry->
blockType,
4252 TRACE(
"Failed to write index entry %zu", entries_written);
4256 if(entries_written == index_header.
entries)
4258 TRACE(
"Successfully wrote all %zu index entries", entries_written);
4267 TRACE(
"Successfully updated header with index offset");
4270 TRACE(
"Failed to update header with index offset");
4276 TRACE(
"Failed to write all index entries (wrote %zu of %" PRIu64
")", entries_written,
4284 TRACE(
"Failed to write index header");
4329 TRACE(
"Entering aaruf_close(%p)", context);
4336 FATAL(
"Invalid context");
4346 FATAL(
"Invalid context");
4353 TRACE(
"File is writing");
4355 TRACE(
"Seeking to start of image");
4359 TRACE(
"Writing header at position 0");
4369 TRACE(
"Closing current block if any");
4474 TRACE(
"Clearing sector hash map");
4481 TRACE(
"Freeing memory pointers");
4509 TRACE(
"Freeing media tags");
4513 free(media_tag->
data);
4518 TRACE(
"Unmapping user data DDT if it is not in memory");
4586 TRACE(
"Exiting aaruf_close() = 0");
void write_dvd_long_sector_blocks(aaruformat_context *ctx)
Serialize DVD long sector auxiliary data blocks to the image file.
static int32_t write_primary_ddt(aaruformat_context *ctx)
Write (flush) the multi-level primary DDT table header and data back to its file offset.
static void write_cicm_block(aaruformat_context *ctx)
Serialize the CICM XML metadata block to the image file.
static void write_sector_subchannel(aaruformat_context *ctx)
Serialize the per-sector subchannel or tag data block.
static int32_t write_index_block(aaruformat_context *ctx)
Serialize the accumulated index entries at the end of the image and back-patch the header.
static void write_media_tags(aaruformat_context *ctx)
Serialize all accumulated media tags to the image file.
static void write_dvd_title_key_decrypted_block(aaruformat_context *ctx)
Serialize the DVD decrypted title key data block to the image file.
int aaruf_close(void *context)
Close an Aaru image context, flushing pending data structures and releasing resources.
static int32_t write_single_level_ddt(aaruformat_context *ctx)
Serialize a single-level DDT (tableShift == 0) directly after its header.
static void write_tape_file_block(aaruformat_context *ctx)
Serialize the tape file metadata block to the image file.
static void write_dumphw_block(aaruformat_context *ctx)
Serialize the dump hardware block containing acquisition environment information.
static void write_checksum_block(aaruformat_context *ctx)
Finalize any active checksum calculations and append a checksum block.
static void write_sector_suffix(aaruformat_context *ctx)
Serialize the optional CD sector suffix block (EDC/ECC region capture).
static void write_sector_suffix_ddt(aaruformat_context *ctx)
Serialize the per-sector CD suffix status / index DeDuplication Table (DDT v2, suffix variant).
static void write_tracks_block(aaruformat_context *ctx)
Serialize the tracks metadata block and add it to the index.
static void write_aaru_json_block(aaruformat_context *ctx)
Serialize the Aaru metadata JSON block to the image file.
static void write_geometry_block(aaruformat_context *ctx)
Serialize the geometry metadata block to the image file.
static void write_mode2_subheaders_block(aaruformat_context *ctx)
Serialize a MODE 2 (XA) subheaders data block.
static void write_tape_partition_block(aaruformat_context *ctx)
Serialize the tape partition metadata block to the image file.
static void write_sector_prefix_ddt(aaruformat_context *ctx)
Serialize the per-sector CD prefix status / index DeDuplication Table (DDT v2, prefix variant).
static int32_t write_tape_ddt(aaruformat_context *ctx)
Converts tape DDT hash table to array format and writes it as a single-level DDT.
static int32_t write_cached_secondary_ddt(aaruformat_context *ctx)
Flush a cached secondary (child) DeDuplication Table (DDT) to the image.
static void write_metadata_block(aaruformat_context *ctx)
Serialize the metadata block containing image and media descriptive information.
static void write_sector_prefix(aaruformat_context *ctx)
Serialize the optional CD sector prefix block.
#define LZMA_PROPERTIES_LENGTH
Size in bytes of the fixed LZMA properties header (lc/lp/pb + dictionary size).
#define AARU_MAGIC
Magic identifier for AaruFormat container (ASCII "AARUFRMT").
#define MD5_DIGEST_LENGTH
struct TapeFileHashEntry tapeFileHashEntry
void aaruf_sha1_final(sha1_ctx *ctx, unsigned char *result)
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_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.
uint64_t aaruf_crc64_data(const uint8_t *data, uint32_t len)
int aaruf_crc64_update(crc64_ctx *ctx, const uint8_t *data, uint32_t len)
Updates the CRC64 context with new data.
void aaruf_sha256_final(sha256_ctx *ctx, unsigned char *result)
crc64_ctx * aaruf_crc64_init()
Initializes a CRC64 context.
void aaruf_md5_final(md5_ctx *ctx, unsigned char *result)
void aaruf_spamsum_free(spamsum_ctx *ctx)
Frees a spamsum (fuzzy hash) context.
int32_t aaruf_get_datatype_for_media_tag_type(int32_t tag_type)
Converts an Aaru media tag type to an image data type.
int aaruf_spamsum_final(spamsum_ctx *ctx, uint8_t *result)
int aaruf_crc64_final(crc64_ctx *ctx, uint64_t *crc)
Computes the final CRC64 value from the context.
@ IndexBlock3
Block containing the index v3.
@ ChecksumBlock
Block containing contents checksums.
@ DataBlock
Block containing data.
@ TapePartitionBlock
Block containing list of partitions for a tape image.
@ GeometryBlock
Block containing logical geometry.
@ DeDuplicationTableSecondary
Block containing a secondary deduplication table (v2).
@ AaruMetadataJsonBlock
Block containing JSON version of Aaru Metadata.
@ CicmBlock
Block containing CICM XML metadata.
@ DeDuplicationTable2
Block containing a deduplication table v2.
@ TapeFileBlock
Block containing list of files for a tape image.
@ DumpHardwareBlock
Block containing an array of hardware used to create the image.
@ MetadataBlock
Block containing metadata.
@ TracksBlock
Block containing optical disc tracks.
@ OpticalDisc
Purely optical discs.
@ BlockMedia
Media that is physically block-based or abstracted like that.
@ SpamSum
SpamSum (context-triggered piecewise hash).
@ CdSectorSubchannel
Compact Disc subchannel data.
@ AppleProfileTag
Apple Profile (20‑byte) tag.
@ DvdSectorIed
DVD ID Error Detection Code (IED)
@ DvdSectorCprMai
DVD Copyright Management Information (CPR_MAI)
@ AppleSonyTag
Apple Sony (12‑byte) tag.
@ CdSectorPrefix
Compact Disc sector prefix (sync, header).
@ PriamDataTowerTag
Priam Data Tower (24‑byte) tag.
@ UserData
User (main) data.
@ DvdSectorEdc
DVD Error Detection Code (EDC)
@ DvdSectorTitleKeyDecrypted
Decrypted DVD Title Key.
@ DvdSectorId
DVD Identification Data (ID)
@ CdSectorSuffix
Compact Disc sector suffix (EDC, ECC P, ECC Q).
@ CompactDiscMode2Subheader
Compact Disc MODE 2 subheader.
@ AARU_FEATURE_RW_BLAKE3
BLAKE3 checksum is present (read/write support for BLAKE3 hashes).
@ AARUF_STATUS_INVALID_CONTEXT
Provided context/handle is invalid.
@ LzmaClauniaSubchannelTransform
LZMA applied to Claunia Subchannel Transform processed data.
#define AARUF_STATUS_OK
Sector present and read without uncorrectable errors.
#define AARUF_ERROR_NOT_ENOUGH_MEMORY
Memory allocation failure (critical).
#define AARUF_ERROR_CANNOT_WRITE_HEADER
Failure writing container header.
void free_map(hash_map_t *map)
Frees all memory associated with a hash map.
int32_t aaruf_close_current_block(aaruformat_context *ctx)
Finalizes and writes the current data block to the AaruFormat image file.
#define SHA1_DIGEST_LENGTH
#define SHA256_DIGEST_LENGTH
Per-checksum metadata immediately followed by the digest / signature bytes.
uint32_t length
Length in bytes of the digest that immediately follows this structure.
uint8_t type
Algorithm used (value from ChecksumAlgorithm).
uint8_t * spamsum
SpamSum fuzzy hash (ASCII), allocated length+1 with trailing 0.
bool hasSha256
True if sha256[] buffer populated.
uint8_t sha1[20]
SHA-1 digest (20 bytes).
uint8_t sha256[32]
SHA-256 digest (32 bytes).
uint8_t md5[16]
MD5 digest (16 bytes).
bool hasSpamSum
True if spamsum pointer allocated and signature read.
bool hasSha1
True if sha1[] buffer populated.
uint8_t blake3[BLAKE3_OUT_LEN]
BLAKE3 digest (32 bytes).
bool hasMd5
True if md5[] buffer populated.
bool hasBlake3
True if blake3[] buffer populated.
Inclusive [start,end] logical sector range contributed by a single hardware environment.
uint8_t * firmware
Firmware version string or NULL.
uint8_t * revision
Hardware revision string or NULL.
uint8_t * model
Model string or NULL.
uint8_t * softwareName
Dump software name or NULL.
struct DumpExtent * extents
Array of extents (entry.extents elements) or NULL.
uint8_t * manufacturer
Manufacturer string (UTF-8) or NULL.
uint8_t * softwareVersion
Dump software version or NULL.
uint8_t * serial
Serial number string or NULL.
DumpHardwareEntry entry
Fixed-size header with lengths & counts.
uint8_t * softwareOperatingSystem
Host operating system string or NULL.
Per-environment length table describing subsequent UTF-8 strings and optional extent array.
uint32_t softwareNameLength
Length in bytes of dumping software name string.
uint32_t manufacturerLength
Length in bytes of manufacturer UTF-8 string.
uint32_t softwareVersionLength
Length in bytes of dumping software version string.
uint32_t firmwareLength
Length in bytes of firmware version string.
uint32_t extents
Number of DumpExtent records following the strings (0 = none).
uint32_t modelLength
Length in bytes of model UTF-8 string.
uint32_t serialLength
Length in bytes of device serial number string.
uint32_t revisionLength
Length in bytes of revision / hardware revision string.
uint32_t softwareOperatingSystemLength
Length in bytes of host operating system string.
uint32_t MediaType
Media type identifier (see MediaType enum; 0=Unknown)
uint8_t MetadataMediaType
Media type for sidecar generation (internal archival use)
uint64_t Sectors
Total count of addressable logical sectors/blocks.
Single index entry describing a block's type, (optional) data classification, and file offset.
uint32_t blockType
Block identifier of the referenced block (value from BlockType).
uint64_t offset
Absolute byte offset in the image where the referenced block header begins.
uint16_t dataType
Data classification (value from DataType) or unused for untyped blocks.
uint64_t key
Key: sector address.
uint64_t value
Value: DDT entry.
Describes a single logical file on a tape medium.
TapeFileEntry fileEntry
The actual tape file data.
Describes a single physical partition on a tape medium.
TapePartitionEntry partitionEntry
The actual tape partition data.
Single optical disc track descriptor (sequence, type, LBAs, session, ISRC, flags).
Master context representing an open or in‑creation Aaru image.
uint8_t * media_barcode
Barcode of the media represented by the image.
DdtHeader2 user_data_ddt_header
Active user data DDT v2 header (primary table meta).
Checksums checksums
Whole-image checksums discovered.
uint8_t * creator
Who (person) created the image?
bool dirty_checksum_block
True if checksum block should be written during close.
bool deduplicate
Storage deduplication active (duplicates coalesce).
bool compression_enabled
True if block compression enabled (writing path).
uint8_t * cicm_block
CICM XML payload.
uint8_t * sector_cpr_mai
DVD sector CPR_MAI (6 bytes) if present.
bool dirty_media_tags
True if media tags should be written during close.
hash_map_t * sector_hash_map
Deduplication hash map (fingerprint->entry mapping).
uint8_t * sector_prefix_corrected
Corrected variant (post error correction) if stored.
uint64_t * user_data_ddt
Legacy flat DDT pointer (NULL when using v2 mini/big arrays).
sha256_ctx sha256_context
Opaque SHA-256 context for streaming updates.
bool calculating_sha256
True if whole-image SHA-256 being calculated on-the-fly.
bool dirty_primary_ddt
True if primary DDT table should be written during close.
uint8_t * drive_firmware_revision
Firmware revision of the drive used to read the media represented by the image.
uint8_t * media_serial_number
Serial number of the media represented by the image.
uint8_t * sector_ied
DVD sector IED (2 bytes) if present.
md5_ctx md5_context
Opaque MD5 context for streaming updates.
bool dirty_sector_suffix_block
True if sector suffix block should be written during close.
uint64_t * user_data_ddt2
DDT entries (big variant) primary/secondary current.
MetadataBlockHeader metadata_block_header
Metadata block header.
uint8_t * sector_prefix
Raw per-sector prefix (e.g., sync+header) uncorrected.
bool dirty_dvd_title_key_decrypted_block
True if decrypted title key block should be written during close.
uint64_t * sector_suffix_ddt2
CD sector suffix DDT V2.
tapeFileHashEntry * tape_files
Hash table root for tape files.
bool dirty_mode2_subheaders_block
True if MODE2 subheader block should be written during close.
bool dirty_tape_partition_block
True if tape partition block should be written during close.
uint64_t cached_ddt_offset
File offset of currently cached secondary DDT (0=none).
bool dirty_cicm_block
True if CICM metadata block should be written during close.
bool is_tape
True if the image is a tape image.
uint8_t * sector_edc
DVD sector EDC (4 bytes) if present.
bool calculating_sha1
True if whole-image SHA-1 being calculated on-the-fly.
uint8_t * media_model
Model of the media represented by the image.
bool dirty_tracks_block
True if tracks block should be written during close.
uint8_t * drive_serial_number
Serial number of the drive used to read the media represented by the image.
CdEccContext * ecc_cd_context
CD ECC/EDC helper tables (allocated on demand).
uint32_t * sector_suffix_ddt
Legacy CD sector suffix DDT.
bool dirty_sector_prefix_block
True if sector prefix block should be written during close.
uint8_t * drive_manufacturer
Manufacturer of the drive used to read the media represented by the image.
bool in_memory_ddt
True if primary (and possibly secondary) DDT loaded.
bool dirty_index_block
True if index block should be written during close.
uint8_t * sector_suffix
Raw per-sector suffix (EDC/ECC) uncorrected.
AaruHeaderV2 header
Parsed container header (v2).
bool dirty_json_block
True if JSON metadata block should be written during close.
bool is_writing
True if context opened/created for writing.
TapeDdtHashEntry * tape_ddt
Hash table root for tape DDT entries.
spamsum_ctx * spamsum_context
Opaque SpamSum context for streaming updates.
CicmMetadataBlock cicm_block_header
CICM metadata header (if present).
size_t sector_prefix_offset
Current position in sector_prefix.
uint8_t * drive_model
Model of the drive used to read the media represented by the image.
bool dirty_single_level_ddt
True if single-level DDT should be written during close.
uint64_t magic
File magic (AARU_MAGIC) post-open.
uint8_t * writing_buffer
Accumulation buffer for current block data.
uint64_t * sector_prefix_ddt2
CD sector prefix DDT V2.
bool calculating_spamsum
True if whole-image SpamSum being calculated on-the-fly.
uint64_t primary_ddt_offset
File offset of the primary DDT v2 table.
mediaTagEntry * mediaTags
Hash table of extra media tags (uthash root).
blake3_hasher * blake3_context
Opaque BLAKE3 context for streaming updates.
bool calculating_blake3
True if whole-image BLAKE3 being calculated on-the-fly.
struct DumpHardwareEntriesWithData * dump_hardware_entries_with_data
Array of dump hardware entries + strings.
bool calculating_md5
True if whole-image MD5 being calculated on-the-fly.
bool dirty_sector_suffix_ddt
True if sector suffix DDT should be written during close.
GeometryBlockHeader geometry_block
Logical geometry block (if present).
size_t sector_suffix_offset
Current position in sector_suffix.
uint64_t * cached_secondary_ddt2
Cached secondary table (big entries) or NULL.
uint8_t * json_block
JSON metadata block payload (UTF-8).
uint8_t * media_part_number
Part number of the media represented by the image.
uint8_t * sector_decrypted_title_key
DVD decrypted title key (5 bytes) if present.
bool dirty_dumphw_block
True if dump hardware block should be written during close.
AaruMetadataJsonBlockHeader json_block_header
JSON metadata block header (if present).
bool dirty_metadata_block
True if metadata block should be written during close.
uint8_t * sector_subchannel
Raw 96-byte subchannel (if captured).
uint8_t * comments
Image comments.
bool dirty_sector_subchannel_block
True if subchannel block should be written during close.
FILE * imageStream
Underlying FILE* stream (binary mode).
bool dirty_dvd_long_sector_blocks
True if DVD long sector blocks should be written during close.
bool dirty_sector_prefix_ddt
True if sector prefix DDT should be written during close.
UT_array * index_entries
Flattened index entries (UT_array of IndexEntry).
bool dirty_tape_file_block
True if tape file block should be written during close.
uint8_t * mode2_subheaders
MODE2 Form1/Form2 8-byte subheaders (concatenated).
ImageInfo image_info
Exposed high-level image info summary.
uint8_t * sector_id
DVD sector ID (4 bytes) if present.
DumpHardwareHeader dump_hardware_header
Dump hardware header.
sha1_ctx sha1_context
Opaque SHA-1 context for streaming updates.
bool dirty_secondary_ddt
True if secondary DDT tables should be written during close.
bool * readableSectorTags
Per-sector boolean array (optical tags read successfully?).
bool dirty_tape_ddt
True if tape DDT should be written during close.
TapePartitionHashEntry * tape_partitions
Hash table root for tape partitions.
uint32_t * sector_prefix_ddt
Legacy CD sector prefix DDT (deprecated by *2).
uint32_t lzma_dict_size
LZMA dictionary size (writing path).
TrackEntry * track_entries
Full track list (tracksHeader.entries elements).
uint8_t * sector_suffix_corrected
Corrected suffix if stored separately.
uint8_t * metadata_block
Raw metadata UTF-16LE concatenated strings.
uint64_t cached_ddt_position
Position index of cached secondary DDT.
uint8_t * media_title
Title of the media represented by the image.
bool dirty_geometry_block
True if geometry block should be written during close.
size_t mapped_memory_ddt_size
Length of mmapped DDT if userDataDdt is mmapped.
uint8_t * media_manufacturer
Manufacturer of the media represented by the image.
TracksHeader tracks_header
Tracks header (optical) if present.
Minimal ECMA-182 CRC64 incremental state container (running value only).
Hash table entry for an arbitrary media tag (e.g., proprietary drive/medium descriptor).
uint8_t * data
Tag data blob (opaque to library core); length bytes long.
int32_t type
Numeric type identifier.
uint32_t length
Length in bytes of data.