diff --git a/src/sys/ubixfsv2/btree.cpp b/src/sys/ubixfsv2/btree.cpp index 9c8ef75..e04822c 100644 --- a/src/sys/ubixfsv2/btree.cpp +++ b/src/sys/ubixfsv2/btree.cpp @@ -133,7 +133,7 @@ inode->prev = iptr->prev; inode->next = iptr; iptr->prev = inode; - if (inode->prev != NULL) inode->prev->next = inode; + if (inode->prev != NULL) inode->prev->next = (ubixfsInode *)inode; } else { inode->next = inode->prev = NULL; } // else @@ -635,11 +635,12 @@ if (node == NULL) return true; while (node != NULL) { - if (node->next != NULL) { + ubixfsInode * next = node->next; + if (next != NULL) { // cout << node->name << "::" << node->next->name << ":::" << strcmp(node->name, node->next->name) << endl; - if (strcmp(node->name, node->next->name) > 0) return false; + if (strcmp(node->name, next->name) > 0) return false; } - node = node->next; + node = next; } // while return true; } // bTree::Verify diff --git a/src/sys/ubixfsv2/btree.h b/src/sys/ubixfsv2/btree.h index 0ed58de..d20591b 100644 --- a/src/sys/ubixfsv2/btree.h +++ b/src/sys/ubixfsv2/btree.h @@ -11,6 +11,9 @@ #define B_MAX_NAME_LENGTH 240 #define B_MAX_CHILD_COUNT 4 +// if any of these structs change they have to be updated in the format +// utility too + typedef struct bNode { uInt32 magic1 __attribute__ ((packed)); uInt32 used __attribute__ ((packed)); @@ -25,13 +28,21 @@ char reserved[143] __attribute__ ((packed)); } bNode; // bNode + +typedef struct bTreeHeader { + uInt32 treeDepth; + uInt32 treeWidth; + uInt32 treeLeafCount; + int32 firstDeleted; +} bTreeHeader; // bTreeHeader + class bTree { protected: bNode * root; uInt32 treeDepth; uInt32 treeWidth; uInt32 treeLeafCount; - uInt32 firstDeleted; + int32 firstDeleted; ubixfsInode * treeSearch(bNode *, const char *); ubixfsInode * inodeSearch(ubixfsInode *, const char *); void splitNode(bNode *); diff --git a/src/sys/ubixfsv2/inode.h b/src/sys/ubixfsv2/inode.h index 5b83c1b..82b5475 100644 --- a/src/sys/ubixfsv2/inode.h +++ b/src/sys/ubixfsv2/inode.h @@ -38,15 +38,14 @@ // inodeAddr attributes __attribute__ ((packed)); uInt32 type __attribute__ ((packed)); int32 inodeSize __attribute__ ((packed)); - ubixfsInode * parentBigPtr __attribute__ ((packed)); - ubixfsInode * parent __attribute__ ((packed)); - ubixfsInode * nextBigPtr __attribute__ ((packed)); - ubixfsInode * next __attribute__ ((packed)); - ubixfsInode * prevBigPtr __attribute__ ((packed)); - ubixfsInode * prev __attribute__ ((packed)); + struct ubixfsInode * parentBigPtr __attribute__ ((packed)); + struct ubixfsInode * parent __attribute__ ((packed)); + struct ubixfsInode * nextBigPtr __attribute__ ((packed)); + struct ubixfsInode * next __attribute__ ((packed)); + struct ubixfsInode * prevBigPtr __attribute__ ((packed)); + struct ubixfsInode * prev __attribute__ ((packed)); // binodeEtc *etc ?? dataStream data __attribute__ ((packed)); - int32 pad[4] __attribute__ ((packed)); - char smallData[3620] __attribute__ ((packed)); + char smallData[3220] __attribute__ ((packed)); } ubixfsInode; #endif diff --git a/src/sys/ubixfsv2/main.cpp b/src/sys/ubixfsv2/main.cpp index 01d4f2b..5209fc9 100644 --- a/src/sys/ubixfsv2/main.cpp +++ b/src/sys/ubixfsv2/main.cpp @@ -16,7 +16,7 @@ strcpy(inode -> name, "50"); bTree * tree = new bTree(inode); - for (i = 0; i < 3000; i++) { + for (i = 0; i < 100; i++) { // while (tree->Verify()) { // if (i%1000 == 0) cout << "-_- i = "<name << endl; cout << tmpInode->name << endl; - tmpInode = tmpInode->next; + tmpInode = (ubixfsInode *)tmpInode->next; } // while cout << sizeof(struct bNode) << endl;