diff --git a/src/sys/ubixfsv2/main.cpp b/src/sys/ubixfsv2/main.cpp index 97e9441..9e77d6d 100644 --- a/src/sys/ubixfsv2/main.cpp +++ b/src/sys/ubixfsv2/main.cpp @@ -15,6 +15,7 @@ UbixFS * fs = new UbixFS(ramDrive); fs->vfs_format(ramDrive); fs->vfs_init(); + fs->vfs_stop(); dev_ramDestroy(); #if 0 diff --git a/src/sys/ubixfsv2/ubixfs.cpp b/src/sys/ubixfsv2/ubixfs.cpp index d8e402f..7ef1e91 100644 --- a/src/sys/ubixfsv2/ubixfs.cpp +++ b/src/sys/ubixfsv2/ubixfs.cpp @@ -74,16 +74,12 @@ freeBlockList = new signed char[superBlock->batSectors*512]; assert(freeBlockList); memset(freeBlockList, 0, superBlock->batSectors*512); -printf("block list before reading it in: \n"); - printFreeBlockList(0); + device->read(device, freeBlockList, device->sectors - superBlock->batSectors-1, superBlock->batSectors ); // device->read() -printf("block list after reading it in: \n"); - printFreeBlockList(0); - cout << "allocating root dir inode" << endl; root = new ubixfsInode; @@ -115,11 +111,6 @@ root->data.btPtr->Info(); printSuperBlock(); - blockRun br; - br.AG = 0; - br.start = 0; - br.len = 15; - br = getFreeBlock(br); return 0; } // UbixFS::init @@ -130,8 +121,6 @@ int32 count, holdCount; blockRun obr = {0, 0, 0}; - printf("before allocation: \n"); - printFreeBlockList(0); // Check to make sure none of these are null if (device == NULL || freeBlockList == NULL || superBlock == NULL) return obr; @@ -199,7 +188,6 @@ if (ibr.len % 8 != 0) *holdPtr = (-1 << (8-(ibr.len % 8))); superBlock->usedBlocks += ibr.len; // increment the number of used blocks - printFreeBlockList(ibr.AG); return obr; } // UbixFS::getFreeBlock @@ -576,6 +564,24 @@ return 0; } // UbixFS::vfs_format +int +UbixFS::vfs_stop(void) { + if (vfs_sync() != 0) return -1; + return 0; +} // UbixFS::vfs_stop + +int +UbixFS::vfs_sync(void) { + if (device == NULL || superBlock == NULL || freeBlockList == NULL) return -1; + device->write(device, + freeBlockList, + device->sectors - superBlock->batSectors - 1, + superBlock->batSectors + ); + device->write(device, superBlock, device->sectors-1, 1); + return 0; +} // UbixFS::vfs_sync + UbixFS::~UbixFS(void) { delete [] freeBlockList; return; diff --git a/src/sys/ubixfsv2/ubixfs.h b/src/sys/ubixfsv2/ubixfs.h index b306567..cf0409e 100644 --- a/src/sys/ubixfsv2/ubixfs.h +++ b/src/sys/ubixfsv2/ubixfs.h @@ -146,6 +146,8 @@ virtual int vfs_init(void); virtual int vfs_format(device_t *); virtual void * vfs_mknod(const char *, mode_t); + virtual int vfs_sync(void); + virtual int vfs_stop(void); virtual ~UbixFS(void); friend class bTree; }; // UbixFS