UbixOS V2 2.0

main.cpp
Go to the documentation of this file.
1 /*
2 #include <iostream>
3 #include <vector>
4 #include <stdlib.h>
5 #include "vfs.h"
6 #include "btree.h"
7 #include "ubixfs.h"
8 #include "device.h"
9 #include "ramdrive.h"
10 using namespace std;
11
12 int
13 main(void) {
14
15 device_t * ramDrive = dev_ramDrive();
16 UbixFS * fs = new UbixFS(ramDrive);
17 fs->vfs_format(ramDrive);
18 fs->vfs_init();
19 fs->vfs_mkdir("/testdir", 0);
20 fs->vfs_stop();
21 dev_ramDestroy();
22
23 #if 0
24 int i = 0;
25 ubixfsInode * inode = (ubixfsInode *)malloc(sizeof(ubixfsInode));
26 memset(inode, 0, sizeof(ubixfsInode));
27 strcpy(inode -> name, "50");
28 bTree * tree = new bTree(".", inode);
29
30 for (i = 0; i < 100; i++) {
31 // while (tree->Verify()) {
32 // if (i%1000 == 0) cout << "-_- i = "<<i<<" -_-" << endl;
33 inode = (ubixfsInode *)malloc(sizeof(ubixfsInode));
34 if (inode == NULL) break;
35 memset(inode, 0, sizeof(ubixfsInode));
36 for (int k = 0; k < (random() % 100)+5; k++) {
37 // for (int k = 0; k < 100; k++) {
38 inode->name[k] = (char)((random() % 26)+'a');
39 } // for k
40 // tree->Insert(inode);
41 if (!tree->Insert(inode->name, inode)) cout << "Insert(" << inode->name << ") failed" << endl;
42 // ++i;
43 } // for i
44 // cout << "i made it to: " << i << endl;
45
46 i = 0;
47 ubixfsInode * tmpInode = tmpInode = tree->GetFirstNode();
48 if (tmpInode == NULL) cout << "GetFirstNode() returns null" << endl;
49 while (tmpInode != NULL) {
50 //cout << "node[" << i++ << "]: " << tmpInode->name << endl;
51 cout << tmpInode->name << endl;
52 tmpInode = tmpInode->next.iPtr;
53 } // while
54
55
56 // tree->Info();
57 tree->Save("tree.dat");
58 free(inode);
59 delete tree;
60 #endif
61 cout << "sizeof(bNode): " << sizeof(struct bNode) << endl;
62 cout << "sizeof(ubixfsInode): " << sizeof(struct ubixfsInode) << endl;
63 cout << "sizeof(diskSuperBlock): " << sizeof(struct diskSuperBlock) << endl;
64 cout << "sizeof(bTreeHeader): " << sizeof(struct bTreeHeader) << endl;
65 return 0;
66 }
67 */