ZealOS/docs/Kernel/BlkDev/DiskCopy.CC.html
TomAwezome 1b75d91002 Fix Mount AHCI Port selection.
Add arg to SATARep to specify drive types to show.
Add checks in AHCIPortInit to verify port signatures, add helper method to get signatures from port.
2021-08-02 16:40:05 -04:00

152 lines
14 KiB
HTML
Executable file

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
<meta name="generator" content="ZealOS V0.13">
<style type="text/css">
body {background-color:#fef1f0;}
.cF0{color:#000000;background-color:#fef1f0;}
.cF1{color:#0148a4;background-color:#fef1f0;}
.cF2{color:#3b7901;background-color:#fef1f0;}
.cF3{color:#057c7e;background-color:#fef1f0;}
.cF4{color:#bb2020;background-color:#fef1f0;}
.cF5{color:#9e42ae;background-color:#fef1f0;}
.cF6{color:#b57901;background-color:#fef1f0;}
.cF7{color:#b2b6af;background-color:#fef1f0;}
.cF8{color:#555753;background-color:#fef1f0;}
.cF9{color:#678fbb;background-color:#fef1f0;}
.cFA{color:#82bc49;background-color:#fef1f0;}
.cFB{color:#0097a2;background-color:#fef1f0;}
.cFC{color:#e26a6a;background-color:#fef1f0;}
.cFD{color:#c671bc;background-color:#fef1f0;}
.cFE{color:#c7ab00;background-color:#fef1f0;}
.cFF{color:#fef1f0;background-color:#fef1f0;}
</style>
</head>
<body>
<pre style="font-family:monospace;font-size:12pt">
<a name="l1"></a><span class=cF1>Bool</span><span class=cF0> </span><span class=cFD>CopySingleZ</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *f1, </span><span class=cF1>U8</span><span class=cF0> *f2) </span><span class=cF2>//Just one file</span><span class=cF0>
<a name="l2"></a>{
<a name="l3"></a> </span><span class=cF1>U8</span><span class=cF0> *file_buf=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l4"></a> </span><span class=cF9>I64</span><span class=cF0> size, attr=</span><span class=cFE>0</span><span class=cF0>, c;
<a name="l5"></a> </span><span class=cF9>CDirEntry</span><span class=cF0> de;
<a name="l6"></a>
<a name="l7"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>FileFind</span><span class=cF7>(</span><span class=cF0>f1, &amp;de, </span><span class=cF3>FUF_JUST_FILES</span><span class=cF7>)</span><span class=cF0>)
<a name="l8"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l9"></a> </span><span class=cF5>Free</span><span class=cF0>(de.full_name);
<a name="l10"></a> file_buf = </span><span class=cF5>FileRead</span><span class=cF0>(f1, &amp;size, &amp;attr);
<a name="l11"></a> attr = </span><span class=cF5>FileAttr</span><span class=cF0>(f2, attr);
<a name="l12"></a> </span><span class=cF1>if</span><span class=cF0> (file_buf)
<a name="l13"></a> {
<a name="l14"></a> </span><span class=cF6>&quot;Copying %s to %s\n&quot;</span><span class=cF0>, f1, f2;
<a name="l15"></a> c = </span><span class=cF5>FileWrite</span><span class=cF0>(f2, file_buf, size, de.datetime, attr);
<a name="l16"></a> </span><span class=cF5>Free</span><span class=cF0>(file_buf);
<a name="l17"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>ToBool</span><span class=cF0>(c);
<a name="l18"></a> }
<a name="l19"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l20"></a> </span><span class=cF5>PrintErr</span><span class=cF0>(</span><span class=cF6>&quot;File not found: \&quot;%s\&quot;.\n&quot;</span><span class=cF0>, f1);
<a name="l21"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l22"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l23"></a> </span><span class=cF5>PrintErr</span><span class=cF0>(</span><span class=cF6>&quot;File not found: \&quot;%s\&quot;.\n&quot;</span><span class=cF0>, f1);
<a name="l24"></a>
<a name="l25"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l26"></a>}
<a name="l27"></a>
<a name="l28"></a>#</span><span class=cF1>define</span><span class=cF0> COPY_BUF_BLKS </span><span class=cFE>0x80</span><span class=cF0>
<a name="l29"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>CopySingle</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *f1, </span><span class=cF1>U8</span><span class=cF0> *f2) </span><span class=cF2>//Just one file</span><span class=cF0>
<a name="l30"></a>{
<a name="l31"></a> </span><span class=cF1>U8</span><span class=cF0> *absf1 = </span><span class=cF5>FileNameAbs</span><span class=cF0>(f1), *absf2 = </span><span class=cF5>FileNameAbs</span><span class=cF0>(f2), *buf;
<a name="l32"></a> </span><span class=cF9>I64</span><span class=cF0> count, n, size, attr1 = </span><span class=cF5>FileAttr</span><span class=cF0>(f1), attr2 = </span><span class=cF5>FileAttr</span><span class=cF0>(f2), i, j;
<a name="l33"></a> </span><span class=cF9>CFile</span><span class=cF0> *in_file = </span><span class=cF3>NULL</span><span class=cF0>, *out_file = </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l34"></a>
<a name="l35"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>StrCompare</span><span class=cF7>(</span><span class=cF0>absf1, absf2</span><span class=cF7>)</span><span class=cF0>)
<a name="l36"></a> </span><span class=cF7>{</span><span class=cF2>//onto self?</span><span class=cF0>
<a name="l37"></a> </span><span class=cF5>Free</span><span class=cF0>(absf1);
<a name="l38"></a> </span><span class=cF5>Free</span><span class=cF0>(absf2);
<a name="l39"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l40"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l41"></a> </span><span class=cF5>Free</span><span class=cF0>(absf1);
<a name="l42"></a> </span><span class=cF5>Free</span><span class=cF0>(absf2);
<a name="l43"></a> </span><span class=cF1>if</span><span class=cF0> (attr1 != attr2)
<a name="l44"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cFD>CopySingleZ</span><span class=cF0>(f1, f2);
<a name="l45"></a> buf = </span><span class=cF5>MAlloc</span><span class=cF0>(COPY_BUF_BLKS &lt;&lt; </span><span class=cF3>BLK_SIZE_BITS</span><span class=cF0>);
<a name="l46"></a> </span><span class=cF1>if</span><span class=cF0> (attr1 &amp; </span><span class=cF3>RS_ATTR_CONTIGUOUS</span><span class=cF0>)
<a name="l47"></a> in_file = </span><span class=cF5>FOpen</span><span class=cF0>(f1, </span><span class=cF6>&quot;rc&quot;</span><span class=cF0>);
<a name="l48"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l49"></a> in_file = </span><span class=cF5>FOpen</span><span class=cF0>(f1, </span><span class=cF6>&quot;r&quot;</span><span class=cF0>);
<a name="l50"></a> </span><span class=cF1>if</span><span class=cF0> (in_file)
<a name="l51"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l52"></a> size = </span><span class=cF5>FSize</span><span class=cF0>(in_file);
<a name="l53"></a> count = (size + </span><span class=cF3>BLK_SIZE</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF0>) &gt;&gt; </span><span class=cF3>BLK_SIZE_BITS</span><span class=cF0>;
<a name="l54"></a> </span><span class=cF1>if</span><span class=cF0> (attr2 &amp; </span><span class=cF3>RS_ATTR_CONTIGUOUS</span><span class=cF0>)
<a name="l55"></a> out_file = </span><span class=cF5>FOpen</span><span class=cF0>(f2, </span><span class=cF6>&quot;wc&quot;</span><span class=cF0>, count);
<a name="l56"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l57"></a> out_file = </span><span class=cF5>FOpen</span><span class=cF0>(f2, </span><span class=cF6>&quot;w&quot;</span><span class=cF0>, count);
<a name="l58"></a> </span><span class=cF1>if</span><span class=cF0> (out_file)
<a name="l59"></a> {
<a name="l60"></a> </span><span class=cF6>&quot;Copying %s to %s\n&quot;</span><span class=cF0>, f1, f2;
<a name="l61"></a> j = size;
<a name="l62"></a> </span><span class=cF1>while</span><span class=cF0> (count &gt; </span><span class=cFE>0</span><span class=cF0>)
<a name="l63"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l64"></a> </span><span class=cF1>if</span><span class=cF0> (count &gt; COPY_BUF_BLKS)
<a name="l65"></a> {
<a name="l66"></a> n = COPY_BUF_BLKS;
<a name="l67"></a> i = n &lt;&lt; </span><span class=cF3>BLK_SIZE_BITS</span><span class=cF0>;
<a name="l68"></a> }
<a name="l69"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l70"></a> {
<a name="l71"></a> n = count;
<a name="l72"></a> i = j;
<a name="l73"></a> }
<a name="l74"></a> </span><span class=cF5>FBlkRead</span><span class=cF0>(in_file, buf, </span><span class=cF3>FFB_NEXT_BLK</span><span class=cF0>, n);
<a name="l75"></a> </span><span class=cF5>FBlkWrite</span><span class=cF0>(out_file, buf, </span><span class=cF3>FFB_NEXT_BLK</span><span class=cF0>, n);
<a name="l76"></a> count -= n;
<a name="l77"></a> j -= n &lt;&lt; </span><span class=cF3>BLK_SIZE_BITS</span><span class=cF0>;
<a name="l78"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l79"></a> out_file-&gt;flags |= </span><span class=cF3>FF_USE_OLD_DATETIME</span><span class=cF0>;
<a name="l80"></a> out_file-&gt;de.datetime = in_file-&gt;de.datetime;
<a name="l81"></a> out_file-&gt;de.size = size;
<a name="l82"></a> out_file-&gt;de.attr = </span><span class=cF5>FileAttr</span><span class=cF0>(f2, in_file-&gt;de.attr);
<a name="l83"></a> </span><span class=cF5>FClose</span><span class=cF0>(out_file);
<a name="l84"></a> </span><span class=cF5>FClose</span><span class=cF0>(in_file);
<a name="l85"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
<a name="l86"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l87"></a> }
<a name="l88"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l89"></a> </span><span class=cF5>PrintErr</span><span class=cF0>(</span><span class=cF6>&quot;File not found: \&quot;%s\&quot;.\n&quot;</span><span class=cF0>, f2);
<a name="l90"></a> </span><span class=cF5>FClose</span><span class=cF0>(in_file);
<a name="l91"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l92"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l93"></a> </span><span class=cF5>PrintErr</span><span class=cF0>(</span><span class=cF6>&quot;File not found: \&quot;%s\&quot;.\n&quot;</span><span class=cF0>, f1);
<a name="l94"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
<a name="l95"></a>
<a name="l96"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l97"></a>}
<a name="l98"></a>
<a name="l99"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>Del</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *files_find_mask, </span><span class=cF1>Bool</span><span class=cF0> make_mask=</span><span class=cF3>FALSE</span><span class=cF0>, </span><span class=cF1>Bool</span><span class=cF0> del_dir=</span><span class=cF3>FALSE</span><span class=cF0>, </span><span class=cF1>Bool</span><span class=cF0> print_message=</span><span class=cF3>TRUE</span><span class=cF0>)
<a name="l100"></a>{</span><span class=cF2>//Delete files.</span><span class=cF0>
<a name="l101"></a> </span><span class=cF9>I64</span><span class=cF0> res = </span><span class=cFE>0</span><span class=cF0>;
<a name="l102"></a> </span><span class=cF9>CDirContext</span><span class=cF0> *dirc;
<a name="l103"></a>
<a name="l104"></a> </span><span class=cF1>if</span><span class=cF0> (dirc = </span><span class=cF5>DirContextNew</span><span class=cF7>(</span><span class=cF0>files_find_mask, make_mask</span><span class=cF7>)</span><span class=cF0>)
<a name="l105"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l106"></a> </span><span class=cF1>switch</span><span class=cF0> (dirc-&gt;drive-&gt;fs_type)
<a name="l107"></a> {
<a name="l108"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>FSt_REDSEA</span><span class=cF0>:
<a name="l109"></a> res = </span><span class=cFD>RedSeaFilesDel</span><span class=cF0>(dirc-&gt;drive, </span><span class=cF5>Fs</span><span class=cF0>-&gt;cur_dir, dirc-&gt;mask, </span><span class=cFE>0</span><span class=cF0>, del_dir, print_message);
<a name="l110"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l111"></a>
<a name="l112"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>FSt_FAT32</span><span class=cF0>:
<a name="l113"></a> res = </span><span class=cFD>FAT32FilesDel</span><span class=cF0>(dirc-&gt;drive, </span><span class=cF5>Fs</span><span class=cF0>-&gt;cur_dir, dirc-&gt;mask, </span><span class=cFE>0</span><span class=cF0>, del_dir, print_message);
<a name="l114"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l115"></a>
<a name="l116"></a> </span><span class=cF1>default</span><span class=cF0>:
<a name="l117"></a> </span><span class=cF5>PrintErr</span><span class=cF0>(</span><span class=cF6>&quot;File System Not Supported\n&quot;</span><span class=cF0>);
<a name="l118"></a> }
<a name="l119"></a> </span><span class=cF5>DirContextDel</span><span class=cF0>(dirc);
<a name="l120"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l121"></a>
<a name="l122"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l123"></a>}
</span></pre></body>
</html>