<ahref="index__v2_8c.html">Go to the documentation of this file.</a><divclass="fragment"><divclass="line"><aid="l00001"name="l00001"></a><spanclass="lineno"> 1</span><spanclass="comment">/*</span></div>
<divclass="line"><aid="l00002"name="l00002"></a><spanclass="lineno"> 2</span><spanclass="comment"> * This file is part of the Aaru Data Preservation Suite.</span></div>
<divclass="line"><aid="l00005"name="l00005"></a><spanclass="lineno"> 5</span><spanclass="comment"> * This library is free software; you can redistribute it and/or modify</span></div>
<divclass="line"><aid="l00006"name="l00006"></a><spanclass="lineno"> 6</span><spanclass="comment"> * it under the terms of the GNU Lesser General Public License as</span></div>
<divclass="line"><aid="l00007"name="l00007"></a><spanclass="lineno"> 7</span><spanclass="comment"> * published by the Free Software Foundation; either version 2.1 of the</span></div>
<divclass="line"><aid="l00008"name="l00008"></a><spanclass="lineno"> 8</span><spanclass="comment"> * License, or (at your option) any later version.</span></div>
<divclass="line"><aid="l00010"name="l00010"></a><spanclass="lineno"> 10</span><spanclass="comment"> * This library is distributed in the hope that it will be useful, but</span></div>
<divclass="line"><aid="l00011"name="l00011"></a><spanclass="lineno"> 11</span><spanclass="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</span></div>
<divclass="line"><aid="l00012"name="l00012"></a><spanclass="lineno"> 12</span><spanclass="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span></div>
<divclass="line"><aid="l00013"name="l00013"></a><spanclass="lineno"> 13</span><spanclass="comment"> * Lesser General Public License for more details.</span></div>
<divclass="line"><aid="l00015"name="l00015"></a><spanclass="lineno"> 15</span><spanclass="comment"> * You should have received a copy of the GNU Lesser General Public</span></div>
<divclass="line"><aid="l00016"name="l00016"></a><spanclass="lineno"> 16</span><spanclass="comment"> * License along with this library; if not, see <http://www.gnu.org/licenses/>.</span></div>
<divclass="line"><aid="l00097"name="l00097"></a><spanclass="lineno"> 97</span><aclass="code hl_define"href="log_8h.html#a053d6037d543b84ce59308ce71d15cd1">FATAL</a>(<spanclass="stringliteral">"Could not allocate memory for index entries array."</span>);</div>
<divclass="line"><aid="l00102"name="l00102"></a><spanclass="lineno"> 102</span><spanclass="comment">// Read the index header</span></div>
<divclass="line"><aid="l00103"name="l00103"></a><spanclass="lineno"> 103</span><aclass="code hl_define"href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<spanclass="stringliteral">"Reading index header at position %llu"</span>, ctx-><aclass="code hl_variable"href="structaaruformat__context.html#a670dec8d59407989fefc361dc26c6832">header</a>.<aclass="code hl_variable"href="structAaruHeaderV2.html#a4ec4b1d593f5a0af19f6d7b8eaeada40">indexOffset</a>);</div>
<divclass="line"><aid="l00106"name="l00106"></a><spanclass="lineno"> 106</span><aclass="code hl_define"href="log_8h.html#a053d6037d543b84ce59308ce71d15cd1">FATAL</a>(<spanclass="stringliteral">"Could not seek to index header at %llu."</span>, ctx-><aclass="code hl_variable"href="structaaruformat__context.html#a670dec8d59407989fefc361dc26c6832">header</a>.<aclass="code hl_variable"href="structAaruHeaderV2.html#a4ec4b1d593f5a0af19f6d7b8eaeada40">indexOffset</a>);</div>
<divclass="line"><aid="l00115"name="l00115"></a><spanclass="lineno"> 115</span><aclass="code hl_define"href="log_8h.html#a053d6037d543b84ce59308ce71d15cd1">FATAL</a>(<spanclass="stringliteral">"Could not read index header at %llu."</span>, ctx-><aclass="code hl_variable"href="structaaruformat__context.html#a670dec8d59407989fefc361dc26c6832">header</a>.<aclass="code hl_variable"href="structAaruHeaderV2.html#a4ec4b1d593f5a0af19f6d7b8eaeada40">indexOffset</a>);</div>
<divclass="line"><aid="l00125"name="l00125"></a><spanclass="lineno"> 125</span><aclass="code hl_define"href="log_8h.html#a053d6037d543b84ce59308ce71d15cd1">FATAL</a>(<spanclass="stringliteral">"Incorrect index identifier."</span>);</div>
<divclass="line"><aid="l00132"name="l00132"></a><spanclass="lineno"> 132</span><spanclass="keywordflow">for</span>(uint64_t i = 0; i < idx_header.<aclass="code hl_variable"href="structIndexHeader2.html#a514ed0ba071841bc96f9583b67c664f9">entries</a>; i++)</div>
<divclass="line"><aid="l00136"name="l00136"></a><spanclass="lineno"> 136</span><aclass="code hl_define"href="log_8h.html#a053d6037d543b84ce59308ce71d15cd1">FATAL</a>(<spanclass="stringliteral">"Could not read index entry %llu at %llu."</span>, (<spanclass="keywordtype">unsigned</span><spanclass="keywordtype">long</span><spanclass="keywordtype">long</span>)i, ctx-><aclass="code hl_variable"href="structaaruformat__context.html#a670dec8d59407989fefc361dc26c6832">header</a>.<aclass="code hl_variable"href="structAaruHeaderV2.html#a4ec4b1d593f5a0af19f6d7b8eaeada40">indexOffset</a>);</div>
<divclass="line"><aid="l00146"name="l00146"></a><spanclass="lineno"> 146</span><aclass="code hl_define"href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<spanclass="stringliteral">"Read %llu index entries from index block at position %llu"</span>, (<spanclass="keywordtype">unsigned</span><spanclass="keywordtype">long</span><spanclass="keywordtype">long</span>)idx_header.<aclass="code hl_variable"href="structIndexHeader2.html#a514ed0ba071841bc96f9583b67c664f9">entries</a>,</div>
<divclass="line"><aid="l00244"name="l00244"></a><spanclass="lineno"> 244</span><spanclass="comment">// This will traverse all blocks and check their CRC64 without uncompressing them</span></div>
<divclass="line"><aid="l00245"name="l00245"></a><spanclass="lineno"> 245</span><aclass="code hl_define"href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<spanclass="stringliteral">"Checking index integrity at %llu."</span>, ctx-><aclass="code hl_variable"href="structaaruformat__context.html#a670dec8d59407989fefc361dc26c6832">header</a>.<aclass="code hl_variable"href="structAaruHeaderV2.html#a4ec4b1d593f5a0af19f6d7b8eaeada40">indexOffset</a>);</div>
<divclass="line"><aid="l00248"name="l00248"></a><spanclass="lineno"> 248</span><aclass="code hl_define"href="log_8h.html#a053d6037d543b84ce59308ce71d15cd1">FATAL</a>(<spanclass="stringliteral">"Could not seek to index header at %llu."</span>, ctx-><aclass="code hl_variable"href="structaaruformat__context.html#a670dec8d59407989fefc361dc26c6832">header</a>.<aclass="code hl_variable"href="structAaruHeaderV2.html#a4ec4b1d593f5a0af19f6d7b8eaeada40">indexOffset</a>);</div>
<divclass="line"><aid="l00254"name="l00254"></a><spanclass="lineno"> 254</span><spanclass="comment">// Read the index header</span></div>
<divclass="line"><aid="l00255"name="l00255"></a><spanclass="lineno"> 255</span><aclass="code hl_define"href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<spanclass="stringliteral">"Reading index header at position %llu"</span>, ctx-><aclass="code hl_variable"href="structaaruformat__context.html#a670dec8d59407989fefc361dc26c6832">header</a>.<aclass="code hl_variable"href="structAaruHeaderV2.html#a4ec4b1d593f5a0af19f6d7b8eaeada40">indexOffset</a>);</div>
<divclass="line"><aid="l00260"name="l00260"></a><spanclass="lineno"> 260</span><aclass="code hl_define"href="log_8h.html#a053d6037d543b84ce59308ce71d15cd1">FATAL</a>(<spanclass="stringliteral">"Could not read index header."</span>);</div>
<divclass="line"><aid="l00268"name="l00268"></a><spanclass="lineno"> 268</span><aclass="code hl_define"href="log_8h.html#a053d6037d543b84ce59308ce71d15cd1">FATAL</a>(<spanclass="stringliteral">"Incorrect index identifier."</span>);</div>
<divclass="line"><aid="l00278"name="l00278"></a><spanclass="lineno"> 278</span><aclass="code hl_define"href="log_8h.html#a053d6037d543b84ce59308ce71d15cd1">FATAL</a>(<spanclass="stringliteral">"Index entry count %llu is too large to process."</span>, (<spanclass="keywordtype">unsigned</span><spanclass="keywordtype">long</span><spanclass="keywordtype">long</span>)index_header.<aclass="code hl_variable"href="structIndexHeader2.html#a514ed0ba071841bc96f9583b67c664f9">entries</a>);</div>
<divclass="line"><aid="l00292"name="l00292"></a><spanclass="lineno"> 292</span><aclass="code hl_define"href="log_8h.html#a053d6037d543b84ce59308ce71d15cd1">FATAL</a>(<spanclass="stringliteral">"Cannot allocate memory for index entries."</span>);</div>
<divclass="line"><aid="l00302"name="l00302"></a><spanclass="lineno"> 302</span><aclass="code hl_define"href="log_8h.html#a053d6037d543b84ce59308ce71d15cd1">FATAL</a>(<spanclass="stringliteral">"Could not read index entries."</span>);</div>
<divclass="line"><aid="l00332"name="l00332"></a><spanclass="lineno"> 332</span><aclass="code hl_define"href="log_8h.html#a053d6037d543b84ce59308ce71d15cd1">FATAL</a>(<spanclass="stringliteral">"Failed to update index CRC."</span>);</div>
<divclass="line"><aid="l00347"name="l00347"></a><spanclass="lineno"> 347</span><aclass="code hl_define"href="log_8h.html#a053d6037d543b84ce59308ce71d15cd1">FATAL</a>(<spanclass="stringliteral">"Failed to finalize index CRC."</span>);</div>
<divclass="line"><aid="l00357"name="l00357"></a><spanclass="lineno"> 357</span><spanclass="comment">// Due to how C# wrote it, it is effectively reversed</span></div>
<divclass="ttc"id="aconsts_8h_html_ac837e146bff4d0f3603e4a9e444358c6"><divclass="ttname"><ahref="consts_8h.html#ac837e146bff4d0f3603e4a9e444358c6">AARUF_VERSION_V1</a></div><divclass="ttdeci">#define AARUF_VERSION_V1</div><divclass="ttdoc">First on‑disk version (C# implementation).</div><divclass="ttdef"><b>Definition</b><ahref="consts_8h_source.html#l00071">consts.h:71</a></div></div>
<divclass="ttc"id="adecls_8h_html_a1fb4423a841ccd728e3ad0d028cbc9b4"><divclass="ttname"><ahref="decls_8h.html#a1fb4423a841ccd728e3ad0d028cbc9b4">aaruf_crc64_update</a></div><divclass="ttdeci">int aaruf_crc64_update(crc64_ctx *ctx, const uint8_t *data, uint32_t len)</div><divclass="ttdoc">Updates the CRC64 context with new data.</div><divclass="ttdef"><b>Definition</b><ahref="crc64_8c_source.html#l00055">crc64.c:55</a></div></div>
<divclass="ttc"id="adecls_8h_html_a4943569a8623eb2e3e0adc276c433097"><divclass="ttname"><ahref="decls_8h.html#a4943569a8623eb2e3e0adc276c433097">aaruf_crc64_free</a></div><divclass="ttdeci">void aaruf_crc64_free(crc64_ctx *ctx)</div><divclass="ttdoc">Frees a CRC64 context.</div><divclass="ttdef"><b>Definition</b><ahref="crc64_8c_source.html#l00155">crc64.c:155</a></div></div>
<divclass="ttc"id="adecls_8h_html_a66567ca64e31a687d4982cb254b45196"><divclass="ttname"><ahref="decls_8h.html#a66567ca64e31a687d4982cb254b45196">aaruf_crc64_init</a></div><divclass="ttdeci">crc64_ctx * aaruf_crc64_init()</div><divclass="ttdoc">Initializes a CRC64 context.</div><divclass="ttdef"><b>Definition</b><ahref="crc64_8c_source.html#l00032">crc64.c:32</a></div></div>
<divclass="ttc"id="adecls_8h_html_ae48cfb59c6585e9ffd4cd1a97044891f"><divclass="ttname"><ahref="decls_8h.html#ae48cfb59c6585e9ffd4cd1a97044891f">aaruf_crc64_final</a></div><divclass="ttdeci">int aaruf_crc64_final(crc64_ctx *ctx, uint64_t *crc)</div><divclass="ttdoc">Computes the final CRC64 value from the context.</div><divclass="ttdef"><b>Definition</b><ahref="crc64_8c_source.html#l00141">crc64.c:141</a></div></div>
<divclass="ttc"id="aenums_8h_html_a54420623f26ab6bb61042b41cccf37a3a6ee3c4c583df36e3dfe796593c1e9439"><divclass="ttname"><ahref="enums_8h.html#a54420623f26ab6bb61042b41cccf37a3a6ee3c4c583df36e3dfe796593c1e9439">IndexBlock2</a></div><divclass="ttdeci">@ IndexBlock2</div><divclass="ttdoc">Block containing the index v2.</div><divclass="ttdef"><b>Definition</b><ahref="enums_8h_source.html#l00147">enums.h:147</a></div></div>
<divclass="ttc"id="aerrors_8h_html_a1d6e49f7e8a1fa489efa0a582e90b5de"><divclass="ttname"><ahref="errors_8h.html#a1d6e49f7e8a1fa489efa0a582e90b5de">AARUF_STATUS_OK</a></div><divclass="ttdeci">#define AARUF_STATUS_OK</div><divclass="ttdoc">Sector present and read without uncorrectable errors.</div><divclass="ttdef"><b>Definition</b><ahref="errors_8h_source.html#l00075">errors.h:75</a></div></div>
<divclass="ttc"id="aerrors_8h_html_a3459a04771fe04f8f77bfa90563a4375"><divclass="ttname"><ahref="errors_8h.html#a3459a04771fe04f8f77bfa90563a4375">AARUF_ERROR_CANNOT_READ_HEADER</a></div><divclass="ttdeci">#define AARUF_ERROR_CANNOT_READ_HEADER</div><divclass="ttdoc">Failed to read container header.</div><divclass="ttdef"><b>Definition</b><ahref="errors_8h_source.html#l00045">errors.h:45</a></div></div>
<divclass="ttc"id="aerrors_8h_html_ab6c57651868e0f35e3821680ebb2b17a"><divclass="ttname"><ahref="errors_8h.html#ab6c57651868e0f35e3821680ebb2b17a">AARUF_ERROR_CANNOT_READ_INDEX</a></div><divclass="ttdeci">#define AARUF_ERROR_CANNOT_READ_INDEX</div><divclass="ttdoc">Index block unreadable / truncated / bad identifier.</div><divclass="ttdef"><b>Definition</b><ahref="errors_8h_source.html#l00043">errors.h:43</a></div></div>
<divclass="ttc"id="aerrors_8h_html_abb63e240b11d790da83bd34507b57851"><divclass="ttname"><ahref="errors_8h.html#abb63e240b11d790da83bd34507b57851">AARUF_ERROR_NOT_AARUFORMAT</a></div><divclass="ttdeci">#define AARUF_ERROR_NOT_AARUFORMAT</div><divclass="ttdoc">Input file/stream failed magic or structural validation.</div><divclass="ttdef"><b>Definition</b><ahref="errors_8h_source.html#l00040">errors.h:40</a></div></div>
<divclass="ttc"id="aindex__v2_8c_html_a1baad6508d1cde5a712794e956fb3d3c"><divclass="ttname"><ahref="index__v2_8c.html#a1baad6508d1cde5a712794e956fb3d3c">process_index_v2</a></div><divclass="ttdeci">UT_array * process_index_v2(aaruformat_context *ctx)</div><divclass="ttdoc">Processes an index block (version 2) from the image stream.</div><divclass="ttdef"><b>Definition</b><ahref="#l00081">index_v2.c:81</a></div></div>
<divclass="ttc"id="aindex__v2_8c_html_ae234e22b16b085d18614110630034db5"><divclass="ttname"><ahref="index__v2_8c.html#ae234e22b16b085d18614110630034db5">verify_index_v2</a></div><divclass="ttdeci">int32_t verify_index_v2(aaruformat_context *ctx)</div><divclass="ttdoc">Verifies the integrity of an index block (version 2) in the image stream.</div><divclass="ttdef"><b>Definition</b><ahref="#l00227">index_v2.c:227</a></div></div>
<divclass="ttc"id="astructAaruHeaderV2_html_a4ec4b1d593f5a0af19f6d7b8eaeada40"><divclass="ttname"><ahref="structAaruHeaderV2.html#a4ec4b1d593f5a0af19f6d7b8eaeada40">AaruHeaderV2::indexOffset</a></div><divclass="ttdeci">uint64_t indexOffset</div><divclass="ttdoc">Absolute byte offset to primary index block (MUST be > 0; 0 => corrupt/unreadable).</div><divclass="ttdef"><b>Definition</b><ahref="header_8h_source.html#l00115">header.h:115</a></div></div>
<divclass="ttc"id="astructAaruHeaderV2_html_af79ca31bcd428d1a54ac25c30d09b7a7"><divclass="ttname"><ahref="structAaruHeaderV2.html#af79ca31bcd428d1a54ac25c30d09b7a7">AaruHeaderV2::imageMajorVersion</a></div><divclass="ttdeci">uint8_t imageMajorVersion</div><divclass="ttdoc">Container format major version.</div><divclass="ttdef"><b>Definition</b><ahref="header_8h_source.html#l00110">header.h:110</a></div></div>
<divclass="ttc"id="astructIndexEntry_html"><divclass="ttname"><ahref="structIndexEntry.html">IndexEntry</a></div><divclass="ttdoc">Single index entry describing a block's type, (optional) data classification, and file offset.</div><divclass="ttdef"><b>Definition</b><ahref="index_8h_source.html#l00108">index.h:109</a></div></div>
<divclass="ttc"id="astructIndexHeader2_html_a514ed0ba071841bc96f9583b67c664f9"><divclass="ttname"><ahref="structIndexHeader2.html#a514ed0ba071841bc96f9583b67c664f9">IndexHeader2::entries</a></div><divclass="ttdeci">uint64_t entries</div><divclass="ttdoc">Number of IndexEntry records that follow immediately.</div><divclass="ttdef"><b>Definition</b><ahref="index_8h_source.html#l00081">index.h:81</a></div></div>
<divclass="ttc"id="astructIndexHeader2_html_a6b95ee733661cf13e56a46ecd1e048b0"><divclass="ttname"><ahref="structIndexHeader2.html#a6b95ee733661cf13e56a46ecd1e048b0">IndexHeader2::identifier</a></div><divclass="ttdeci">uint32_t identifier</div><divclass="ttdoc">Block identifier (must be BlockType::IndexBlock2).</div><divclass="ttdef"><b>Definition</b><ahref="index_8h_source.html#l00080">index.h:80</a></div></div>
<divclass="ttc"id="astructIndexHeader2_html_a8851ba5d67ff638378d9e61db5413b8f"><divclass="ttname"><ahref="structIndexHeader2.html#a8851ba5d67ff638378d9e61db5413b8f">IndexHeader2::crc64</a></div><divclass="ttdeci">uint64_t crc64</div><divclass="ttdoc">CRC64-ECMA of the entries array (legacy byte-swapped rule still applies for old versions).</div><divclass="ttdef"><b>Definition</b><ahref="index_8h_source.html#l00082">index.h:82</a></div></div>
<divclass="ttc"id="astructaaruformat__context_html"><divclass="ttname"><ahref="structaaruformat__context.html">aaruformat_context</a></div><divclass="ttdoc">Master context representing an open or in‑creation Aaru image.</div><divclass="ttdef"><b>Definition</b><ahref="context_8h_source.html#l00171">context.h:172</a></div></div>
<divclass="ttc"id="astructcrc64__ctx_html"><divclass="ttname"><ahref="structcrc64__ctx.html">crc64_ctx</a></div><divclass="ttdoc">Minimal ECMA-182 CRC64 incremental state container (running value only).</div><divclass="ttdef"><b>Definition</b><ahref="crc64_8h_source.html#l00055">crc64.h:56</a></div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
</div><!-- container -->
<!-- start footer part -->
<divid="nav-path"class="navpath"><!-- id is needed for treeview function! -->
<liclass="footer">Generated by <ahref="https://www.doxygen.org/index.html"><imgclass="footer"src="doxygen.svg"width="104"height="31"alt="doxygen"/></a> 1.14.0 </li>