# main.cpp

Go to the documentation of this file.

    00001 #include <iostream>
    00002 #include <vector>
    00003 #include <stdlib.h>
    00004 #include "vfs.h"
    00005 #include "btree.h"
    00006 #include "ubixfs.h"
    00007 #include "device.h"
    00008 #include "ramdrive.h"
    00009 using namespace std;
    00010
    00011 int
    00012 main(void) {
    00013
    00014   device_t * ramDrive = dev_ramDrive();
    00015   UbixFS * fs = new UbixFS(ramDrive);
    00016   fs->vfs_format(ramDrive);
    00017   fs->vfs_init();
    00018   fs->vfs_mkdir("/testdir", 0);
    00019   fs->vfs_stop();
    00020   dev_ramDestroy();
    00021
    00022 #if 0
    00023   int i = 0;
    00024   ubixfsInode * inode = (ubixfsInode *)malloc(sizeof(ubixfsInode));
    00025   memset(inode, 0, sizeof(ubixfsInode));
    00026   strcpy(inode -> name, "50");
    00027   bTree * tree = new bTree(".", inode);
    00028
    00029   for (i = 0; i < 100; i++) {
    00030 //  while (tree->Verify()) {
    00031 //    if (i%1000 == 0) cout << "-_- i = "<<i<<" -_-" << endl;
    00032     inode = (ubixfsInode *)malloc(sizeof(ubixfsInode));
    00033     if (inode == NULL) break;
    00034     memset(inode, 0, sizeof(ubixfsInode));
    00035     for (int k = 0; k < (random() % 100)+5; k++) {
    00036 //    for (int k = 0; k < 100; k++) {
    00037       inode->name[k] = (char)((random() % 26)+'a');
    00038     } // for k
    00039 //     tree->Insert(inode);
    00040     if (!tree->Insert(inode->name, inode)) cout << "Insert(" << inode->name << ") failed" << endl;
    00041 //    ++i;
    00042   } // for i
    00043 //  cout << "i made it to: " << i << endl;
    00044
    00045   i = 0;
    00046   ubixfsInode * tmpInode = tmpInode = tree->GetFirstNode();
    00047   if (tmpInode == NULL) cout << "GetFirstNode() returns null" << endl;
    00048   while (tmpInode != NULL) {
    00049     //cout << "node[" << i++ << "]: " << tmpInode->name << endl;
    00050     cout << tmpInode->name << endl;
    00051     tmpInode = tmpInode->next.iPtr;
    00052   } // while
    00053
    00054
    00055 //  tree->Info();
    00056   tree->Save("tree.dat");
    00057   free(inode);
    00058   delete tree;
    00059 #endif
    00060   cout << "sizeof(bNode): " << sizeof(struct bNode) << endl;
    00061   cout << "sizeof(ubixfsInode): " << sizeof(struct ubixfsInode) << endl;
    00062   cout << "sizeof(diskSuperBlock): " << sizeof(struct diskSuperBlock) << endl;
    00063   cout << "sizeof(bTreeHeader): " << sizeof(struct bTreeHeader) << endl;
    00064   return 0;
    00065 }