Newer
Older
UbixOS / doc / html / main_8cpp-source.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>UbixOS V2: src/sys/ubixfsv2/main.cpp Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.7 -->
<div class="tabs">
  <ul>
    <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
    <li><a href="namespaces.html"><span>Namespaces</span></a></li>
    <li><a href="classes.html"><span>Data&nbsp;Structures</span></a></li>
    <li id="current"><a href="files.html"><span>Files</span></a></li>
    <li><a href="dirs.html"><span>Directories</span></a></li>
    <li>
      <form action="search.php" method="get">
        <table cellspacing="0" cellpadding="0" border="0">
          <tr>
            <td><label>&nbsp;<u>S</u>earch&nbsp;for&nbsp;</label></td>
            <td><input type="text" name="query" value="" size="20" accesskey="s"/></td>
          </tr>
        </table>
      </form>
    </li>
  </ul></div>
<div class="tabs">
  <ul>
    <li><a href="files.html"><span>File&nbsp;List</span></a></li>
    <li><a href="globals.html"><span>Globals</span></a></li>
  </ul></div>
<div class="nav">
<a class="el" href="dir_897b6a2d7bab147dd1db58381aad3984.html">src</a>&nbsp;&raquo&nbsp;<a class="el" href="dir_832905b1f7f5feaf61a306b40c0ac817.html">sys</a>&nbsp;&raquo&nbsp;<a class="el" href="dir_21e0927e9dd41d8ff1206ca4f0555726.html">ubixfsv2</a></div>
<h1>main.cpp</h1><a href="main_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#include &lt;iostream&gt;</span>
<a name="l00002"></a>00002 <span class="preprocessor">#include &lt;vector&gt;</span>
<a name="l00003"></a>00003 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00004"></a>00004 <span class="preprocessor">#include "<a class="code" href="ubixfsv2_2vfs_8h.html">vfs.h</a>"</span>
<a name="l00005"></a>00005 <span class="preprocessor">#include "<a class="code" href="btree_8h.html">btree.h</a>"</span>
<a name="l00006"></a>00006 <span class="preprocessor">#include "<a class="code" href="ubixfsv2_2ubixfs_8h.html">ubixfs.h</a>"</span>
<a name="l00007"></a>00007 <span class="preprocessor">#include "<a class="code" href="ubixfsv2_2device_8h.html">device.h</a>"</span>
<a name="l00008"></a>00008 <span class="preprocessor">#include "<a class="code" href="ramdrive_8h.html">ramdrive.h</a>"</span>
<a name="l00009"></a>00009 <span class="keyword">using namespace </span>std;
<a name="l00010"></a>00010 
<a name="l00011"></a>00011 <span class="keywordtype">int</span>
<a name="l00012"></a><a class="code" href="main_8cpp.html#840291bc02cba5474a4cb46a9b9566fe">00012</a> <a class="code" href="main_8cpp.html#840291bc02cba5474a4cb46a9b9566fe">main</a>(<span class="keywordtype">void</span>) {
<a name="l00013"></a>00013 
<a name="l00014"></a>00014   <a class="code" href="structdevice__t.html">device_t</a> * ramDrive = <a class="code" href="ramdrive_8cpp.html#fc84c5ce562d095ec8a54c428f416ff1">dev_ramDrive</a>();
<a name="l00015"></a>00015   <a class="code" href="classUbixFS.html">UbixFS</a> * <a class="code" href="structfs.html">fs</a> = <span class="keyword">new</span> <a class="code" href="classUbixFS.html">UbixFS</a>(ramDrive);
<a name="l00016"></a>00016   fs-&gt;<a class="code" href="classUbixFS.html#e1266337d259778b1404601184d75028">vfs_format</a>(ramDrive);
<a name="l00017"></a>00017   fs-&gt;<a class="code" href="classUbixFS.html#148aae4eb2ceb35ffcad9ff22b2f7309">vfs_init</a>(); 
<a name="l00018"></a>00018   fs-&gt;<a class="code" href="classUbixFS.html#f93fcff0825ffcdaf05ceefaeb48fd7b">vfs_mkdir</a>(<span class="stringliteral">"/testdir"</span>, 0);
<a name="l00019"></a>00019   fs-&gt;<a class="code" href="classUbixFS.html#c2ccea3f574eaa7d4700748d0b4bde71">vfs_stop</a>();
<a name="l00020"></a>00020   <a class="code" href="ramdrive_8cpp.html#788c47c723973c46800d667ee8eaa979">dev_ramDestroy</a>();
<a name="l00021"></a>00021 
<a name="l00022"></a>00022 <span class="preprocessor">#if 0</span>
<a name="l00023"></a>00023 <span class="preprocessor"></span>  <span class="keywordtype">int</span> i = 0;
<a name="l00024"></a>00024   <a class="code" href="structubixfsInode.html">ubixfsInode</a> * inode = (<a class="code" href="structubixfsInode.html">ubixfsInode</a> *)malloc(<span class="keyword">sizeof</span>(<a class="code" href="structubixfsInode.html">ubixfsInode</a>));
<a name="l00025"></a>00025   <a class="code" href="lib_2string_8h.html#ce4b911463887af5e748326323e99a23">memset</a>(inode, 0, <span class="keyword">sizeof</span>(ubixfsInode));
<a name="l00026"></a>00026   <a class="code" href="lib_2string_8h.html#55e123beb3d7f96e25e024a13582d987">strcpy</a>(inode -&gt; <a class="code" href="pci_8c.html#8f8f80d37794cde9472343e4487ba3eb">name</a>, <span class="stringliteral">"50"</span>);
<a name="l00027"></a>00027   <a class="code" href="classbTree.html">bTree</a> * tree = <span class="keyword">new</span> <a class="code" href="classbTree.html">bTree</a>(<span class="stringliteral">"."</span>, inode);
<a name="l00028"></a>00028 
<a name="l00029"></a>00029   <span class="keywordflow">for</span> (i = 0; i &lt; 100; i++) {
<a name="l00030"></a>00030 <span class="comment">//  while (tree-&gt;Verify()) {</span>
<a name="l00031"></a>00031 <span class="comment">//    if (i%1000 == 0) cout &lt;&lt; "-_- i = "&lt;&lt;i&lt;&lt;" -_-" &lt;&lt; endl;</span>
<a name="l00032"></a>00032     inode = (ubixfsInode *)malloc(<span class="keyword">sizeof</span>(ubixfsInode));
<a name="l00033"></a>00033     <span class="keywordflow">if</span> (inode == <a class="code" href="def_8h.html#070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>) <span class="keywordflow">break</span>;
<a name="l00034"></a>00034     <a class="code" href="lib_2string_8h.html#ce4b911463887af5e748326323e99a23">memset</a>(inode, 0, <span class="keyword">sizeof</span>(ubixfsInode));
<a name="l00035"></a>00035     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> k = 0; k &lt; (random() % 100)+5; k++) {
<a name="l00036"></a>00036 <span class="comment">//    for (int k = 0; k &lt; 100; k++) {</span>
<a name="l00037"></a>00037       inode-&gt;name[k] = (<span class="keywordtype">char</span>)((random() % 26)+<span class="charliteral">'a'</span>);
<a name="l00038"></a>00038     } <span class="comment">// for k</span>
<a name="l00039"></a>00039 <span class="comment">//     tree-&gt;Insert(inode);</span>
<a name="l00040"></a>00040     <span class="keywordflow">if</span> (!tree-&gt;<a class="code" href="classbTree.html#fbaa745c86c8bfaa77d2196a0c1eb85b">Insert</a>(inode-&gt;name, inode)) cout &lt;&lt; <span class="stringliteral">"Insert("</span> &lt;&lt; inode-&gt;name &lt;&lt; <span class="stringliteral">") failed"</span> &lt;&lt; endl;
<a name="l00041"></a>00041 <span class="comment">//    ++i;</span>
<a name="l00042"></a>00042   } <span class="comment">// for i</span>
<a name="l00043"></a>00043 <span class="comment">//  cout &lt;&lt; "i made it to: " &lt;&lt; i &lt;&lt; endl;</span>
<a name="l00044"></a>00044 
<a name="l00045"></a>00045   i = 0;
<a name="l00046"></a>00046   ubixfsInode * tmpInode = tmpInode = tree-&gt;<a class="code" href="classbTree.html#8d04e7d1bb555d157f32673af0977244">GetFirstNode</a>();
<a name="l00047"></a>00047   <span class="keywordflow">if</span> (tmpInode == <a class="code" href="def_8h.html#070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>) cout &lt;&lt; <span class="stringliteral">"GetFirstNode() returns null"</span> &lt;&lt; endl;
<a name="l00048"></a>00048   <span class="keywordflow">while</span> (tmpInode != <a class="code" href="def_8h.html#070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>) {
<a name="l00049"></a>00049     <span class="comment">//cout &lt;&lt; "node[" &lt;&lt; i++ &lt;&lt; "]: " &lt;&lt; tmpInode-&gt;name &lt;&lt; endl;</span>
<a name="l00050"></a>00050     cout &lt;&lt; tmpInode-&gt;name &lt;&lt; endl;
<a name="l00051"></a>00051     tmpInode = tmpInode-&gt;next.iPtr;
<a name="l00052"></a>00052   } <span class="comment">// while</span>
<a name="l00053"></a>00053 
<a name="l00054"></a>00054 
<a name="l00055"></a>00055 <span class="comment">//  tree-&gt;Info();</span>
<a name="l00056"></a>00056   tree-&gt;<a class="code" href="classbTree.html#58a7211e172868c67ee7ed12e8015c4f">Save</a>(<span class="stringliteral">"tree.dat"</span>);
<a name="l00057"></a>00057   free(inode);
<a name="l00058"></a>00058   <span class="keyword">delete</span> tree;
<a name="l00059"></a>00059 <span class="preprocessor">#endif</span>
<a name="l00060"></a>00060 <span class="preprocessor"></span>  cout &lt;&lt; <span class="stringliteral">"sizeof(bNode): "</span> &lt;&lt; <span class="keyword">sizeof</span>(<span class="keyword">struct </span><a class="code" href="structbNode.html">bNode</a>) &lt;&lt; endl;
<a name="l00061"></a>00061   cout &lt;&lt; <span class="stringliteral">"sizeof(ubixfsInode): "</span> &lt;&lt; <span class="keyword">sizeof</span>(<span class="keyword">struct </span>ubixfsInode) &lt;&lt; endl;
<a name="l00062"></a>00062   cout &lt;&lt; <span class="stringliteral">"sizeof(diskSuperBlock): "</span> &lt;&lt; <span class="keyword">sizeof</span>(<span class="keyword">struct </span><a class="code" href="structdiskSuperBlock.html">diskSuperBlock</a>) &lt;&lt; endl;
<a name="l00063"></a>00063   cout &lt;&lt; <span class="stringliteral">"sizeof(bTreeHeader): "</span> &lt;&lt; <span class="keyword">sizeof</span>(<span class="keyword">struct </span><a class="code" href="structbTreeHeader.html">bTreeHeader</a>) &lt;&lt; endl;
<a name="l00064"></a>00064   <span class="keywordflow">return</span> 0;
<a name="l00065"></a>00065 }
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Tue Dec 5 23:34:58 2006 for UbixOS V2 by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.7 </small></address>
</body>
</html>