diff --git a/src/Makefile.inc b/src/Makefile.inc index 935fc6c..8a14d34 100644 --- a/src/Makefile.inc +++ b/src/Makefile.inc @@ -2,8 +2,8 @@ # Global 'Source' Options # allow you to change your default compiler without affecting your other work -CC = gcc -CXX = g++ +CC = gcc295 +CXX = g++295 LD = ld AR = ar REMOVE = rm -rf diff --git a/src/sys/ubixfs/ubixfs.c b/src/sys/ubixfs/ubixfs.c index 53a4f1c..2cba578 100644 --- a/src/sys/ubixfs/ubixfs.c +++ b/src/sys/ubixfs/ubixfs.c @@ -40,6 +40,7 @@ #include #include #include +#include int ubixfs_init() { @@ -79,17 +80,38 @@ void initUbixFS(struct mountPoints *mp) { struct ubixFSInfo *fsInfo = 0x0; + int size; + /* assert(mp->fsInfo != NULL); */ + + if (mp == NULL) { + kprintf("\nAssertion error in %s:%d\n", __FILE__, __LINE__); + } + mp->fsInfo = (struct ubixFSInfo *)kmalloc(sizeof(struct ubixFSInfo)); + + if (mp->fsInfo == NULL || mp->diskLabel == NULL || + mp->diskLabel->partitions == NULL ) { + kprintf("\nAssertion error in %s:%d\n", __FILE__, __LINE__); + } + fsInfo = mp->fsInfo; fsInfo->rootDir = 0x0; //mp->diskLabel->partitions[mp->partition].pOffset -= 63; - if ((mp->diskLabel->magicNum == UBIXDISKMAGIC) && (mp->diskLabel->magicNum2 == UBIXDISKMAGIC)) { - fsInfo->blockAllocationTable = (struct blockAllocationTableEntry *)kmalloc(mp->diskLabel->partitions[mp->partition].pBatSize*512); + if ((mp->diskLabel->magicNum == UBIXDISKMAGIC) && + (mp->diskLabel->magicNum2 == UBIXDISKMAGIC)) { + size = mp->diskLabel->partitions[mp->partition].pBatSize * 512; + fsInfo->blockAllocationTable = (struct blockAllocationTableEntry *)kmalloc(size); + /* fsInfo->blockAllocationTable[0].nextBlock = 100; */ - fsInfo->batEntries = ((mp->diskLabel->partitions[mp->partition].pBatSize*512)/sizeof(struct blockAllocationTableEntry)); - kprintf("C"); - mp->device->devInfo->read(mp->device->devInfo->info,fsInfo->blockAllocationTable,mp->diskLabel->partitions[mp->partition].pOffset,mp->diskLabel->partitions[mp->partition].pBatSize); - kprintf("Offset: [%i], Partition: [%i]\n",mp->diskLabel->partitions[mp->partition].pOffset,mp->partition); + size = (mp->diskLabel->partitions[mp->partition].pBatSize*512) / sizeof(struct blockAllocationTableEntry); + fsInfo->batEntries = size; + + mp->device->devInfo->read(mp->device->devInfo->info, + fsInfo->blockAllocationTable, + mp->diskLabel->partitions[mp->partition].pOffset, + mp->diskLabel->partitions[mp->partition].pBatSize); + kprintf("Offset: [%i], Partition: [%i]\n", + mp->diskLabel->partitions[mp->partition].pOffset,mp->partition); kprintf("UbixFS Initialized\n"); } else { @@ -101,13 +123,29 @@ return; } -int openFileUbixFS(char *file,fileDescriptor *fd) { - int x=0; +int +openFileUbixFS(char *file, fileDescriptor *fd) { + int x = 0; + long offsets, size; struct directoryEntry *dirEntry = (struct directoryEntry *)kmalloc(0x4000); struct ubixFSInfo *fsInfo = fd->mp->fsInfo; - if (file[0] == '/' && file[1] != '\0') - file++; - fd->mp->device->devInfo->read(fd->mp->device->devInfo->info,dirEntry,(fd->mp->diskLabel->partitions[fd->mp->partition].pOffset+fsInfo->blockAllocationTable[fsInfo->rootDir].realSector),(0x4000/512)); + + assert(fd); + assert(fd->mp); + assert(fd->mp->device); + assert(fd->mp->device->devInfo); + assert(fd->mp->device->devInfo->read); + + if (fd == NULL || fd->mp == NULL || fd->mp->device == NULL || + fd->mp->device->devInfo == NULL || fd->mp->device->devInfo->read == NULL){ + kprintf("\nAssertion error in %s:%d\n", __FILE__, __LINE__); + } + + if (file[0] == '/' && file[1] != '\0') file++; + + fd->mp->device->devInfo->read(fd->mp->device->devInfo->info, + dirEntry, + (fd->mp->diskLabel->partitions[fd->mp->partition].pOffset+fsInfo->blockAllocationTable[fsInfo->rootDir].realSector),(0x4000/512)); if ((fd->mode & fileRead) == fileRead) { for (x=0;x<(0x4000/sizeof(struct directoryEntry));x++) { if ((int)!strcmp(dirEntry[x].fileName,file)) { @@ -149,7 +187,8 @@ return((int)0); } -int writeFileByte(int ch,fileDescriptor *fd,long offset) { +int +writeFileByte(int ch, fileDescriptor *fd, long offset) { int blockCount = 0x0,batIndex = 0x0,batIndexPrev = fd->start,i = 0x0; struct directoryEntry *dirEntry = 0x0; @@ -159,7 +198,8 @@ blockCount = (offset/4096); /* Find The Block If It Doesn't Exist We Will Have To Allocate One */ - for (i=0x0;i<=fd->mp->diskLabel->partitions[fd->mp->partition].pBatSize;i++) { + for (i=0x0; i <= fd->mp->diskLabel->partitions[fd->mp->partition].pBatSize; + i++) { batIndex = fsInfo->blockAllocationTable[batIndexPrev].nextBlock; if (batIndex == 0x0) { break; diff --git a/src/sys/vfs/vfs.c b/src/sys/vfs/vfs.c index 122a830..2c2a801 100644 --- a/src/sys/vfs/vfs.c +++ b/src/sys/vfs/vfs.c @@ -31,6 +31,7 @@ #include #include #include +#include /************************************************************************ @@ -83,7 +84,7 @@ } /* Set Up FS Defaults */ - +/* tmpFs->vfsType = newFS.vfsType; tmpFs->vfsInitFS = newFS.vfsInitFS; tmpFs->vfsRead = newFS.vfsRead; @@ -93,8 +94,8 @@ tmpFs->vfsMakeDir = newFS.vfsMakeDir; tmpFs->vfsRemDir = newFS.vfsRemDir; tmpFs->vfsSync = newFS.vfsSync; - -/* memcpy(*tmpFs, newFS, sizeof(struct fileSystem)); */ + */ + memcpy(tmpFs, &newFS, sizeof(struct fileSystem)); if (!systemVitals->fileSystems) { tmpFs->prev = 0x0; tmpFs->next = 0x0;