Files
libaaruformat/docs/html/tape_8c_source.html

625 lines
108 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.14.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>libaaruformat: src/blocks/tape.c Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="clipboard.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="cookie.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectalign">
<div id="projectname">libaaruformat<span id="projectnumber">&#160;1.0</span>
</div>
<div id="projectbrief">Aaru Data Preservation Suite - Format Library</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.14.0 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search/",'.html');
</script>
<script type="text/javascript">
$(function() { codefold.init(); });
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
initMenu('',true,false,'search.php','Search',true);
$(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
$(function(){initNavTree('tape_8c_source.html','',''); });
</script>
<div id="container">
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>
<div class="header">
<div class="headertitle"><div class="title">tape.c</div></div>
</div><!--header-->
<div class="contents">
<a href="tape_8c.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno"> 1</span><span class="comment">/*</span></div>
<div class="line"><a id="l00002" name="l00002"></a><span class="lineno"> 2</span><span class="comment"> * This file is part of the Aaru Data Preservation Suite.</span></div>
<div class="line"><a id="l00003" name="l00003"></a><span class="lineno"> 3</span><span class="comment"> * Copyright (c) 2019-2025 Natalia Portillo.</span></div>
<div class="line"><a id="l00004" name="l00004"></a><span class="lineno"> 4</span><span class="comment"> *</span></div>
<div class="line"><a id="l00005" name="l00005"></a><span class="lineno"> 5</span><span class="comment"> * This library is free software; you can redistribute it and/or modify</span></div>
<div class="line"><a id="l00006" name="l00006"></a><span class="lineno"> 6</span><span class="comment"> * it under the terms of the GNU Lesser General Public License as</span></div>
<div class="line"><a id="l00007" name="l00007"></a><span class="lineno"> 7</span><span class="comment"> * published by the Free Software Foundation; either version 2.1 of the</span></div>
<div class="line"><a id="l00008" name="l00008"></a><span class="lineno"> 8</span><span class="comment"> * License, or (at your option) any later version.</span></div>
<div class="line"><a id="l00009" name="l00009"></a><span class="lineno"> 9</span><span class="comment"> *</span></div>
<div class="line"><a id="l00010" name="l00010"></a><span class="lineno"> 10</span><span class="comment"> * This library is distributed in the hope that it will be useful, but</span></div>
<div class="line"><a id="l00011" name="l00011"></a><span class="lineno"> 11</span><span class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</span></div>
<div class="line"><a id="l00012" name="l00012"></a><span class="lineno"> 12</span><span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span></div>
<div class="line"><a id="l00013" name="l00013"></a><span class="lineno"> 13</span><span class="comment"> * Lesser General Public License for more details.</span></div>
<div class="line"><a id="l00014" name="l00014"></a><span class="lineno"> 14</span><span class="comment"> *</span></div>
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno"> 15</span><span class="comment"> * You should have received a copy of the GNU Lesser General Public</span></div>
<div class="line"><a id="l00016" name="l00016"></a><span class="lineno"> 16</span><span class="comment"> * License along with this library; if not, see &lt;http://www.gnu.org/licenses/&gt;.</span></div>
<div class="line"><a id="l00017" name="l00017"></a><span class="lineno"> 17</span><span class="comment"> * */</span></div>
<div class="line"><a id="l00018" name="l00018"></a><span class="lineno"> 18</span> </div>
<div class="line"><a id="l00019" name="l00019"></a><span class="lineno"> 19</span><span class="preprocessor">#include &quot;<a class="code" href="aaruformat_8h.html">aaruformat.h</a>&quot;</span></div>
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno"> 20</span><span class="preprocessor">#include &quot;<a class="code" href="log_8h.html">log.h</a>&quot;</span></div>
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno"> 21</span></div>
<div class="foldopen" id="foldopen00126" data-start="{" data-end="}">
<div class="line"><a id="l00126" name="l00126"></a><span class="lineno"><a class="line" href="internal_8h.html#a829bbac3c17b60efd8f93188a8de8278"> 126</a></span><span class="keywordtype">void</span> <a class="code hl_function" href="tape_8c.html#a829bbac3c17b60efd8f93188a8de8278">process_tape_files_block</a>(<a class="code hl_struct" href="structaaruformat__context.html">aaruformat_context</a> *ctx, <span class="keyword">const</span> <a class="code hl_struct" href="structIndexEntry.html">IndexEntry</a> *entry)</div>
<div class="line"><a id="l00127" name="l00127"></a><span class="lineno"> 127</span>{</div>
<div class="line"><a id="l00128" name="l00128"></a><span class="lineno"> 128</span> <span class="keywordtype">long</span> pos = 0;</div>
<div class="line"><a id="l00129" name="l00129"></a><span class="lineno"> 129</span> <span class="keywordtype">size_t</span> read_bytes = 0;</div>
<div class="line"><a id="l00130" name="l00130"></a><span class="lineno"> 130</span> <a class="code hl_struct" href="structTapeFileHeader.html">TapeFileHeader</a> tape_file_header = {0};</div>
<div class="line"><a id="l00131" name="l00131"></a><span class="lineno"> 131</span> </div>
<div class="line"><a id="l00132" name="l00132"></a><span class="lineno"> 132</span> <span class="comment">// Check if the context and image stream are valid</span></div>
<div class="line"><a id="l00133" name="l00133"></a><span class="lineno"> 133</span> <span class="keywordflow">if</span>(ctx == NULL || ctx-&gt;<a class="code hl_variable" href="structaaruformat__context.html#ab516fae594bde4f76b75488d0a3ca3a8">imageStream</a> == NULL)</div>
<div class="line"><a id="l00134" name="l00134"></a><span class="lineno"> 134</span> {</div>
<div class="line"><a id="l00135" name="l00135"></a><span class="lineno"> 135</span> <a class="code hl_define" href="log_8h.html#a053d6037d543b84ce59308ce71d15cd1">FATAL</a>(<span class="stringliteral">&quot;Invalid context or image stream.&quot;</span>);</div>
<div class="line"><a id="l00136" name="l00136"></a><span class="lineno"> 136</span> <span class="keywordflow">return</span>;</div>
<div class="line"><a id="l00137" name="l00137"></a><span class="lineno"> 137</span> }</div>
<div class="line"><a id="l00138" name="l00138"></a><span class="lineno"> 138</span> </div>
<div class="line"><a id="l00139" name="l00139"></a><span class="lineno"> 139</span> <span class="comment">// Seek to block</span></div>
<div class="line"><a id="l00140" name="l00140"></a><span class="lineno"> 140</span> pos = fseek(ctx-&gt;<a class="code hl_variable" href="structaaruformat__context.html#ab516fae594bde4f76b75488d0a3ca3a8">imageStream</a>, entry-&gt;<a class="code hl_variable" href="structIndexEntry.html#a854951a64192d7e4cdcfa6dd6fd2b3ea">offset</a>, SEEK_SET);</div>
<div class="line"><a id="l00141" name="l00141"></a><span class="lineno"> 141</span> <span class="keywordflow">if</span>(pos &lt; 0 || ftell(ctx-&gt;<a class="code hl_variable" href="structaaruformat__context.html#ab516fae594bde4f76b75488d0a3ca3a8">imageStream</a>) != entry-&gt;<a class="code hl_variable" href="structIndexEntry.html#a854951a64192d7e4cdcfa6dd6fd2b3ea">offset</a>)</div>
<div class="line"><a id="l00142" name="l00142"></a><span class="lineno"> 142</span> {</div>
<div class="line"><a id="l00143" name="l00143"></a><span class="lineno"> 143</span> <a class="code hl_define" href="log_8h.html#a053d6037d543b84ce59308ce71d15cd1">FATAL</a>(<span class="stringliteral">&quot;Could not seek to %&quot;</span> PRIu64 <span class="stringliteral">&quot; as indicated by index entry...&quot;</span>, entry-&gt;<a class="code hl_variable" href="structIndexEntry.html#a854951a64192d7e4cdcfa6dd6fd2b3ea">offset</a>);</div>
<div class="line"><a id="l00144" name="l00144"></a><span class="lineno"> 144</span> </div>
<div class="line"><a id="l00145" name="l00145"></a><span class="lineno"> 145</span> <span class="keywordflow">return</span>;</div>
<div class="line"><a id="l00146" name="l00146"></a><span class="lineno"> 146</span> }</div>
<div class="line"><a id="l00147" name="l00147"></a><span class="lineno"> 147</span> </div>
<div class="line"><a id="l00148" name="l00148"></a><span class="lineno"> 148</span> <span class="comment">// Even if those two checks shall have been done before</span></div>
<div class="line"><a id="l00149" name="l00149"></a><span class="lineno"> 149</span> read_bytes = fread(&amp;tape_file_header, 1, <span class="keyword">sizeof</span>(<a class="code hl_struct" href="structTapeFileHeader.html">TapeFileHeader</a>), ctx-&gt;<a class="code hl_variable" href="structaaruformat__context.html#ab516fae594bde4f76b75488d0a3ca3a8">imageStream</a>);</div>
<div class="line"><a id="l00150" name="l00150"></a><span class="lineno"> 150</span> </div>
<div class="line"><a id="l00151" name="l00151"></a><span class="lineno"> 151</span> <span class="keywordflow">if</span>(read_bytes != <span class="keyword">sizeof</span>(<a class="code hl_struct" href="structTapeFileHeader.html">TapeFileHeader</a>))</div>
<div class="line"><a id="l00152" name="l00152"></a><span class="lineno"> 152</span> {</div>
<div class="line"><a id="l00153" name="l00153"></a><span class="lineno"> 153</span> <a class="code hl_define" href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<span class="stringliteral">&quot;Could not read tape files header, continuing...&quot;</span>);</div>
<div class="line"><a id="l00154" name="l00154"></a><span class="lineno"> 154</span> <span class="keywordflow">return</span>;</div>
<div class="line"><a id="l00155" name="l00155"></a><span class="lineno"> 155</span> }</div>
<div class="line"><a id="l00156" name="l00156"></a><span class="lineno"> 156</span> </div>
<div class="line"><a id="l00157" name="l00157"></a><span class="lineno"> 157</span> <span class="keywordflow">if</span>(tape_file_header.<a class="code hl_variable" href="structTapeFileHeader.html#a36fe923f8d67004e0b0ae8eaf6535e1d">identifier</a> != <a class="code hl_enumvalue" href="enums_8h.html#a54420623f26ab6bb61042b41cccf37a3ac3a117f2498bf736a76d5d3a3830540a">TapeFileBlock</a>)</div>
<div class="line"><a id="l00158" name="l00158"></a><span class="lineno"> 158</span> {</div>
<div class="line"><a id="l00159" name="l00159"></a><span class="lineno"> 159</span> <a class="code hl_define" href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<span class="stringliteral">&quot;Incorrect identifier for data block at position %&quot;</span> PRIu64 <span class="stringliteral">&quot;\n&quot;</span>, entry-&gt;<a class="code hl_variable" href="structIndexEntry.html#a854951a64192d7e4cdcfa6dd6fd2b3ea">offset</a>);</div>
<div class="line"><a id="l00160" name="l00160"></a><span class="lineno"> 160</span> <span class="keywordflow">return</span>;</div>
<div class="line"><a id="l00161" name="l00161"></a><span class="lineno"> 161</span> }</div>
<div class="line"><a id="l00162" name="l00162"></a><span class="lineno"> 162</span> </div>
<div class="line"><a id="l00163" name="l00163"></a><span class="lineno"> 163</span> ctx-&gt;<a class="code hl_variable" href="structaaruformat__context.html#ac970291b3449c04221827b9c2c18ac70">image_info</a>.<a class="code hl_variable" href="structImageInfo.html#abca8e73a9655d810e6d30d36c3ab54d7">ImageSize</a> += <span class="keyword">sizeof</span>(<a class="code hl_struct" href="structTapeFileEntry.html">TapeFileEntry</a>) * tape_file_header.<a class="code hl_variable" href="structTapeFileHeader.html#a319aea86a448c0b969de944f22e551c0">entries</a>;</div>
<div class="line"><a id="l00164" name="l00164"></a><span class="lineno"> 164</span> </div>
<div class="line"><a id="l00165" name="l00165"></a><span class="lineno"> 165</span> uint8_t *buffer = malloc(<span class="keyword">sizeof</span>(<a class="code hl_struct" href="structTapeFileEntry.html">TapeFileEntry</a>) * tape_file_header.<a class="code hl_variable" href="structTapeFileHeader.html#a319aea86a448c0b969de944f22e551c0">entries</a>);</div>
<div class="line"><a id="l00166" name="l00166"></a><span class="lineno"> 166</span> <span class="keywordflow">if</span>(buffer == NULL)</div>
<div class="line"><a id="l00167" name="l00167"></a><span class="lineno"> 167</span> {</div>
<div class="line"><a id="l00168" name="l00168"></a><span class="lineno"> 168</span> <a class="code hl_define" href="log_8h.html#a053d6037d543b84ce59308ce71d15cd1">FATAL</a>(<span class="stringliteral">&quot;Could not allocate memory for tape files block, continuing...&quot;</span>);</div>
<div class="line"><a id="l00169" name="l00169"></a><span class="lineno"> 169</span> <span class="keywordflow">return</span>;</div>
<div class="line"><a id="l00170" name="l00170"></a><span class="lineno"> 170</span> }</div>
<div class="line"><a id="l00171" name="l00171"></a><span class="lineno"> 171</span> read_bytes = fread(buffer, <span class="keyword">sizeof</span>(<a class="code hl_struct" href="structTapeFileEntry.html">TapeFileEntry</a>), tape_file_header.<a class="code hl_variable" href="structTapeFileHeader.html#a319aea86a448c0b969de944f22e551c0">entries</a>, ctx-&gt;<a class="code hl_variable" href="structaaruformat__context.html#ab516fae594bde4f76b75488d0a3ca3a8">imageStream</a>);</div>
<div class="line"><a id="l00172" name="l00172"></a><span class="lineno"> 172</span> <span class="keywordflow">if</span>(read_bytes != tape_file_header.<a class="code hl_variable" href="structTapeFileHeader.html#a319aea86a448c0b969de944f22e551c0">entries</a>)</div>
<div class="line"><a id="l00173" name="l00173"></a><span class="lineno"> 173</span> {</div>
<div class="line"><a id="l00174" name="l00174"></a><span class="lineno"> 174</span> free(buffer);</div>
<div class="line"><a id="l00175" name="l00175"></a><span class="lineno"> 175</span> <a class="code hl_define" href="log_8h.html#a053d6037d543b84ce59308ce71d15cd1">FATAL</a>(<span class="stringliteral">&quot;Could not read tape files block, continuing...&quot;</span>);</div>
<div class="line"><a id="l00176" name="l00176"></a><span class="lineno"> 176</span> <span class="keywordflow">return</span>;</div>
<div class="line"><a id="l00177" name="l00177"></a><span class="lineno"> 177</span> }</div>
<div class="line"><a id="l00178" name="l00178"></a><span class="lineno"> 178</span> <span class="comment">// Check CRC64</span></div>
<div class="line"><a id="l00179" name="l00179"></a><span class="lineno"> 179</span> uint64_t crc64 = <a class="code hl_function" href="decls_8h.html#a0fee4834bf0747bcd933c4e754aa4692">aaruf_crc64_data</a>(buffer, <span class="keyword">sizeof</span>(<a class="code hl_struct" href="structTapeFileEntry.html">TapeFileEntry</a>) * tape_file_header.<a class="code hl_variable" href="structTapeFileHeader.html#a319aea86a448c0b969de944f22e551c0">entries</a>);</div>
<div class="line"><a id="l00180" name="l00180"></a><span class="lineno"> 180</span> </div>
<div class="line"><a id="l00181" name="l00181"></a><span class="lineno"> 181</span> <span class="keywordflow">if</span>(crc64 != tape_file_header.<a class="code hl_variable" href="structTapeFileHeader.html#a5172ee4bf0b5820a66d04aff1e3809db">crc64</a>)</div>
<div class="line"><a id="l00182" name="l00182"></a><span class="lineno"> 182</span> {</div>
<div class="line"><a id="l00183" name="l00183"></a><span class="lineno"> 183</span> <a class="code hl_define" href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<span class="stringliteral">&quot;Incorrect CRC found: 0x%&quot;</span> PRIx64 <span class="stringliteral">&quot; found, expected 0x%&quot;</span> PRIx64 <span class="stringliteral">&quot;, continuing...&quot;</span>, crc64,</div>
<div class="line"><a id="l00184" name="l00184"></a><span class="lineno"> 184</span> tape_file_header.<a class="code hl_variable" href="structTapeFileHeader.html#a5172ee4bf0b5820a66d04aff1e3809db">crc64</a>);</div>
<div class="line"><a id="l00185" name="l00185"></a><span class="lineno"> 185</span> free(buffer);</div>
<div class="line"><a id="l00186" name="l00186"></a><span class="lineno"> 186</span> <span class="keywordflow">return</span>;</div>
<div class="line"><a id="l00187" name="l00187"></a><span class="lineno"> 187</span> }</div>
<div class="line"><a id="l00188" name="l00188"></a><span class="lineno"> 188</span> </div>
<div class="line"><a id="l00189" name="l00189"></a><span class="lineno"> 189</span> <span class="comment">// Insert entries into UTHASH array indexed by partition &lt;&lt; 32 | file number</span></div>
<div class="line"><a id="l00190" name="l00190"></a><span class="lineno"> 190</span> <span class="keyword">const</span> <a class="code hl_struct" href="structTapeFileEntry.html">TapeFileEntry</a> *entries = (<a class="code hl_struct" href="structTapeFileEntry.html">TapeFileEntry</a> *)buffer;</div>
<div class="line"><a id="l00191" name="l00191"></a><span class="lineno"> 191</span> </div>
<div class="line"><a id="l00192" name="l00192"></a><span class="lineno"> 192</span> <span class="keywordflow">for</span>(uint32_t i = 0; i &lt; tape_file_header.<a class="code hl_variable" href="structTapeFileHeader.html#a319aea86a448c0b969de944f22e551c0">entries</a>; i++)</div>
<div class="line"><a id="l00193" name="l00193"></a><span class="lineno"> 193</span> {</div>
<div class="line"><a id="l00194" name="l00194"></a><span class="lineno"> 194</span> <span class="comment">// Create hash table entry</span></div>
<div class="line"><a id="l00195" name="l00195"></a><span class="lineno"> 195</span> <a class="code hl_typedef" href="context_8h.html#a5ba965cb003bc2d68a9f9e1c11225494">tapeFileHashEntry</a> *hash_entry = malloc(<span class="keyword">sizeof</span>(<a class="code hl_typedef" href="context_8h.html#a5ba965cb003bc2d68a9f9e1c11225494">tapeFileHashEntry</a>));</div>
<div class="line"><a id="l00196" name="l00196"></a><span class="lineno"> 196</span> <span class="keywordflow">if</span>(hash_entry == NULL)</div>
<div class="line"><a id="l00197" name="l00197"></a><span class="lineno"> 197</span> {</div>
<div class="line"><a id="l00198" name="l00198"></a><span class="lineno"> 198</span> <a class="code hl_define" href="log_8h.html#a053d6037d543b84ce59308ce71d15cd1">FATAL</a>(<span class="stringliteral">&quot;Could not allocate memory for tape file hash entry&quot;</span>);</div>
<div class="line"><a id="l00199" name="l00199"></a><span class="lineno"> 199</span> <span class="keywordflow">continue</span>;</div>
<div class="line"><a id="l00200" name="l00200"></a><span class="lineno"> 200</span> }</div>
<div class="line"><a id="l00201" name="l00201"></a><span class="lineno"> 201</span> </div>
<div class="line"><a id="l00202" name="l00202"></a><span class="lineno"> 202</span> <span class="comment">// Create composite key: partition &lt;&lt; 32 | file number</span></div>
<div class="line"><a id="l00203" name="l00203"></a><span class="lineno"> 203</span> hash_entry-&gt;<a class="code hl_variable" href="structTapeFileHashEntry.html#a5556a05025c18c16e3bb45026b2246e0">key</a> = (uint64_t)entries[i].Partition &lt;&lt; 32 | entries[i].File;</div>
<div class="line"><a id="l00204" name="l00204"></a><span class="lineno"> 204</span> </div>
<div class="line"><a id="l00205" name="l00205"></a><span class="lineno"> 205</span> <span class="comment">// Copy the tape file entry data</span></div>
<div class="line"><a id="l00206" name="l00206"></a><span class="lineno"> 206</span> hash_entry-&gt;<a class="code hl_variable" href="structTapeFileHashEntry.html#aff0f81d26d4ee00ad33331aacc2834e1">fileEntry</a> = entries[i];</div>
<div class="line"><a id="l00207" name="l00207"></a><span class="lineno"> 207</span> </div>
<div class="line"><a id="l00208" name="l00208"></a><span class="lineno"> 208</span> <span class="comment">// Replace if exists, add if new</span></div>
<div class="line"><a id="l00209" name="l00209"></a><span class="lineno"> 209</span> <a class="code hl_typedef" href="context_8h.html#a5ba965cb003bc2d68a9f9e1c11225494">tapeFileHashEntry</a> *old_entry = NULL;</div>
<div class="line"><a id="l00210" name="l00210"></a><span class="lineno"> 210</span> HASH_REPLACE(hh, ctx-&gt;<a class="code hl_variable" href="structaaruformat__context.html#a4783c528aec3e854986885077c5d5854">tape_files</a>, key, <span class="keyword">sizeof</span>(uint64_t), hash_entry, old_entry);</div>
<div class="line"><a id="l00211" name="l00211"></a><span class="lineno"> 211</span> </div>
<div class="line"><a id="l00212" name="l00212"></a><span class="lineno"> 212</span> <span class="comment">// Free old entry if it was replaced</span></div>
<div class="line"><a id="l00213" name="l00213"></a><span class="lineno"> 213</span> <span class="keywordflow">if</span>(old_entry != NULL)</div>
<div class="line"><a id="l00214" name="l00214"></a><span class="lineno"> 214</span> {</div>
<div class="line"><a id="l00215" name="l00215"></a><span class="lineno"> 215</span> <a class="code hl_define" href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<span class="stringliteral">&quot;Replaced existing tape file entry for partition %u, file %u&quot;</span>, entries[i].Partition, entries[i].File);</div>
<div class="line"><a id="l00216" name="l00216"></a><span class="lineno"> 216</span> free(old_entry);</div>
<div class="line"><a id="l00217" name="l00217"></a><span class="lineno"> 217</span> }</div>
<div class="line"><a id="l00218" name="l00218"></a><span class="lineno"> 218</span> <span class="keywordflow">else</span></div>
<div class="line"><a id="l00219" name="l00219"></a><span class="lineno"> 219</span> <a class="code hl_define" href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<span class="stringliteral">&quot;Added new tape file entry for partition %u, file %u&quot;</span>, entries[i].Partition, entries[i].File);</div>
<div class="line"><a id="l00220" name="l00220"></a><span class="lineno"> 220</span> }</div>
<div class="line"><a id="l00221" name="l00221"></a><span class="lineno"> 221</span> </div>
<div class="line"><a id="l00222" name="l00222"></a><span class="lineno"> 222</span> free(buffer);</div>
<div class="line"><a id="l00223" name="l00223"></a><span class="lineno"> 223</span>}</div>
</div>
<div class="line"><a id="l00224" name="l00224"></a><span class="lineno"> 224</span></div>
<div class="foldopen" id="foldopen00346" data-start="{" data-end="}">
<div class="line"><a id="l00346" name="l00346"></a><span class="lineno"><a class="line" href="internal_8h.html#aa76718b0402b1a28be3d563d5e62028e"> 346</a></span><span class="keywordtype">void</span> <a class="code hl_function" href="tape_8c.html#aa76718b0402b1a28be3d563d5e62028e">process_tape_partitions_block</a>(<a class="code hl_struct" href="structaaruformat__context.html">aaruformat_context</a> *ctx, <span class="keyword">const</span> <a class="code hl_struct" href="structIndexEntry.html">IndexEntry</a> *entry)</div>
<div class="line"><a id="l00347" name="l00347"></a><span class="lineno"> 347</span>{</div>
<div class="line"><a id="l00348" name="l00348"></a><span class="lineno"> 348</span> <span class="keywordtype">long</span> pos = 0;</div>
<div class="line"><a id="l00349" name="l00349"></a><span class="lineno"> 349</span> <span class="keywordtype">size_t</span> read_bytes = 0;</div>
<div class="line"><a id="l00350" name="l00350"></a><span class="lineno"> 350</span> <a class="code hl_struct" href="structTapePartitionHeader.html">TapePartitionHeader</a> tape_partition_header = {0};</div>
<div class="line"><a id="l00351" name="l00351"></a><span class="lineno"> 351</span> </div>
<div class="line"><a id="l00352" name="l00352"></a><span class="lineno"> 352</span> <span class="comment">// Check if the context and image stream are valid</span></div>
<div class="line"><a id="l00353" name="l00353"></a><span class="lineno"> 353</span> <span class="keywordflow">if</span>(ctx == NULL || ctx-&gt;<a class="code hl_variable" href="structaaruformat__context.html#ab516fae594bde4f76b75488d0a3ca3a8">imageStream</a> == NULL)</div>
<div class="line"><a id="l00354" name="l00354"></a><span class="lineno"> 354</span> {</div>
<div class="line"><a id="l00355" name="l00355"></a><span class="lineno"> 355</span> <a class="code hl_define" href="log_8h.html#a053d6037d543b84ce59308ce71d15cd1">FATAL</a>(<span class="stringliteral">&quot;Invalid context or image stream.&quot;</span>);</div>
<div class="line"><a id="l00356" name="l00356"></a><span class="lineno"> 356</span> <span class="keywordflow">return</span>;</div>
<div class="line"><a id="l00357" name="l00357"></a><span class="lineno"> 357</span> }</div>
<div class="line"><a id="l00358" name="l00358"></a><span class="lineno"> 358</span> </div>
<div class="line"><a id="l00359" name="l00359"></a><span class="lineno"> 359</span> <span class="comment">// Seek to block</span></div>
<div class="line"><a id="l00360" name="l00360"></a><span class="lineno"> 360</span> pos = fseek(ctx-&gt;<a class="code hl_variable" href="structaaruformat__context.html#ab516fae594bde4f76b75488d0a3ca3a8">imageStream</a>, entry-&gt;<a class="code hl_variable" href="structIndexEntry.html#a854951a64192d7e4cdcfa6dd6fd2b3ea">offset</a>, SEEK_SET);</div>
<div class="line"><a id="l00361" name="l00361"></a><span class="lineno"> 361</span> <span class="keywordflow">if</span>(pos &lt; 0 || ftell(ctx-&gt;<a class="code hl_variable" href="structaaruformat__context.html#ab516fae594bde4f76b75488d0a3ca3a8">imageStream</a>) != entry-&gt;<a class="code hl_variable" href="structIndexEntry.html#a854951a64192d7e4cdcfa6dd6fd2b3ea">offset</a>)</div>
<div class="line"><a id="l00362" name="l00362"></a><span class="lineno"> 362</span> {</div>
<div class="line"><a id="l00363" name="l00363"></a><span class="lineno"> 363</span> <a class="code hl_define" href="log_8h.html#a053d6037d543b84ce59308ce71d15cd1">FATAL</a>(<span class="stringliteral">&quot;Could not seek to %&quot;</span> PRIu64 <span class="stringliteral">&quot; as indicated by index entry...&quot;</span>, entry-&gt;<a class="code hl_variable" href="structIndexEntry.html#a854951a64192d7e4cdcfa6dd6fd2b3ea">offset</a>);</div>
<div class="line"><a id="l00364" name="l00364"></a><span class="lineno"> 364</span> </div>
<div class="line"><a id="l00365" name="l00365"></a><span class="lineno"> 365</span> <span class="keywordflow">return</span>;</div>
<div class="line"><a id="l00366" name="l00366"></a><span class="lineno"> 366</span> }</div>
<div class="line"><a id="l00367" name="l00367"></a><span class="lineno"> 367</span> </div>
<div class="line"><a id="l00368" name="l00368"></a><span class="lineno"> 368</span> <span class="comment">// Even if those two checks shall have been done before</span></div>
<div class="line"><a id="l00369" name="l00369"></a><span class="lineno"> 369</span> read_bytes = fread(&amp;tape_partition_header, 1, <span class="keyword">sizeof</span>(<a class="code hl_struct" href="structTapePartitionHeader.html">TapePartitionHeader</a>), ctx-&gt;<a class="code hl_variable" href="structaaruformat__context.html#ab516fae594bde4f76b75488d0a3ca3a8">imageStream</a>);</div>
<div class="line"><a id="l00370" name="l00370"></a><span class="lineno"> 370</span> </div>
<div class="line"><a id="l00371" name="l00371"></a><span class="lineno"> 371</span> <span class="keywordflow">if</span>(read_bytes != <span class="keyword">sizeof</span>(<a class="code hl_struct" href="structTapePartitionHeader.html">TapePartitionHeader</a>))</div>
<div class="line"><a id="l00372" name="l00372"></a><span class="lineno"> 372</span> {</div>
<div class="line"><a id="l00373" name="l00373"></a><span class="lineno"> 373</span> <a class="code hl_define" href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<span class="stringliteral">&quot;Could not read tape partitions header, continuing...&quot;</span>);</div>
<div class="line"><a id="l00374" name="l00374"></a><span class="lineno"> 374</span> <span class="keywordflow">return</span>;</div>
<div class="line"><a id="l00375" name="l00375"></a><span class="lineno"> 375</span> }</div>
<div class="line"><a id="l00376" name="l00376"></a><span class="lineno"> 376</span> </div>
<div class="line"><a id="l00377" name="l00377"></a><span class="lineno"> 377</span> <span class="keywordflow">if</span>(tape_partition_header.<a class="code hl_variable" href="structTapePartitionHeader.html#ace597fc284e2191b65e69eb0be9f99f6">identifier</a> != <a class="code hl_enumvalue" href="enums_8h.html#a54420623f26ab6bb61042b41cccf37a3a60609bbcd07339a8bf589e66ef4a3041">TapePartitionBlock</a>)</div>
<div class="line"><a id="l00378" name="l00378"></a><span class="lineno"> 378</span> {</div>
<div class="line"><a id="l00379" name="l00379"></a><span class="lineno"> 379</span> <a class="code hl_define" href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<span class="stringliteral">&quot;Incorrect identifier for data block at position %&quot;</span> PRIu64 <span class="stringliteral">&quot;\n&quot;</span>, entry-&gt;<a class="code hl_variable" href="structIndexEntry.html#a854951a64192d7e4cdcfa6dd6fd2b3ea">offset</a>);</div>
<div class="line"><a id="l00380" name="l00380"></a><span class="lineno"> 380</span> <span class="keywordflow">return</span>;</div>
<div class="line"><a id="l00381" name="l00381"></a><span class="lineno"> 381</span> }</div>
<div class="line"><a id="l00382" name="l00382"></a><span class="lineno"> 382</span> </div>
<div class="line"><a id="l00383" name="l00383"></a><span class="lineno"> 383</span> ctx-&gt;<a class="code hl_variable" href="structaaruformat__context.html#ac970291b3449c04221827b9c2c18ac70">image_info</a>.<a class="code hl_variable" href="structImageInfo.html#abca8e73a9655d810e6d30d36c3ab54d7">ImageSize</a> += <span class="keyword">sizeof</span>(<a class="code hl_struct" href="structTapePartitionEntry.html">TapePartitionEntry</a>) * tape_partition_header.<a class="code hl_variable" href="structTapePartitionHeader.html#a85cd855dac694aa7cf12177844d8b43e">entries</a>;</div>
<div class="line"><a id="l00384" name="l00384"></a><span class="lineno"> 384</span> </div>
<div class="line"><a id="l00385" name="l00385"></a><span class="lineno"> 385</span> uint8_t *buffer = malloc(<span class="keyword">sizeof</span>(<a class="code hl_struct" href="structTapePartitionEntry.html">TapePartitionEntry</a>) * tape_partition_header.<a class="code hl_variable" href="structTapePartitionHeader.html#a85cd855dac694aa7cf12177844d8b43e">entries</a>);</div>
<div class="line"><a id="l00386" name="l00386"></a><span class="lineno"> 386</span> <span class="keywordflow">if</span>(buffer == NULL)</div>
<div class="line"><a id="l00387" name="l00387"></a><span class="lineno"> 387</span> {</div>
<div class="line"><a id="l00388" name="l00388"></a><span class="lineno"> 388</span> <a class="code hl_define" href="log_8h.html#a053d6037d543b84ce59308ce71d15cd1">FATAL</a>(<span class="stringliteral">&quot;Could not allocate memory for tape partitions block, continuing...&quot;</span>);</div>
<div class="line"><a id="l00389" name="l00389"></a><span class="lineno"> 389</span> <span class="keywordflow">return</span>;</div>
<div class="line"><a id="l00390" name="l00390"></a><span class="lineno"> 390</span> }</div>
<div class="line"><a id="l00391" name="l00391"></a><span class="lineno"> 391</span> read_bytes = fread(buffer, <span class="keyword">sizeof</span>(<a class="code hl_struct" href="structTapePartitionEntry.html">TapePartitionEntry</a>), tape_partition_header.<a class="code hl_variable" href="structTapePartitionHeader.html#a85cd855dac694aa7cf12177844d8b43e">entries</a>, ctx-&gt;<a class="code hl_variable" href="structaaruformat__context.html#ab516fae594bde4f76b75488d0a3ca3a8">imageStream</a>);</div>
<div class="line"><a id="l00392" name="l00392"></a><span class="lineno"> 392</span> <span class="keywordflow">if</span>(read_bytes != tape_partition_header.<a class="code hl_variable" href="structTapePartitionHeader.html#a85cd855dac694aa7cf12177844d8b43e">entries</a>)</div>
<div class="line"><a id="l00393" name="l00393"></a><span class="lineno"> 393</span> {</div>
<div class="line"><a id="l00394" name="l00394"></a><span class="lineno"> 394</span> free(buffer);</div>
<div class="line"><a id="l00395" name="l00395"></a><span class="lineno"> 395</span> <a class="code hl_define" href="log_8h.html#a053d6037d543b84ce59308ce71d15cd1">FATAL</a>(<span class="stringliteral">&quot;Could not read tape partitions block, continuing...&quot;</span>);</div>
<div class="line"><a id="l00396" name="l00396"></a><span class="lineno"> 396</span> <span class="keywordflow">return</span>;</div>
<div class="line"><a id="l00397" name="l00397"></a><span class="lineno"> 397</span> }</div>
<div class="line"><a id="l00398" name="l00398"></a><span class="lineno"> 398</span> <span class="comment">// Check CRC64</span></div>
<div class="line"><a id="l00399" name="l00399"></a><span class="lineno"> 399</span> uint64_t crc64 = <a class="code hl_function" href="decls_8h.html#a0fee4834bf0747bcd933c4e754aa4692">aaruf_crc64_data</a>(buffer, <span class="keyword">sizeof</span>(<a class="code hl_struct" href="structTapePartitionEntry.html">TapePartitionEntry</a>) * tape_partition_header.<a class="code hl_variable" href="structTapePartitionHeader.html#a85cd855dac694aa7cf12177844d8b43e">entries</a>);</div>
<div class="line"><a id="l00400" name="l00400"></a><span class="lineno"> 400</span> </div>
<div class="line"><a id="l00401" name="l00401"></a><span class="lineno"> 401</span> <span class="keywordflow">if</span>(crc64 != tape_partition_header.<a class="code hl_variable" href="structTapePartitionHeader.html#a172a09251507f59bf607e4e2680f1bfc">crc64</a>)</div>
<div class="line"><a id="l00402" name="l00402"></a><span class="lineno"> 402</span> {</div>
<div class="line"><a id="l00403" name="l00403"></a><span class="lineno"> 403</span> <a class="code hl_define" href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<span class="stringliteral">&quot;Incorrect CRC found: 0x%&quot;</span> PRIx64 <span class="stringliteral">&quot; found, expected 0x%&quot;</span> PRIx64 <span class="stringliteral">&quot;, continuing...&quot;</span>, crc64,</div>
<div class="line"><a id="l00404" name="l00404"></a><span class="lineno"> 404</span> tape_partition_header.<a class="code hl_variable" href="structTapePartitionHeader.html#a172a09251507f59bf607e4e2680f1bfc">crc64</a>);</div>
<div class="line"><a id="l00405" name="l00405"></a><span class="lineno"> 405</span> free(buffer);</div>
<div class="line"><a id="l00406" name="l00406"></a><span class="lineno"> 406</span> <span class="keywordflow">return</span>;</div>
<div class="line"><a id="l00407" name="l00407"></a><span class="lineno"> 407</span> }</div>
<div class="line"><a id="l00408" name="l00408"></a><span class="lineno"> 408</span> </div>
<div class="line"><a id="l00409" name="l00409"></a><span class="lineno"> 409</span> <span class="comment">// Insert entries into UTHASH array indexed by partition</span></div>
<div class="line"><a id="l00410" name="l00410"></a><span class="lineno"> 410</span> <span class="keyword">const</span> <a class="code hl_struct" href="structTapePartitionEntry.html">TapePartitionEntry</a> *entries = (<a class="code hl_struct" href="structTapePartitionEntry.html">TapePartitionEntry</a> *)buffer;</div>
<div class="line"><a id="l00411" name="l00411"></a><span class="lineno"> 411</span> </div>
<div class="line"><a id="l00412" name="l00412"></a><span class="lineno"> 412</span> <span class="keywordflow">for</span>(uint32_t i = 0; i &lt; tape_partition_header.<a class="code hl_variable" href="structTapePartitionHeader.html#a85cd855dac694aa7cf12177844d8b43e">entries</a>; i++)</div>
<div class="line"><a id="l00413" name="l00413"></a><span class="lineno"> 413</span> {</div>
<div class="line"><a id="l00414" name="l00414"></a><span class="lineno"> 414</span> <span class="comment">// Create hash table entry</span></div>
<div class="line"><a id="l00415" name="l00415"></a><span class="lineno"> 415</span> <a class="code hl_struct" href="structTapePartitionHashEntry.html">TapePartitionHashEntry</a> *hash_entry = malloc(<span class="keyword">sizeof</span>(<a class="code hl_struct" href="structTapePartitionHashEntry.html">TapePartitionHashEntry</a>));</div>
<div class="line"><a id="l00416" name="l00416"></a><span class="lineno"> 416</span> <span class="keywordflow">if</span>(hash_entry == NULL)</div>
<div class="line"><a id="l00417" name="l00417"></a><span class="lineno"> 417</span> {</div>
<div class="line"><a id="l00418" name="l00418"></a><span class="lineno"> 418</span> <a class="code hl_define" href="log_8h.html#a053d6037d543b84ce59308ce71d15cd1">FATAL</a>(<span class="stringliteral">&quot;Could not allocate memory for tape partition hash entry&quot;</span>);</div>
<div class="line"><a id="l00419" name="l00419"></a><span class="lineno"> 419</span> <span class="keywordflow">continue</span>;</div>
<div class="line"><a id="l00420" name="l00420"></a><span class="lineno"> 420</span> }</div>
<div class="line"><a id="l00421" name="l00421"></a><span class="lineno"> 421</span> </div>
<div class="line"><a id="l00422" name="l00422"></a><span class="lineno"> 422</span> <span class="comment">// Create key: partition</span></div>
<div class="line"><a id="l00423" name="l00423"></a><span class="lineno"> 423</span> hash_entry-&gt;<a class="code hl_variable" href="structTapePartitionHashEntry.html#a6c817631a75a1b290d7e879c0cda5456">key</a> = entries[i].<a class="code hl_variable" href="structTapePartitionEntry.html#afb840f56fb39b1074f96715d102e2c0f">Number</a>;</div>
<div class="line"><a id="l00424" name="l00424"></a><span class="lineno"> 424</span> </div>
<div class="line"><a id="l00425" name="l00425"></a><span class="lineno"> 425</span> <span class="comment">// Copy the tape partition entry data</span></div>
<div class="line"><a id="l00426" name="l00426"></a><span class="lineno"> 426</span> hash_entry-&gt;<a class="code hl_variable" href="structTapePartitionHashEntry.html#af7c9f8904da9a0a21171ff3c04ec4379">partitionEntry</a> = entries[i];</div>
<div class="line"><a id="l00427" name="l00427"></a><span class="lineno"> 427</span> </div>
<div class="line"><a id="l00428" name="l00428"></a><span class="lineno"> 428</span> <span class="comment">// Replace if exists, add if new</span></div>
<div class="line"><a id="l00429" name="l00429"></a><span class="lineno"> 429</span> <a class="code hl_struct" href="structTapePartitionHashEntry.html">TapePartitionHashEntry</a> *old_entry = NULL;</div>
<div class="line"><a id="l00430" name="l00430"></a><span class="lineno"> 430</span> HASH_REPLACE(hh, ctx-&gt;<a class="code hl_variable" href="structaaruformat__context.html#ad7ca524fb6cece835566c268258b9a54">tape_partitions</a>, key, <span class="keyword">sizeof</span>(uint8_t), hash_entry, old_entry);</div>
<div class="line"><a id="l00431" name="l00431"></a><span class="lineno"> 431</span> </div>
<div class="line"><a id="l00432" name="l00432"></a><span class="lineno"> 432</span> <span class="comment">// Free old entry if it was replaced</span></div>
<div class="line"><a id="l00433" name="l00433"></a><span class="lineno"> 433</span> <span class="keywordflow">if</span>(old_entry != NULL)</div>
<div class="line"><a id="l00434" name="l00434"></a><span class="lineno"> 434</span> {</div>
<div class="line"><a id="l00435" name="l00435"></a><span class="lineno"> 435</span> <a class="code hl_define" href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<span class="stringliteral">&quot;Replaced existing tape partition entry for partition %u&quot;</span>, entries[i].Number);</div>
<div class="line"><a id="l00436" name="l00436"></a><span class="lineno"> 436</span> free(old_entry);</div>
<div class="line"><a id="l00437" name="l00437"></a><span class="lineno"> 437</span> }</div>
<div class="line"><a id="l00438" name="l00438"></a><span class="lineno"> 438</span> <span class="keywordflow">else</span></div>
<div class="line"><a id="l00439" name="l00439"></a><span class="lineno"> 439</span> <a class="code hl_define" href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<span class="stringliteral">&quot;Added new tape partition entry for partition %u&quot;</span>, entries[i].Number);</div>
<div class="line"><a id="l00440" name="l00440"></a><span class="lineno"> 440</span> }</div>
<div class="line"><a id="l00441" name="l00441"></a><span class="lineno"> 441</span> </div>
<div class="line"><a id="l00442" name="l00442"></a><span class="lineno"> 442</span> free(buffer);</div>
<div class="line"><a id="l00443" name="l00443"></a><span class="lineno"> 443</span>}</div>
</div>
<div class="line"><a id="l00444" name="l00444"></a><span class="lineno"> 444</span></div>
<div class="foldopen" id="foldopen00569" data-start="{" data-end="}">
<div class="line"><a id="l00569" name="l00569"></a><span class="lineno"><a class="line" href="decls_8h.html#a1c8d4faf14212a4c46c1fb47bf25ac1e"> 569</a></span><a class="code hl_define" href="decls_8h.html#a9001412c35f3c92d3a9320d27b0d97f9">AARU_EXPORT</a> int32_t <a class="code hl_define" href="decls_8h.html#a018e0da1c1f7e4f6187a982c0e40e056">AARU_CALL</a> <a class="code hl_function" href="tape_8c.html#a6221f89b294ca55944944a04edb964e3">aaruf_get_tape_file</a>(<span class="keyword">const</span> <span class="keywordtype">void</span> *context, <span class="keyword">const</span> uint8_t partition, <span class="keyword">const</span> uint32_t file,</div>
<div class="line"><a id="l00570" name="l00570"></a><span class="lineno"> 570</span> uint64_t *starting_block, uint64_t *ending_block)</div>
<div class="line"><a id="l00571" name="l00571"></a><span class="lineno"> 571</span>{</div>
<div class="line"><a id="l00572" name="l00572"></a><span class="lineno"> 572</span> <a class="code hl_define" href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<span class="stringliteral">&quot;Entering aaruf_get_tape_file(%p, %d, %d, %llu, %llu)&quot;</span>, context, partition, file, *starting_block,</div>
<div class="line"><a id="l00573" name="l00573"></a><span class="lineno"> 573</span> *ending_block);</div>
<div class="line"><a id="l00574" name="l00574"></a><span class="lineno"> 574</span> </div>
<div class="line"><a id="l00575" name="l00575"></a><span class="lineno"> 575</span> <span class="keyword">const</span> <a class="code hl_struct" href="structaaruformat__context.html">aaruformat_context</a> *ctx = NULL;</div>
<div class="line"><a id="l00576" name="l00576"></a><span class="lineno"> 576</span> </div>
<div class="line"><a id="l00577" name="l00577"></a><span class="lineno"> 577</span> <span class="keywordflow">if</span>(context == NULL)</div>
<div class="line"><a id="l00578" name="l00578"></a><span class="lineno"> 578</span> {</div>
<div class="line"><a id="l00579" name="l00579"></a><span class="lineno"> 579</span> <a class="code hl_define" href="log_8h.html#a053d6037d543b84ce59308ce71d15cd1">FATAL</a>(<span class="stringliteral">&quot;Invalid context&quot;</span>);</div>
<div class="line"><a id="l00580" name="l00580"></a><span class="lineno"> 580</span> </div>
<div class="line"><a id="l00581" name="l00581"></a><span class="lineno"> 581</span> <a class="code hl_define" href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<span class="stringliteral">&quot;Exiting aaruf_get_tape_file() = AARUF_ERROR_NOT_AARUFORMAT&quot;</span>);</div>
<div class="line"><a id="l00582" name="l00582"></a><span class="lineno"> 582</span> <span class="keywordflow">return</span> <a class="code hl_define" href="errors_8h.html#abb63e240b11d790da83bd34507b57851">AARUF_ERROR_NOT_AARUFORMAT</a>;</div>
<div class="line"><a id="l00583" name="l00583"></a><span class="lineno"> 583</span> }</div>
<div class="line"><a id="l00584" name="l00584"></a><span class="lineno"> 584</span> </div>
<div class="line"><a id="l00585" name="l00585"></a><span class="lineno"> 585</span> ctx = context;</div>
<div class="line"><a id="l00586" name="l00586"></a><span class="lineno"> 586</span> </div>
<div class="line"><a id="l00587" name="l00587"></a><span class="lineno"> 587</span> <span class="comment">// Not a libaaruformat context</span></div>
<div class="line"><a id="l00588" name="l00588"></a><span class="lineno"> 588</span> <span class="keywordflow">if</span>(ctx-&gt;<a class="code hl_variable" href="structaaruformat__context.html#a7dc0a0fe0bf6223ff4587fd01c360b76">magic</a> != <a class="code hl_define" href="consts_8h.html#a3c3ba66fe2b547655c9e4b16a1ba519a">AARU_MAGIC</a>)</div>
<div class="line"><a id="l00589" name="l00589"></a><span class="lineno"> 589</span> {</div>
<div class="line"><a id="l00590" name="l00590"></a><span class="lineno"> 590</span> <a class="code hl_define" href="log_8h.html#a053d6037d543b84ce59308ce71d15cd1">FATAL</a>(<span class="stringliteral">&quot;Invalid context&quot;</span>);</div>
<div class="line"><a id="l00591" name="l00591"></a><span class="lineno"> 591</span> </div>
<div class="line"><a id="l00592" name="l00592"></a><span class="lineno"> 592</span> <a class="code hl_define" href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<span class="stringliteral">&quot;Exiting aaruf_get_tape_file() = AARUF_ERROR_NOT_AARUFORMAT&quot;</span>);</div>
<div class="line"><a id="l00593" name="l00593"></a><span class="lineno"> 593</span> <span class="keywordflow">return</span> <a class="code hl_define" href="errors_8h.html#abb63e240b11d790da83bd34507b57851">AARUF_ERROR_NOT_AARUFORMAT</a>;</div>
<div class="line"><a id="l00594" name="l00594"></a><span class="lineno"> 594</span> }</div>
<div class="line"><a id="l00595" name="l00595"></a><span class="lineno"> 595</span> </div>
<div class="line"><a id="l00596" name="l00596"></a><span class="lineno"> 596</span> uint64_t key = (uint64_t)partition &lt;&lt; 32 | file;</div>
<div class="line"><a id="l00597" name="l00597"></a><span class="lineno"> 597</span> <a class="code hl_typedef" href="context_8h.html#a5ba965cb003bc2d68a9f9e1c11225494">tapeFileHashEntry</a> *entry = NULL;</div>
<div class="line"><a id="l00598" name="l00598"></a><span class="lineno"> 598</span> HASH_FIND(hh, ctx-&gt;<a class="code hl_variable" href="structaaruformat__context.html#a4783c528aec3e854986885077c5d5854">tape_files</a>, &amp;key, <span class="keyword">sizeof</span>(uint64_t), entry);</div>
<div class="line"><a id="l00599" name="l00599"></a><span class="lineno"> 599</span> </div>
<div class="line"><a id="l00600" name="l00600"></a><span class="lineno"> 600</span> <span class="keywordflow">if</span>(entry == NULL)</div>
<div class="line"><a id="l00601" name="l00601"></a><span class="lineno"> 601</span> {</div>
<div class="line"><a id="l00602" name="l00602"></a><span class="lineno"> 602</span> <a class="code hl_define" href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<span class="stringliteral">&quot;Tape file not found&quot;</span>);</div>
<div class="line"><a id="l00603" name="l00603"></a><span class="lineno"> 603</span> <span class="keywordflow">return</span> <a class="code hl_define" href="errors_8h.html#a64fa67cb4d9323e914641c70c731a5b2">AARUF_ERROR_TAPE_FILE_NOT_FOUND</a>;</div>
<div class="line"><a id="l00604" name="l00604"></a><span class="lineno"> 604</span> }</div>
<div class="line"><a id="l00605" name="l00605"></a><span class="lineno"> 605</span> </div>
<div class="line"><a id="l00606" name="l00606"></a><span class="lineno"> 606</span> *starting_block = entry-&gt;<a class="code hl_variable" href="structTapeFileHashEntry.html#aff0f81d26d4ee00ad33331aacc2834e1">fileEntry</a>.<a class="code hl_variable" href="structTapeFileEntry.html#a8bc76d9c2d9c43e14680e39d3fc728ca">FirstBlock</a>;</div>
<div class="line"><a id="l00607" name="l00607"></a><span class="lineno"> 607</span> *ending_block = entry-&gt;<a class="code hl_variable" href="structTapeFileHashEntry.html#aff0f81d26d4ee00ad33331aacc2834e1">fileEntry</a>.<a class="code hl_variable" href="structTapeFileEntry.html#a7cd5974b8f4d7bf691428d856be1e54b">LastBlock</a>;</div>
<div class="line"><a id="l00608" name="l00608"></a><span class="lineno"> 608</span> </div>
<div class="line"><a id="l00609" name="l00609"></a><span class="lineno"> 609</span> <a class="code hl_define" href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<span class="stringliteral">&quot;Exiting aaruf_get_tape_file(%p, %d, %d, %llu, %llu) = AARUF_STATUS_OK&quot;</span>, context, partition, file,</div>
<div class="line"><a id="l00610" name="l00610"></a><span class="lineno"> 610</span> *starting_block, *ending_block);</div>
<div class="line"><a id="l00611" name="l00611"></a><span class="lineno"> 611</span> <span class="keywordflow">return</span> <a class="code hl_define" href="errors_8h.html#a1d6e49f7e8a1fa489efa0a582e90b5de">AARUF_STATUS_OK</a>;</div>
<div class="line"><a id="l00612" name="l00612"></a><span class="lineno"> 612</span>}</div>
</div>
<div class="line"><a id="l00613" name="l00613"></a><span class="lineno"> 613</span></div>
<div class="foldopen" id="foldopen00770" data-start="{" data-end="}">
<div class="line"><a id="l00770" name="l00770"></a><span class="lineno"><a class="line" href="decls_8h.html#a01c915ab49a4b47fd6768a2055208c48"> 770</a></span><a class="code hl_define" href="decls_8h.html#a9001412c35f3c92d3a9320d27b0d97f9">AARU_EXPORT</a> int32_t <a class="code hl_define" href="decls_8h.html#a018e0da1c1f7e4f6187a982c0e40e056">AARU_CALL</a> <a class="code hl_function" href="tape_8c.html#a03d080a18e07adc52a654dc31b26eea0">aaruf_set_tape_file</a>(<span class="keywordtype">void</span> *context, <span class="keyword">const</span> uint8_t partition, <span class="keyword">const</span> uint32_t file,</div>
<div class="line"><a id="l00771" name="l00771"></a><span class="lineno"> 771</span> <span class="keyword">const</span> uint64_t starting_block, <span class="keyword">const</span> uint64_t ending_block)</div>
<div class="line"><a id="l00772" name="l00772"></a><span class="lineno"> 772</span>{</div>
<div class="line"><a id="l00773" name="l00773"></a><span class="lineno"> 773</span> <a class="code hl_define" href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<span class="stringliteral">&quot;Entering aaruf_set_tape_file(%p, %d, %d, %llu, %llu)&quot;</span>, context, partition, file, starting_block,</div>
<div class="line"><a id="l00774" name="l00774"></a><span class="lineno"> 774</span> ending_block);</div>
<div class="line"><a id="l00775" name="l00775"></a><span class="lineno"> 775</span> </div>
<div class="line"><a id="l00776" name="l00776"></a><span class="lineno"> 776</span> <a class="code hl_struct" href="structaaruformat__context.html">aaruformat_context</a> *ctx = NULL;</div>
<div class="line"><a id="l00777" name="l00777"></a><span class="lineno"> 777</span> </div>
<div class="line"><a id="l00778" name="l00778"></a><span class="lineno"> 778</span> <span class="keywordflow">if</span>(context == NULL)</div>
<div class="line"><a id="l00779" name="l00779"></a><span class="lineno"> 779</span> {</div>
<div class="line"><a id="l00780" name="l00780"></a><span class="lineno"> 780</span> <a class="code hl_define" href="log_8h.html#a053d6037d543b84ce59308ce71d15cd1">FATAL</a>(<span class="stringliteral">&quot;Invalid context&quot;</span>);</div>
<div class="line"><a id="l00781" name="l00781"></a><span class="lineno"> 781</span> </div>
<div class="line"><a id="l00782" name="l00782"></a><span class="lineno"> 782</span> <a class="code hl_define" href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<span class="stringliteral">&quot;Exiting aaruf_set_tape_file() = AARUF_ERROR_NOT_AARUFORMAT&quot;</span>);</div>
<div class="line"><a id="l00783" name="l00783"></a><span class="lineno"> 783</span> <span class="keywordflow">return</span> <a class="code hl_define" href="errors_8h.html#abb63e240b11d790da83bd34507b57851">AARUF_ERROR_NOT_AARUFORMAT</a>;</div>
<div class="line"><a id="l00784" name="l00784"></a><span class="lineno"> 784</span> }</div>
<div class="line"><a id="l00785" name="l00785"></a><span class="lineno"> 785</span> </div>
<div class="line"><a id="l00786" name="l00786"></a><span class="lineno"> 786</span> ctx = context;</div>
<div class="line"><a id="l00787" name="l00787"></a><span class="lineno"> 787</span> </div>
<div class="line"><a id="l00788" name="l00788"></a><span class="lineno"> 788</span> <span class="comment">// Not a libaaruformat context</span></div>
<div class="line"><a id="l00789" name="l00789"></a><span class="lineno"> 789</span> <span class="keywordflow">if</span>(ctx-&gt;<a class="code hl_variable" href="structaaruformat__context.html#a7dc0a0fe0bf6223ff4587fd01c360b76">magic</a> != <a class="code hl_define" href="consts_8h.html#a3c3ba66fe2b547655c9e4b16a1ba519a">AARU_MAGIC</a>)</div>
<div class="line"><a id="l00790" name="l00790"></a><span class="lineno"> 790</span> {</div>
<div class="line"><a id="l00791" name="l00791"></a><span class="lineno"> 791</span> <a class="code hl_define" href="log_8h.html#a053d6037d543b84ce59308ce71d15cd1">FATAL</a>(<span class="stringliteral">&quot;Invalid context&quot;</span>);</div>
<div class="line"><a id="l00792" name="l00792"></a><span class="lineno"> 792</span> </div>
<div class="line"><a id="l00793" name="l00793"></a><span class="lineno"> 793</span> <a class="code hl_define" href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<span class="stringliteral">&quot;Exiting aaruf_set_tape_file() = AARUF_ERROR_NOT_AARUFORMAT&quot;</span>);</div>
<div class="line"><a id="l00794" name="l00794"></a><span class="lineno"> 794</span> <span class="keywordflow">return</span> <a class="code hl_define" href="errors_8h.html#abb63e240b11d790da83bd34507b57851">AARUF_ERROR_NOT_AARUFORMAT</a>;</div>
<div class="line"><a id="l00795" name="l00795"></a><span class="lineno"> 795</span> }</div>
<div class="line"><a id="l00796" name="l00796"></a><span class="lineno"> 796</span> </div>
<div class="line"><a id="l00797" name="l00797"></a><span class="lineno"> 797</span> <span class="comment">// Check we are writing</span></div>
<div class="line"><a id="l00798" name="l00798"></a><span class="lineno"> 798</span> <span class="keywordflow">if</span>(!ctx-&gt;<a class="code hl_variable" href="structaaruformat__context.html#a6f61f9ea20f4e3b791a0d6388dd43651">is_writing</a>)</div>
<div class="line"><a id="l00799" name="l00799"></a><span class="lineno"> 799</span> {</div>
<div class="line"><a id="l00800" name="l00800"></a><span class="lineno"> 800</span> <a class="code hl_define" href="log_8h.html#a053d6037d543b84ce59308ce71d15cd1">FATAL</a>(<span class="stringliteral">&quot;Trying to write a read-only image&quot;</span>);</div>
<div class="line"><a id="l00801" name="l00801"></a><span class="lineno"> 801</span> </div>
<div class="line"><a id="l00802" name="l00802"></a><span class="lineno"> 802</span> <a class="code hl_define" href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<span class="stringliteral">&quot;Exiting aaruf_set_tape_file() = AARUF_READ_ONLY&quot;</span>);</div>
<div class="line"><a id="l00803" name="l00803"></a><span class="lineno"> 803</span> <span class="keywordflow">return</span> <a class="code hl_define" href="errors_8h.html#a1df49eaa19eaa14891b6aaab966a9bc6">AARUF_READ_ONLY</a>;</div>
<div class="line"><a id="l00804" name="l00804"></a><span class="lineno"> 804</span> }</div>
<div class="line"><a id="l00805" name="l00805"></a><span class="lineno"> 805</span> </div>
<div class="line"><a id="l00806" name="l00806"></a><span class="lineno"> 806</span> <span class="comment">// Create hash table entry</span></div>
<div class="line"><a id="l00807" name="l00807"></a><span class="lineno"> 807</span> <a class="code hl_typedef" href="context_8h.html#a5ba965cb003bc2d68a9f9e1c11225494">tapeFileHashEntry</a> *hash_entry = malloc(<span class="keyword">sizeof</span>(<a class="code hl_typedef" href="context_8h.html#a5ba965cb003bc2d68a9f9e1c11225494">tapeFileHashEntry</a>));</div>
<div class="line"><a id="l00808" name="l00808"></a><span class="lineno"> 808</span> <span class="keywordflow">if</span>(hash_entry == NULL)</div>
<div class="line"><a id="l00809" name="l00809"></a><span class="lineno"> 809</span> {</div>
<div class="line"><a id="l00810" name="l00810"></a><span class="lineno"> 810</span> <a class="code hl_define" href="log_8h.html#a053d6037d543b84ce59308ce71d15cd1">FATAL</a>(<span class="stringliteral">&quot;Could not allocate memory for tape file hash entry&quot;</span>);</div>
<div class="line"><a id="l00811" name="l00811"></a><span class="lineno"> 811</span> </div>
<div class="line"><a id="l00812" name="l00812"></a><span class="lineno"> 812</span> <a class="code hl_define" href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<span class="stringliteral">&quot;Exiting aaruf_set_tape_file() = AARUF_ERROR_NOT_ENOUGH_MEMORY&quot;</span>);</div>
<div class="line"><a id="l00813" name="l00813"></a><span class="lineno"> 813</span> <span class="keywordflow">return</span> <a class="code hl_define" href="errors_8h.html#a35a771e3648bf971a004d4b2be9b5ec4">AARUF_ERROR_NOT_ENOUGH_MEMORY</a>;</div>
<div class="line"><a id="l00814" name="l00814"></a><span class="lineno"> 814</span> }</div>
<div class="line"><a id="l00815" name="l00815"></a><span class="lineno"> 815</span> </div>
<div class="line"><a id="l00816" name="l00816"></a><span class="lineno"> 816</span> <span class="comment">// Create composite key: partition &lt;&lt; 32 | file number</span></div>
<div class="line"><a id="l00817" name="l00817"></a><span class="lineno"> 817</span> hash_entry-&gt;<a class="code hl_variable" href="structTapeFileHashEntry.html#a5556a05025c18c16e3bb45026b2246e0">key</a> = (uint64_t)partition &lt;&lt; 32 | file;</div>
<div class="line"><a id="l00818" name="l00818"></a><span class="lineno"> 818</span> </div>
<div class="line"><a id="l00819" name="l00819"></a><span class="lineno"> 819</span> <span class="comment">// Copy the tape file entry data</span></div>
<div class="line"><a id="l00820" name="l00820"></a><span class="lineno"> 820</span> hash_entry-&gt;<a class="code hl_variable" href="structTapeFileHashEntry.html#aff0f81d26d4ee00ad33331aacc2834e1">fileEntry</a>.<a class="code hl_variable" href="structTapeFileEntry.html#a1e5786e5762aaecbd270f9e26777f344">File</a> = file;</div>
<div class="line"><a id="l00821" name="l00821"></a><span class="lineno"> 821</span> hash_entry-&gt;<a class="code hl_variable" href="structTapeFileHashEntry.html#aff0f81d26d4ee00ad33331aacc2834e1">fileEntry</a>.<a class="code hl_variable" href="structTapeFileEntry.html#acef4f9b9acac33d1e5f08f6cd62afab3">Partition</a> = partition;</div>
<div class="line"><a id="l00822" name="l00822"></a><span class="lineno"> 822</span> hash_entry-&gt;<a class="code hl_variable" href="structTapeFileHashEntry.html#aff0f81d26d4ee00ad33331aacc2834e1">fileEntry</a>.<a class="code hl_variable" href="structTapeFileEntry.html#a8bc76d9c2d9c43e14680e39d3fc728ca">FirstBlock</a> = starting_block;</div>
<div class="line"><a id="l00823" name="l00823"></a><span class="lineno"> 823</span> hash_entry-&gt;<a class="code hl_variable" href="structTapeFileHashEntry.html#aff0f81d26d4ee00ad33331aacc2834e1">fileEntry</a>.<a class="code hl_variable" href="structTapeFileEntry.html#a7cd5974b8f4d7bf691428d856be1e54b">LastBlock</a> = ending_block;</div>
<div class="line"><a id="l00824" name="l00824"></a><span class="lineno"> 824</span> </div>
<div class="line"><a id="l00825" name="l00825"></a><span class="lineno"> 825</span> <span class="comment">// Replace if exists, add if new</span></div>
<div class="line"><a id="l00826" name="l00826"></a><span class="lineno"> 826</span> <a class="code hl_typedef" href="context_8h.html#a5ba965cb003bc2d68a9f9e1c11225494">tapeFileHashEntry</a> *old_entry = NULL;</div>
<div class="line"><a id="l00827" name="l00827"></a><span class="lineno"> 827</span> HASH_REPLACE(hh, ctx-&gt;<a class="code hl_variable" href="structaaruformat__context.html#a4783c528aec3e854986885077c5d5854">tape_files</a>, key, <span class="keyword">sizeof</span>(uint64_t), hash_entry, old_entry);</div>
<div class="line"><a id="l00828" name="l00828"></a><span class="lineno"> 828</span> </div>
<div class="line"><a id="l00829" name="l00829"></a><span class="lineno"> 829</span> <span class="comment">// Free old entry if it was replaced</span></div>
<div class="line"><a id="l00830" name="l00830"></a><span class="lineno"> 830</span> <span class="keywordflow">if</span>(old_entry != NULL)</div>
<div class="line"><a id="l00831" name="l00831"></a><span class="lineno"> 831</span> {</div>
<div class="line"><a id="l00832" name="l00832"></a><span class="lineno"> 832</span> <a class="code hl_define" href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<span class="stringliteral">&quot;Replaced existing tape file entry for partition %u, file %u&quot;</span>, partition, file);</div>
<div class="line"><a id="l00833" name="l00833"></a><span class="lineno"> 833</span> free(old_entry);</div>
<div class="line"><a id="l00834" name="l00834"></a><span class="lineno"> 834</span> }</div>
<div class="line"><a id="l00835" name="l00835"></a><span class="lineno"> 835</span> <span class="keywordflow">else</span></div>
<div class="line"><a id="l00836" name="l00836"></a><span class="lineno"> 836</span> <a class="code hl_define" href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<span class="stringliteral">&quot;Added new tape file entry for partition %u, file %u&quot;</span>, partition, file);</div>
<div class="line"><a id="l00837" name="l00837"></a><span class="lineno"> 837</span> </div>
<div class="line"><a id="l00838" name="l00838"></a><span class="lineno"> 838</span> <a class="code hl_define" href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<span class="stringliteral">&quot;Exiting aaruf_set_tape_file(%p, %d, %d, %llu, %llu) = AARUF_STATUS_OK&quot;</span>, context, partition, file,</div>
<div class="line"><a id="l00839" name="l00839"></a><span class="lineno"> 839</span> starting_block, ending_block);</div>
<div class="line"><a id="l00840" name="l00840"></a><span class="lineno"> 840</span> <span class="keywordflow">return</span> <a class="code hl_define" href="errors_8h.html#a1d6e49f7e8a1fa489efa0a582e90b5de">AARUF_STATUS_OK</a>;</div>
<div class="line"><a id="l00841" name="l00841"></a><span class="lineno"> 841</span>}</div>
</div>
<div class="line"><a id="l00842" name="l00842"></a><span class="lineno"> 842</span></div>
<div class="foldopen" id="foldopen00982" data-start="{" data-end="}">
<div class="line"><a id="l00982" name="l00982"></a><span class="lineno"><a class="line" href="decls_8h.html#ab1ca1a092699df0f43ea050812f6c6b1"> 982</a></span><a class="code hl_define" href="decls_8h.html#a9001412c35f3c92d3a9320d27b0d97f9">AARU_EXPORT</a> int32_t <a class="code hl_define" href="decls_8h.html#a018e0da1c1f7e4f6187a982c0e40e056">AARU_CALL</a> <a class="code hl_function" href="tape_8c.html#a91c40d91fdeb98193d6eeb95f16d8973">aaruf_get_tape_partition</a>(<span class="keyword">const</span> <span class="keywordtype">void</span> *context, <span class="keyword">const</span> uint8_t partition,</div>
<div class="line"><a id="l00983" name="l00983"></a><span class="lineno"> 983</span> uint64_t *starting_block, uint64_t *ending_block)</div>
<div class="line"><a id="l00984" name="l00984"></a><span class="lineno"> 984</span>{</div>
<div class="line"><a id="l00985" name="l00985"></a><span class="lineno"> 985</span> <a class="code hl_define" href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<span class="stringliteral">&quot;Entering aaruf_get_tape_partition(%p, %d, %llu, %llu)&quot;</span>, context, partition, *starting_block, *ending_block);</div>
<div class="line"><a id="l00986" name="l00986"></a><span class="lineno"> 986</span> </div>
<div class="line"><a id="l00987" name="l00987"></a><span class="lineno"> 987</span> <span class="keyword">const</span> <a class="code hl_struct" href="structaaruformat__context.html">aaruformat_context</a> *ctx = NULL;</div>
<div class="line"><a id="l00988" name="l00988"></a><span class="lineno"> 988</span> </div>
<div class="line"><a id="l00989" name="l00989"></a><span class="lineno"> 989</span> <span class="keywordflow">if</span>(context == NULL)</div>
<div class="line"><a id="l00990" name="l00990"></a><span class="lineno"> 990</span> {</div>
<div class="line"><a id="l00991" name="l00991"></a><span class="lineno"> 991</span> <a class="code hl_define" href="log_8h.html#a053d6037d543b84ce59308ce71d15cd1">FATAL</a>(<span class="stringliteral">&quot;Invalid context&quot;</span>);</div>
<div class="line"><a id="l00992" name="l00992"></a><span class="lineno"> 992</span> </div>
<div class="line"><a id="l00993" name="l00993"></a><span class="lineno"> 993</span> <a class="code hl_define" href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<span class="stringliteral">&quot;Exiting aaruf_get_tape_partition() = AARUF_ERROR_NOT_AARUFORMAT&quot;</span>);</div>
<div class="line"><a id="l00994" name="l00994"></a><span class="lineno"> 994</span> <span class="keywordflow">return</span> <a class="code hl_define" href="errors_8h.html#abb63e240b11d790da83bd34507b57851">AARUF_ERROR_NOT_AARUFORMAT</a>;</div>
<div class="line"><a id="l00995" name="l00995"></a><span class="lineno"> 995</span> }</div>
<div class="line"><a id="l00996" name="l00996"></a><span class="lineno"> 996</span> </div>
<div class="line"><a id="l00997" name="l00997"></a><span class="lineno"> 997</span> ctx = context;</div>
<div class="line"><a id="l00998" name="l00998"></a><span class="lineno"> 998</span> </div>
<div class="line"><a id="l00999" name="l00999"></a><span class="lineno"> 999</span> <span class="comment">// Not a libaaruformat context</span></div>
<div class="line"><a id="l01000" name="l01000"></a><span class="lineno"> 1000</span> <span class="keywordflow">if</span>(ctx-&gt;<a class="code hl_variable" href="structaaruformat__context.html#a7dc0a0fe0bf6223ff4587fd01c360b76">magic</a> != <a class="code hl_define" href="consts_8h.html#a3c3ba66fe2b547655c9e4b16a1ba519a">AARU_MAGIC</a>)</div>
<div class="line"><a id="l01001" name="l01001"></a><span class="lineno"> 1001</span> {</div>
<div class="line"><a id="l01002" name="l01002"></a><span class="lineno"> 1002</span> <a class="code hl_define" href="log_8h.html#a053d6037d543b84ce59308ce71d15cd1">FATAL</a>(<span class="stringliteral">&quot;Invalid context&quot;</span>);</div>
<div class="line"><a id="l01003" name="l01003"></a><span class="lineno"> 1003</span> </div>
<div class="line"><a id="l01004" name="l01004"></a><span class="lineno"> 1004</span> <a class="code hl_define" href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<span class="stringliteral">&quot;Exiting aaruf_get_tape_partition() = AARUF_ERROR_NOT_AARUFORMAT&quot;</span>);</div>
<div class="line"><a id="l01005" name="l01005"></a><span class="lineno"> 1005</span> <span class="keywordflow">return</span> <a class="code hl_define" href="errors_8h.html#abb63e240b11d790da83bd34507b57851">AARUF_ERROR_NOT_AARUFORMAT</a>;</div>
<div class="line"><a id="l01006" name="l01006"></a><span class="lineno"> 1006</span> }</div>
<div class="line"><a id="l01007" name="l01007"></a><span class="lineno"> 1007</span> </div>
<div class="line"><a id="l01008" name="l01008"></a><span class="lineno"> 1008</span> uint8_t key = partition;</div>
<div class="line"><a id="l01009" name="l01009"></a><span class="lineno"> 1009</span> <a class="code hl_struct" href="structTapePartitionHashEntry.html">TapePartitionHashEntry</a> *entry = NULL;</div>
<div class="line"><a id="l01010" name="l01010"></a><span class="lineno"> 1010</span> HASH_FIND(hh, ctx-&gt;<a class="code hl_variable" href="structaaruformat__context.html#ad7ca524fb6cece835566c268258b9a54">tape_partitions</a>, &amp;key, <span class="keyword">sizeof</span>(uint8_t), entry);</div>
<div class="line"><a id="l01011" name="l01011"></a><span class="lineno"> 1011</span> </div>
<div class="line"><a id="l01012" name="l01012"></a><span class="lineno"> 1012</span> <span class="keywordflow">if</span>(entry == NULL)</div>
<div class="line"><a id="l01013" name="l01013"></a><span class="lineno"> 1013</span> {</div>
<div class="line"><a id="l01014" name="l01014"></a><span class="lineno"> 1014</span> <a class="code hl_define" href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<span class="stringliteral">&quot;Tape partition not found&quot;</span>);</div>
<div class="line"><a id="l01015" name="l01015"></a><span class="lineno"> 1015</span> <span class="keywordflow">return</span> <a class="code hl_define" href="errors_8h.html#a14db41b6e45622397fa6339bc79d2b9f">AARUF_ERROR_TAPE_PARTITION_NOT_FOUND</a>;</div>
<div class="line"><a id="l01016" name="l01016"></a><span class="lineno"> 1016</span> }</div>
<div class="line"><a id="l01017" name="l01017"></a><span class="lineno"> 1017</span> </div>
<div class="line"><a id="l01018" name="l01018"></a><span class="lineno"> 1018</span> *starting_block = entry-&gt;<a class="code hl_variable" href="structTapePartitionHashEntry.html#af7c9f8904da9a0a21171ff3c04ec4379">partitionEntry</a>.<a class="code hl_variable" href="structTapePartitionEntry.html#af2cdde924cd050523ad0fb453eb5842d">FirstBlock</a>;</div>
<div class="line"><a id="l01019" name="l01019"></a><span class="lineno"> 1019</span> *ending_block = entry-&gt;<a class="code hl_variable" href="structTapePartitionHashEntry.html#af7c9f8904da9a0a21171ff3c04ec4379">partitionEntry</a>.<a class="code hl_variable" href="structTapePartitionEntry.html#a19aec00f3d7b0850bf49b055dbcc837d">LastBlock</a>;</div>
<div class="line"><a id="l01020" name="l01020"></a><span class="lineno"> 1020</span> </div>
<div class="line"><a id="l01021" name="l01021"></a><span class="lineno"> 1021</span> <a class="code hl_define" href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<span class="stringliteral">&quot;Exiting aaruf_get_tape_partition(%p, %d, %llu, %llu) = AARUF_STATUS_OK&quot;</span>, context, partition, *starting_block,</div>
<div class="line"><a id="l01022" name="l01022"></a><span class="lineno"> 1022</span> *ending_block);</div>
<div class="line"><a id="l01023" name="l01023"></a><span class="lineno"> 1023</span> <span class="keywordflow">return</span> <a class="code hl_define" href="errors_8h.html#a1d6e49f7e8a1fa489efa0a582e90b5de">AARUF_STATUS_OK</a>;</div>
<div class="line"><a id="l01024" name="l01024"></a><span class="lineno"> 1024</span>}</div>
</div>
<div class="line"><a id="l01025" name="l01025"></a><span class="lineno"> 1025</span></div>
<div class="foldopen" id="foldopen01196" data-start="{" data-end="}">
<div class="line"><a id="l01196" name="l01196"></a><span class="lineno"><a class="line" href="decls_8h.html#a9daeeb54c74dd2707d95ab47e8ab0a00"> 1196</a></span><a class="code hl_define" href="decls_8h.html#a9001412c35f3c92d3a9320d27b0d97f9">AARU_EXPORT</a> int32_t <a class="code hl_define" href="decls_8h.html#a018e0da1c1f7e4f6187a982c0e40e056">AARU_CALL</a> <a class="code hl_function" href="tape_8c.html#aa16d4457093df66246ce5622c3565a17">aaruf_set_tape_partition</a>(<span class="keywordtype">void</span> *context, <span class="keyword">const</span> uint8_t partition,</div>
<div class="line"><a id="l01197" name="l01197"></a><span class="lineno"> 1197</span> <span class="keyword">const</span> uint64_t starting_block, <span class="keyword">const</span> uint64_t ending_block)</div>
<div class="line"><a id="l01198" name="l01198"></a><span class="lineno"> 1198</span>{</div>
<div class="line"><a id="l01199" name="l01199"></a><span class="lineno"> 1199</span> <a class="code hl_define" href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<span class="stringliteral">&quot;Entering aaruf_set_tape_partition(%p, %d, %llu, %llu)&quot;</span>, context, partition, starting_block, ending_block);</div>
<div class="line"><a id="l01200" name="l01200"></a><span class="lineno"> 1200</span> </div>
<div class="line"><a id="l01201" name="l01201"></a><span class="lineno"> 1201</span> <a class="code hl_struct" href="structaaruformat__context.html">aaruformat_context</a> *ctx = NULL;</div>
<div class="line"><a id="l01202" name="l01202"></a><span class="lineno"> 1202</span> </div>
<div class="line"><a id="l01203" name="l01203"></a><span class="lineno"> 1203</span> <span class="keywordflow">if</span>(context == NULL)</div>
<div class="line"><a id="l01204" name="l01204"></a><span class="lineno"> 1204</span> {</div>
<div class="line"><a id="l01205" name="l01205"></a><span class="lineno"> 1205</span> <a class="code hl_define" href="log_8h.html#a053d6037d543b84ce59308ce71d15cd1">FATAL</a>(<span class="stringliteral">&quot;Invalid context&quot;</span>);</div>
<div class="line"><a id="l01206" name="l01206"></a><span class="lineno"> 1206</span> </div>
<div class="line"><a id="l01207" name="l01207"></a><span class="lineno"> 1207</span> <a class="code hl_define" href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<span class="stringliteral">&quot;Exiting aaruf_set_tape_partition() = AARUF_ERROR_NOT_AARUFORMAT&quot;</span>);</div>
<div class="line"><a id="l01208" name="l01208"></a><span class="lineno"> 1208</span> <span class="keywordflow">return</span> <a class="code hl_define" href="errors_8h.html#abb63e240b11d790da83bd34507b57851">AARUF_ERROR_NOT_AARUFORMAT</a>;</div>
<div class="line"><a id="l01209" name="l01209"></a><span class="lineno"> 1209</span> }</div>
<div class="line"><a id="l01210" name="l01210"></a><span class="lineno"> 1210</span> </div>
<div class="line"><a id="l01211" name="l01211"></a><span class="lineno"> 1211</span> ctx = context;</div>
<div class="line"><a id="l01212" name="l01212"></a><span class="lineno"> 1212</span> </div>
<div class="line"><a id="l01213" name="l01213"></a><span class="lineno"> 1213</span> <span class="comment">// Not a libaaruformat context</span></div>
<div class="line"><a id="l01214" name="l01214"></a><span class="lineno"> 1214</span> <span class="keywordflow">if</span>(ctx-&gt;<a class="code hl_variable" href="structaaruformat__context.html#a7dc0a0fe0bf6223ff4587fd01c360b76">magic</a> != <a class="code hl_define" href="consts_8h.html#a3c3ba66fe2b547655c9e4b16a1ba519a">AARU_MAGIC</a>)</div>
<div class="line"><a id="l01215" name="l01215"></a><span class="lineno"> 1215</span> {</div>
<div class="line"><a id="l01216" name="l01216"></a><span class="lineno"> 1216</span> <a class="code hl_define" href="log_8h.html#a053d6037d543b84ce59308ce71d15cd1">FATAL</a>(<span class="stringliteral">&quot;Invalid context&quot;</span>);</div>
<div class="line"><a id="l01217" name="l01217"></a><span class="lineno"> 1217</span> </div>
<div class="line"><a id="l01218" name="l01218"></a><span class="lineno"> 1218</span> <a class="code hl_define" href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<span class="stringliteral">&quot;Exiting aaruf_set_tape_partition() = AARUF_ERROR_NOT_AARUFORMAT&quot;</span>);</div>
<div class="line"><a id="l01219" name="l01219"></a><span class="lineno"> 1219</span> <span class="keywordflow">return</span> <a class="code hl_define" href="errors_8h.html#abb63e240b11d790da83bd34507b57851">AARUF_ERROR_NOT_AARUFORMAT</a>;</div>
<div class="line"><a id="l01220" name="l01220"></a><span class="lineno"> 1220</span> }</div>
<div class="line"><a id="l01221" name="l01221"></a><span class="lineno"> 1221</span> </div>
<div class="line"><a id="l01222" name="l01222"></a><span class="lineno"> 1222</span> <span class="comment">// Check we are writing</span></div>
<div class="line"><a id="l01223" name="l01223"></a><span class="lineno"> 1223</span> <span class="keywordflow">if</span>(!ctx-&gt;<a class="code hl_variable" href="structaaruformat__context.html#a6f61f9ea20f4e3b791a0d6388dd43651">is_writing</a>)</div>
<div class="line"><a id="l01224" name="l01224"></a><span class="lineno"> 1224</span> {</div>
<div class="line"><a id="l01225" name="l01225"></a><span class="lineno"> 1225</span> <a class="code hl_define" href="log_8h.html#a053d6037d543b84ce59308ce71d15cd1">FATAL</a>(<span class="stringliteral">&quot;Trying to write a read-only image&quot;</span>);</div>
<div class="line"><a id="l01226" name="l01226"></a><span class="lineno"> 1226</span> </div>
<div class="line"><a id="l01227" name="l01227"></a><span class="lineno"> 1227</span> <a class="code hl_define" href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<span class="stringliteral">&quot;Exiting aaruf_set_tape_partition() = AARUF_READ_ONLY&quot;</span>);</div>
<div class="line"><a id="l01228" name="l01228"></a><span class="lineno"> 1228</span> <span class="keywordflow">return</span> <a class="code hl_define" href="errors_8h.html#a1df49eaa19eaa14891b6aaab966a9bc6">AARUF_READ_ONLY</a>;</div>
<div class="line"><a id="l01229" name="l01229"></a><span class="lineno"> 1229</span> }</div>
<div class="line"><a id="l01230" name="l01230"></a><span class="lineno"> 1230</span> </div>
<div class="line"><a id="l01231" name="l01231"></a><span class="lineno"> 1231</span> <span class="comment">// Create hash table entry</span></div>
<div class="line"><a id="l01232" name="l01232"></a><span class="lineno"> 1232</span> <a class="code hl_struct" href="structTapePartitionHashEntry.html">TapePartitionHashEntry</a> *hash_entry = malloc(<span class="keyword">sizeof</span>(<a class="code hl_struct" href="structTapePartitionHashEntry.html">TapePartitionHashEntry</a>));</div>
<div class="line"><a id="l01233" name="l01233"></a><span class="lineno"> 1233</span> <span class="keywordflow">if</span>(hash_entry == NULL)</div>
<div class="line"><a id="l01234" name="l01234"></a><span class="lineno"> 1234</span> {</div>
<div class="line"><a id="l01235" name="l01235"></a><span class="lineno"> 1235</span> <a class="code hl_define" href="log_8h.html#a053d6037d543b84ce59308ce71d15cd1">FATAL</a>(<span class="stringliteral">&quot;Could not allocate memory for tape partition hash entry&quot;</span>);</div>
<div class="line"><a id="l01236" name="l01236"></a><span class="lineno"> 1236</span> </div>
<div class="line"><a id="l01237" name="l01237"></a><span class="lineno"> 1237</span> <a class="code hl_define" href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<span class="stringliteral">&quot;Exiting aaruf_set_tape_partition() = AARUF_ERROR_NOT_ENOUGH_MEMORY&quot;</span>);</div>
<div class="line"><a id="l01238" name="l01238"></a><span class="lineno"> 1238</span> <span class="keywordflow">return</span> <a class="code hl_define" href="errors_8h.html#a35a771e3648bf971a004d4b2be9b5ec4">AARUF_ERROR_NOT_ENOUGH_MEMORY</a>;</div>
<div class="line"><a id="l01239" name="l01239"></a><span class="lineno"> 1239</span> }</div>
<div class="line"><a id="l01240" name="l01240"></a><span class="lineno"> 1240</span> </div>
<div class="line"><a id="l01241" name="l01241"></a><span class="lineno"> 1241</span> <span class="comment">// Create key: partition</span></div>
<div class="line"><a id="l01242" name="l01242"></a><span class="lineno"> 1242</span> hash_entry-&gt;<a class="code hl_variable" href="structTapePartitionHashEntry.html#a6c817631a75a1b290d7e879c0cda5456">key</a> = partition;</div>
<div class="line"><a id="l01243" name="l01243"></a><span class="lineno"> 1243</span> </div>
<div class="line"><a id="l01244" name="l01244"></a><span class="lineno"> 1244</span> <span class="comment">// Copy the tape partition entry data</span></div>
<div class="line"><a id="l01245" name="l01245"></a><span class="lineno"> 1245</span> hash_entry-&gt;<a class="code hl_variable" href="structTapePartitionHashEntry.html#af7c9f8904da9a0a21171ff3c04ec4379">partitionEntry</a>.<a class="code hl_variable" href="structTapePartitionEntry.html#afb840f56fb39b1074f96715d102e2c0f">Number</a> = partition;</div>
<div class="line"><a id="l01246" name="l01246"></a><span class="lineno"> 1246</span> hash_entry-&gt;<a class="code hl_variable" href="structTapePartitionHashEntry.html#af7c9f8904da9a0a21171ff3c04ec4379">partitionEntry</a>.<a class="code hl_variable" href="structTapePartitionEntry.html#af2cdde924cd050523ad0fb453eb5842d">FirstBlock</a> = starting_block;</div>
<div class="line"><a id="l01247" name="l01247"></a><span class="lineno"> 1247</span> hash_entry-&gt;<a class="code hl_variable" href="structTapePartitionHashEntry.html#af7c9f8904da9a0a21171ff3c04ec4379">partitionEntry</a>.<a class="code hl_variable" href="structTapePartitionEntry.html#a19aec00f3d7b0850bf49b055dbcc837d">LastBlock</a> = ending_block;</div>
<div class="line"><a id="l01248" name="l01248"></a><span class="lineno"> 1248</span> </div>
<div class="line"><a id="l01249" name="l01249"></a><span class="lineno"> 1249</span> <span class="comment">// Replace if exists, add if new</span></div>
<div class="line"><a id="l01250" name="l01250"></a><span class="lineno"> 1250</span> <a class="code hl_struct" href="structTapePartitionHashEntry.html">TapePartitionHashEntry</a> *old_entry = NULL;</div>
<div class="line"><a id="l01251" name="l01251"></a><span class="lineno"> 1251</span> HASH_REPLACE(hh, ctx-&gt;<a class="code hl_variable" href="structaaruformat__context.html#ad7ca524fb6cece835566c268258b9a54">tape_partitions</a>, key, <span class="keyword">sizeof</span>(uint8_t), hash_entry, old_entry);</div>
<div class="line"><a id="l01252" name="l01252"></a><span class="lineno"> 1252</span> </div>
<div class="line"><a id="l01253" name="l01253"></a><span class="lineno"> 1253</span> <span class="comment">// Free old entry if it was replaced</span></div>
<div class="line"><a id="l01254" name="l01254"></a><span class="lineno"> 1254</span> <span class="keywordflow">if</span>(old_entry != NULL)</div>
<div class="line"><a id="l01255" name="l01255"></a><span class="lineno"> 1255</span> {</div>
<div class="line"><a id="l01256" name="l01256"></a><span class="lineno"> 1256</span> <a class="code hl_define" href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<span class="stringliteral">&quot;Replaced existing tape partition entry for partition %u&quot;</span>, partition);</div>
<div class="line"><a id="l01257" name="l01257"></a><span class="lineno"> 1257</span> free(old_entry);</div>
<div class="line"><a id="l01258" name="l01258"></a><span class="lineno"> 1258</span> }</div>
<div class="line"><a id="l01259" name="l01259"></a><span class="lineno"> 1259</span> <span class="keywordflow">else</span></div>
<div class="line"><a id="l01260" name="l01260"></a><span class="lineno"> 1260</span> <a class="code hl_define" href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<span class="stringliteral">&quot;Added new tape partition entry for partition %u&quot;</span>, partition);</div>
<div class="line"><a id="l01261" name="l01261"></a><span class="lineno"> 1261</span> </div>
<div class="line"><a id="l01262" name="l01262"></a><span class="lineno"> 1262</span> <a class="code hl_define" href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a>(<span class="stringliteral">&quot;Exiting aaruf_set_tape_partition(%p, %d, %llu, %llu) = AARUF_STATUS_OK&quot;</span>, context, partition, starting_block,</div>
<div class="line"><a id="l01263" name="l01263"></a><span class="lineno"> 1263</span> ending_block);</div>
<div class="line"><a id="l01264" name="l01264"></a><span class="lineno"> 1264</span> <span class="keywordflow">return</span> <a class="code hl_define" href="errors_8h.html#a1d6e49f7e8a1fa489efa0a582e90b5de">AARUF_STATUS_OK</a>;</div>
<div class="line"><a id="l01265" name="l01265"></a><span class="lineno"> 1265</span>}</div>
</div>
<div class="ttc" id="aaaruformat_8h_html"><div class="ttname"><a href="aaruformat_8h.html">aaruformat.h</a></div></div>
<div class="ttc" id="aconsts_8h_html_a3c3ba66fe2b547655c9e4b16a1ba519a"><div class="ttname"><a href="consts_8h.html#a3c3ba66fe2b547655c9e4b16a1ba519a">AARU_MAGIC</a></div><div class="ttdeci">#define AARU_MAGIC</div><div class="ttdoc">Magic identifier for AaruFormat container (ASCII &quot;AARUFRMT&quot;).</div><div class="ttdef"><b>Definition</b> <a href="consts_8h_source.html#l00064">consts.h:64</a></div></div>
<div class="ttc" id="acontext_8h_html_a5ba965cb003bc2d68a9f9e1c11225494"><div class="ttname"><a href="context_8h.html#a5ba965cb003bc2d68a9f9e1c11225494">tapeFileHashEntry</a></div><div class="ttdeci">struct TapeFileHashEntry tapeFileHashEntry</div></div>
<div class="ttc" id="adecls_8h_html_a018e0da1c1f7e4f6187a982c0e40e056"><div class="ttname"><a href="decls_8h.html#a018e0da1c1f7e4f6187a982c0e40e056">AARU_CALL</a></div><div class="ttdeci">#define AARU_CALL</div><div class="ttdef"><b>Definition</b> <a href="decls_8h_source.html#l00045">decls.h:45</a></div></div>
<div class="ttc" id="adecls_8h_html_a0fee4834bf0747bcd933c4e754aa4692"><div class="ttname"><a href="decls_8h.html#a0fee4834bf0747bcd933c4e754aa4692">aaruf_crc64_data</a></div><div class="ttdeci">uint64_t aaruf_crc64_data(const uint8_t *data, uint32_t len)</div><div class="ttdef"><b>Definition</b> <a href="crc64_8c_source.html#l00160">crc64.c:160</a></div></div>
<div class="ttc" id="adecls_8h_html_a9001412c35f3c92d3a9320d27b0d97f9"><div class="ttname"><a href="decls_8h.html#a9001412c35f3c92d3a9320d27b0d97f9">AARU_EXPORT</a></div><div class="ttdeci">#define AARU_EXPORT</div><div class="ttdef"><b>Definition</b> <a href="decls_8h_source.html#l00054">decls.h:54</a></div></div>
<div class="ttc" id="aenums_8h_html_a54420623f26ab6bb61042b41cccf37a3a60609bbcd07339a8bf589e66ef4a3041"><div class="ttname"><a href="enums_8h.html#a54420623f26ab6bb61042b41cccf37a3a60609bbcd07339a8bf589e66ef4a3041">TapePartitionBlock</a></div><div class="ttdeci">@ TapePartitionBlock</div><div class="ttdoc">Block containing list of partitions for a tape image.</div><div class="ttdef"><b>Definition</b> <a href="enums_8h_source.html#l00158">enums.h:158</a></div></div>
<div class="ttc" id="aenums_8h_html_a54420623f26ab6bb61042b41cccf37a3ac3a117f2498bf736a76d5d3a3830540a"><div class="ttname"><a href="enums_8h.html#a54420623f26ab6bb61042b41cccf37a3ac3a117f2498bf736a76d5d3a3830540a">TapeFileBlock</a></div><div class="ttdeci">@ TapeFileBlock</div><div class="ttdoc">Block containing list of files for a tape image.</div><div class="ttdef"><b>Definition</b> <a href="enums_8h_source.html#l00157">enums.h:157</a></div></div>
<div class="ttc" id="aerrors_8h_html_a14db41b6e45622397fa6339bc79d2b9f"><div class="ttname"><a href="errors_8h.html#a14db41b6e45622397fa6339bc79d2b9f">AARUF_ERROR_TAPE_PARTITION_NOT_FOUND</a></div><div class="ttdeci">#define AARUF_ERROR_TAPE_PARTITION_NOT_FOUND</div><div class="ttdoc">Requested tape partition not present in image.</div><div class="ttdef"><b>Definition</b> <a href="errors_8h_source.html#l00068">errors.h:68</a></div></div>
<div class="ttc" id="aerrors_8h_html_a1d6e49f7e8a1fa489efa0a582e90b5de"><div class="ttname"><a href="errors_8h.html#a1d6e49f7e8a1fa489efa0a582e90b5de">AARUF_STATUS_OK</a></div><div class="ttdeci">#define AARUF_STATUS_OK</div><div class="ttdoc">Sector present and read without uncorrectable errors.</div><div class="ttdef"><b>Definition</b> <a href="errors_8h_source.html#l00075">errors.h:75</a></div></div>
<div class="ttc" id="aerrors_8h_html_a1df49eaa19eaa14891b6aaab966a9bc6"><div class="ttname"><a href="errors_8h.html#a1df49eaa19eaa14891b6aaab966a9bc6">AARUF_READ_ONLY</a></div><div class="ttdeci">#define AARUF_READ_ONLY</div><div class="ttdoc">Operation requires write mode but context is read-only.</div><div class="ttdef"><b>Definition</b> <a href="errors_8h_source.html#l00061">errors.h:61</a></div></div>
<div class="ttc" id="aerrors_8h_html_a35a771e3648bf971a004d4b2be9b5ec4"><div class="ttname"><a href="errors_8h.html#a35a771e3648bf971a004d4b2be9b5ec4">AARUF_ERROR_NOT_ENOUGH_MEMORY</a></div><div class="ttdeci">#define AARUF_ERROR_NOT_ENOUGH_MEMORY</div><div class="ttdoc">Memory allocation failure (critical).</div><div class="ttdef"><b>Definition</b> <a href="errors_8h_source.html#l00048">errors.h:48</a></div></div>
<div class="ttc" id="aerrors_8h_html_a64fa67cb4d9323e914641c70c731a5b2"><div class="ttname"><a href="errors_8h.html#a64fa67cb4d9323e914641c70c731a5b2">AARUF_ERROR_TAPE_FILE_NOT_FOUND</a></div><div class="ttdeci">#define AARUF_ERROR_TAPE_FILE_NOT_FOUND</div><div class="ttdoc">Requested tape file number not present in image.</div><div class="ttdef"><b>Definition</b> <a href="errors_8h_source.html#l00067">errors.h:67</a></div></div>
<div class="ttc" id="aerrors_8h_html_abb63e240b11d790da83bd34507b57851"><div class="ttname"><a href="errors_8h.html#abb63e240b11d790da83bd34507b57851">AARUF_ERROR_NOT_AARUFORMAT</a></div><div class="ttdeci">#define AARUF_ERROR_NOT_AARUFORMAT</div><div class="ttdoc">Input file/stream failed magic or structural validation.</div><div class="ttdef"><b>Definition</b> <a href="errors_8h_source.html#l00040">errors.h:40</a></div></div>
<div class="ttc" id="alog_8h_html"><div class="ttname"><a href="log_8h.html">log.h</a></div></div>
<div class="ttc" id="alog_8h_html_a053d6037d543b84ce59308ce71d15cd1"><div class="ttname"><a href="log_8h.html#a053d6037d543b84ce59308ce71d15cd1">FATAL</a></div><div class="ttdeci">#define FATAL(fmt,...)</div><div class="ttdef"><b>Definition</b> <a href="log_8h_source.html#l00040">log.h:40</a></div></div>
<div class="ttc" id="alog_8h_html_a21cc0459b78d5f2d7bd737e5aae1278a"><div class="ttname"><a href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a">TRACE</a></div><div class="ttdeci">#define TRACE(fmt,...)</div><div class="ttdef"><b>Definition</b> <a href="log_8h_source.html#l00025">log.h:25</a></div></div>
<div class="ttc" id="astructImageInfo_html_abca8e73a9655d810e6d30d36c3ab54d7"><div class="ttname"><a href="structImageInfo.html#abca8e73a9655d810e6d30d36c3ab54d7">ImageInfo::ImageSize</a></div><div class="ttdeci">uint64_t ImageSize</div><div class="ttdoc">Size of the image payload in bytes (excludes headers/metadata)</div><div class="ttdef"><b>Definition</b> <a href="aaru_8h_source.html#l00873">aaru.h:873</a></div></div>
<div class="ttc" id="astructIndexEntry_html"><div class="ttname"><a href="structIndexEntry.html">IndexEntry</a></div><div class="ttdoc">Single index entry describing a block&#39;s type, (optional) data classification, and file offset.</div><div class="ttdef"><b>Definition</b> <a href="index_8h_source.html#l00108">index.h:109</a></div></div>
<div class="ttc" id="astructIndexEntry_html_a854951a64192d7e4cdcfa6dd6fd2b3ea"><div class="ttname"><a href="structIndexEntry.html#a854951a64192d7e4cdcfa6dd6fd2b3ea">IndexEntry::offset</a></div><div class="ttdeci">uint64_t offset</div><div class="ttdoc">Absolute byte offset in the image where the referenced block header begins.</div><div class="ttdef"><b>Definition</b> <a href="index_8h_source.html#l00112">index.h:112</a></div></div>
<div class="ttc" id="astructTapeFileEntry_html"><div class="ttname"><a href="structTapeFileEntry.html">TapeFileEntry</a></div><div class="ttdoc">Describes a single logical file on a tape medium.</div><div class="ttdef"><b>Definition</b> <a href="tape_8h_source.html#l00133">tape.h:134</a></div></div>
<div class="ttc" id="astructTapeFileEntry_html_a1e5786e5762aaecbd270f9e26777f344"><div class="ttname"><a href="structTapeFileEntry.html#a1e5786e5762aaecbd270f9e26777f344">TapeFileEntry::File</a></div><div class="ttdeci">uint32_t File</div><div class="ttdoc">File number (unique within the partition).</div><div class="ttdef"><b>Definition</b> <a href="tape_8h_source.html#l00135">tape.h:135</a></div></div>
<div class="ttc" id="astructTapeFileEntry_html_a7cd5974b8f4d7bf691428d856be1e54b"><div class="ttname"><a href="structTapeFileEntry.html#a7cd5974b8f4d7bf691428d856be1e54b">TapeFileEntry::LastBlock</a></div><div class="ttdeci">uint64_t LastBlock</div><div class="ttdoc">Last block of the file (inclusive).</div><div class="ttdef"><b>Definition</b> <a href="tape_8h_source.html#l00142">tape.h:142</a></div></div>
<div class="ttc" id="astructTapeFileEntry_html_a8bc76d9c2d9c43e14680e39d3fc728ca"><div class="ttname"><a href="structTapeFileEntry.html#a8bc76d9c2d9c43e14680e39d3fc728ca">TapeFileEntry::FirstBlock</a></div><div class="ttdeci">uint64_t FirstBlock</div><div class="ttdoc">First block of the file (inclusive).</div><div class="ttdef"><b>Definition</b> <a href="tape_8h_source.html#l00139">tape.h:139</a></div></div>
<div class="ttc" id="astructTapeFileEntry_html_acef4f9b9acac33d1e5f08f6cd62afab3"><div class="ttname"><a href="structTapeFileEntry.html#acef4f9b9acac33d1e5f08f6cd62afab3">TapeFileEntry::Partition</a></div><div class="ttdeci">uint8_t Partition</div><div class="ttdoc">Partition number containing this file.</div><div class="ttdef"><b>Definition</b> <a href="tape_8h_source.html#l00137">tape.h:137</a></div></div>
<div class="ttc" id="astructTapeFileHashEntry_html_a5556a05025c18c16e3bb45026b2246e0"><div class="ttname"><a href="structTapeFileHashEntry.html#a5556a05025c18c16e3bb45026b2246e0">TapeFileHashEntry::key</a></div><div class="ttdeci">uint64_t key</div><div class="ttdoc">Composite key: partition &lt;&lt; 32 | file.</div><div class="ttdef"><b>Definition</b> <a href="context_8h_source.html#l00128">context.h:128</a></div></div>
<div class="ttc" id="astructTapeFileHashEntry_html_aff0f81d26d4ee00ad33331aacc2834e1"><div class="ttname"><a href="structTapeFileHashEntry.html#aff0f81d26d4ee00ad33331aacc2834e1">TapeFileHashEntry::fileEntry</a></div><div class="ttdeci">TapeFileEntry fileEntry</div><div class="ttdoc">The actual tape file data.</div><div class="ttdef"><b>Definition</b> <a href="context_8h_source.html#l00129">context.h:129</a></div></div>
<div class="ttc" id="astructTapeFileHeader_html"><div class="ttname"><a href="structTapeFileHeader.html">TapeFileHeader</a></div><div class="ttdoc">Header for a tape file metadata block containing file layout information.</div><div class="ttdef"><b>Definition</b> <a href="tape_8h_source.html#l00237">tape.h:238</a></div></div>
<div class="ttc" id="astructTapeFileHeader_html_a319aea86a448c0b969de944f22e551c0"><div class="ttname"><a href="structTapeFileHeader.html#a319aea86a448c0b969de944f22e551c0">TapeFileHeader::entries</a></div><div class="ttdeci">uint32_t entries</div><div class="ttdoc">Number of file entries following this header.</div><div class="ttdef"><b>Definition</b> <a href="tape_8h_source.html#l00241">tape.h:241</a></div></div>
<div class="ttc" id="astructTapeFileHeader_html_a36fe923f8d67004e0b0ae8eaf6535e1d"><div class="ttname"><a href="structTapeFileHeader.html#a36fe923f8d67004e0b0ae8eaf6535e1d">TapeFileHeader::identifier</a></div><div class="ttdeci">uint32_t identifier</div><div class="ttdoc">Block type identifier.</div><div class="ttdef"><b>Definition</b> <a href="tape_8h_source.html#l00239">tape.h:239</a></div></div>
<div class="ttc" id="astructTapeFileHeader_html_a5172ee4bf0b5820a66d04aff1e3809db"><div class="ttname"><a href="structTapeFileHeader.html#a5172ee4bf0b5820a66d04aff1e3809db">TapeFileHeader::crc64</a></div><div class="ttdeci">uint64_t crc64</div><div class="ttdoc">CRC64-ECMA checksum of the entry data.</div><div class="ttdef"><b>Definition</b> <a href="tape_8h_source.html#l00245">tape.h:245</a></div></div>
<div class="ttc" id="astructTapePartitionEntry_html"><div class="ttname"><a href="structTapePartitionEntry.html">TapePartitionEntry</a></div><div class="ttdoc">Describes a single physical partition on a tape medium.</div><div class="ttdef"><b>Definition</b> <a href="tape_8h_source.html#l00319">tape.h:320</a></div></div>
<div class="ttc" id="astructTapePartitionEntry_html_a19aec00f3d7b0850bf49b055dbcc837d"><div class="ttname"><a href="structTapePartitionEntry.html#a19aec00f3d7b0850bf49b055dbcc837d">TapePartitionEntry::LastBlock</a></div><div class="ttdeci">uint64_t LastBlock</div><div class="ttdoc">Last block in the partition (inclusive).</div><div class="ttdef"><b>Definition</b> <a href="tape_8h_source.html#l00325">tape.h:325</a></div></div>
<div class="ttc" id="astructTapePartitionEntry_html_af2cdde924cd050523ad0fb453eb5842d"><div class="ttname"><a href="structTapePartitionEntry.html#af2cdde924cd050523ad0fb453eb5842d">TapePartitionEntry::FirstBlock</a></div><div class="ttdeci">uint64_t FirstBlock</div><div class="ttdoc">First block in the partition (inclusive).</div><div class="ttdef"><b>Definition</b> <a href="tape_8h_source.html#l00323">tape.h:323</a></div></div>
<div class="ttc" id="astructTapePartitionEntry_html_afb840f56fb39b1074f96715d102e2c0f"><div class="ttname"><a href="structTapePartitionEntry.html#afb840f56fb39b1074f96715d102e2c0f">TapePartitionEntry::Number</a></div><div class="ttdeci">uint8_t Number</div><div class="ttdoc">Partition number (unique identifier for this partition).</div><div class="ttdef"><b>Definition</b> <a href="tape_8h_source.html#l00321">tape.h:321</a></div></div>
<div class="ttc" id="astructTapePartitionHashEntry_html"><div class="ttname"><a href="structTapePartitionHashEntry.html">TapePartitionHashEntry</a></div><div class="ttdef"><b>Definition</b> <a href="context_8h_source.html#l00133">context.h:134</a></div></div>
<div class="ttc" id="astructTapePartitionHashEntry_html_a6c817631a75a1b290d7e879c0cda5456"><div class="ttname"><a href="structTapePartitionHashEntry.html#a6c817631a75a1b290d7e879c0cda5456">TapePartitionHashEntry::key</a></div><div class="ttdeci">uint8_t key</div><div class="ttdoc">Key: partition.</div><div class="ttdef"><b>Definition</b> <a href="context_8h_source.html#l00135">context.h:135</a></div></div>
<div class="ttc" id="astructTapePartitionHashEntry_html_af7c9f8904da9a0a21171ff3c04ec4379"><div class="ttname"><a href="structTapePartitionHashEntry.html#af7c9f8904da9a0a21171ff3c04ec4379">TapePartitionHashEntry::partitionEntry</a></div><div class="ttdeci">TapePartitionEntry partitionEntry</div><div class="ttdoc">The actual tape partition data.</div><div class="ttdef"><b>Definition</b> <a href="context_8h_source.html#l00136">context.h:136</a></div></div>
<div class="ttc" id="astructTapePartitionHeader_html"><div class="ttname"><a href="structTapePartitionHeader.html">TapePartitionHeader</a></div><div class="ttdoc">Header for a tape partition metadata block containing partition layout information.</div><div class="ttdef"><b>Definition</b> <a href="tape_8h_source.html#l00440">tape.h:441</a></div></div>
<div class="ttc" id="astructTapePartitionHeader_html_a172a09251507f59bf607e4e2680f1bfc"><div class="ttname"><a href="structTapePartitionHeader.html#a172a09251507f59bf607e4e2680f1bfc">TapePartitionHeader::crc64</a></div><div class="ttdeci">uint64_t crc64</div><div class="ttdoc">CRC64-ECMA checksum of the entry data.</div><div class="ttdef"><b>Definition</b> <a href="tape_8h_source.html#l00448">tape.h:448</a></div></div>
<div class="ttc" id="astructTapePartitionHeader_html_a85cd855dac694aa7cf12177844d8b43e"><div class="ttname"><a href="structTapePartitionHeader.html#a85cd855dac694aa7cf12177844d8b43e">TapePartitionHeader::entries</a></div><div class="ttdeci">uint8_t entries</div><div class="ttdoc">Number of partition entries following this header.</div><div class="ttdef"><b>Definition</b> <a href="tape_8h_source.html#l00444">tape.h:444</a></div></div>
<div class="ttc" id="astructTapePartitionHeader_html_ace597fc284e2191b65e69eb0be9f99f6"><div class="ttname"><a href="structTapePartitionHeader.html#ace597fc284e2191b65e69eb0be9f99f6">TapePartitionHeader::identifier</a></div><div class="ttdeci">uint32_t identifier</div><div class="ttdoc">Block type identifier.</div><div class="ttdef"><b>Definition</b> <a href="tape_8h_source.html#l00442">tape.h:442</a></div></div>
<div class="ttc" id="astructaaruformat__context_html"><div class="ttname"><a href="structaaruformat__context.html">aaruformat_context</a></div><div class="ttdoc">Master context representing an open or increation Aaru image.</div><div class="ttdef"><b>Definition</b> <a href="context_8h_source.html#l00171">context.h:172</a></div></div>
<div class="ttc" id="astructaaruformat__context_html_a4783c528aec3e854986885077c5d5854"><div class="ttname"><a href="structaaruformat__context.html#a4783c528aec3e854986885077c5d5854">aaruformat_context::tape_files</a></div><div class="ttdeci">tapeFileHashEntry * tape_files</div><div class="ttdoc">Hash table root for tape files.</div><div class="ttdef"><b>Definition</b> <a href="context_8h_source.html#l00302">context.h:302</a></div></div>
<div class="ttc" id="astructaaruformat__context_html_a6f61f9ea20f4e3b791a0d6388dd43651"><div class="ttname"><a href="structaaruformat__context.html#a6f61f9ea20f4e3b791a0d6388dd43651">aaruformat_context::is_writing</a></div><div class="ttdeci">bool is_writing</div><div class="ttdoc">True if context opened/created for writing.</div><div class="ttdef"><b>Definition</b> <a href="context_8h_source.html#l00292">context.h:292</a></div></div>
<div class="ttc" id="astructaaruformat__context_html_a7dc0a0fe0bf6223ff4587fd01c360b76"><div class="ttname"><a href="structaaruformat__context.html#a7dc0a0fe0bf6223ff4587fd01c360b76">aaruformat_context::magic</a></div><div class="ttdeci">uint64_t magic</div><div class="ttdoc">File magic (AARU_MAGIC) post-open.</div><div class="ttdef"><b>Definition</b> <a href="context_8h_source.html#l00174">context.h:174</a></div></div>
<div class="ttc" id="astructaaruformat__context_html_ab516fae594bde4f76b75488d0a3ca3a8"><div class="ttname"><a href="structaaruformat__context.html#ab516fae594bde4f76b75488d0a3ca3a8">aaruformat_context::imageStream</a></div><div class="ttdeci">FILE * imageStream</div><div class="ttdoc">Underlying FILE* stream (binary mode).</div><div class="ttdef"><b>Definition</b> <a href="context_8h_source.html#l00176">context.h:176</a></div></div>
<div class="ttc" id="astructaaruformat__context_html_ac970291b3449c04221827b9c2c18ac70"><div class="ttname"><a href="structaaruformat__context.html#ac970291b3449c04221827b9c2c18ac70">aaruformat_context::image_info</a></div><div class="ttdeci">ImageInfo image_info</div><div class="ttdoc">Exposed high-level image info summary.</div><div class="ttdef"><b>Definition</b> <a href="context_8h_source.html#l00260">context.h:260</a></div></div>
<div class="ttc" id="astructaaruformat__context_html_ad7ca524fb6cece835566c268258b9a54"><div class="ttname"><a href="structaaruformat__context.html#ad7ca524fb6cece835566c268258b9a54">aaruformat_context::tape_partitions</a></div><div class="ttdeci">TapePartitionHashEntry * tape_partitions</div><div class="ttdoc">Hash table root for tape partitions.</div><div class="ttdef"><b>Definition</b> <a href="context_8h_source.html#l00303">context.h:303</a></div></div>
<div class="ttc" id="atape_8c_html_a03d080a18e07adc52a654dc31b26eea0"><div class="ttname"><a href="tape_8c.html#a03d080a18e07adc52a654dc31b26eea0">aaruf_set_tape_file</a></div><div class="ttdeci">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)</div><div class="ttdoc">Sets or updates the block range for a specific tape file in an Aaru tape image.</div><div class="ttdef"><b>Definition</b> <a href="#l00770">tape.c:770</a></div></div>
<div class="ttc" id="atape_8c_html_a6221f89b294ca55944944a04edb964e3"><div class="ttname"><a href="tape_8c.html#a6221f89b294ca55944944a04edb964e3">aaruf_get_tape_file</a></div><div class="ttdeci">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)</div><div class="ttdoc">Retrieves the block range for a specific tape file from an Aaru tape image.</div><div class="ttdef"><b>Definition</b> <a href="#l00569">tape.c:569</a></div></div>
<div class="ttc" id="atape_8c_html_a829bbac3c17b60efd8f93188a8de8278"><div class="ttname"><a href="tape_8c.html#a829bbac3c17b60efd8f93188a8de8278">process_tape_files_block</a></div><div class="ttdeci">void process_tape_files_block(aaruformat_context *ctx, const IndexEntry *entry)</div><div class="ttdoc">Processes a tape file metadata block from the image stream.</div><div class="ttdef"><b>Definition</b> <a href="#l00126">tape.c:126</a></div></div>
<div class="ttc" id="atape_8c_html_a91c40d91fdeb98193d6eeb95f16d8973"><div class="ttname"><a href="tape_8c.html#a91c40d91fdeb98193d6eeb95f16d8973">aaruf_get_tape_partition</a></div><div class="ttdeci">int32_t aaruf_get_tape_partition(const void *context, const uint8_t partition, uint64_t *starting_block, uint64_t *ending_block)</div><div class="ttdoc">Retrieves the block range for a specific tape partition from an Aaru tape image.</div><div class="ttdef"><b>Definition</b> <a href="#l00982">tape.c:982</a></div></div>
<div class="ttc" id="atape_8c_html_aa16d4457093df66246ce5622c3565a17"><div class="ttname"><a href="tape_8c.html#aa16d4457093df66246ce5622c3565a17">aaruf_set_tape_partition</a></div><div class="ttdeci">int32_t aaruf_set_tape_partition(void *context, const uint8_t partition, const uint64_t starting_block, const uint64_t ending_block)</div><div class="ttdoc">Sets or updates the block range for a specific tape partition in an Aaru tape image.</div><div class="ttdef"><b>Definition</b> <a href="#l01196">tape.c:1196</a></div></div>
<div class="ttc" id="atape_8c_html_aa76718b0402b1a28be3d563d5e62028e"><div class="ttname"><a href="tape_8c.html#aa76718b0402b1a28be3d563d5e62028e">process_tape_partitions_block</a></div><div class="ttdeci">void process_tape_partitions_block(aaruformat_context *ctx, const IndexEntry *entry)</div><div class="ttdoc">Processes a tape partition metadata block from the image stream.</div><div class="ttdef"><b>Definition</b> <a href="#l00346">tape.c:346</a></div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
</div><!-- container -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a href="dir_b2e0cd1ddd0a904cb261e9b68779deb4.html">blocks</a></li><li class="navelem"><a href="tape_8c.html">tape.c</a></li>
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.14.0 </li>
</ul>
</div>
</body>
</html>