diff --git a/src/sys/include/ubixfs/dirCache.h b/src/sys/include/ubixfs/dirCache.h index 3c0b8d2..bd106a5 100644 --- a/src/sys/include/ubixfs/dirCache.h +++ b/src/sys/include/ubixfs/dirCache.h @@ -11,12 +11,12 @@ struct cacheNode * fileListHead; struct cacheNode * fileListTail; void * info; - int size; + int * size; int present; int dirty; - uInt32 startCluster; - uInt16 attributes; - uInt16 permissions; + uInt32 * startCluster; + uInt16 * attributes; + uInt16 * permissions; }; /* cacheNode */ struct cacheNode * ubixfs_cacheFind(struct cacheNode *, char *); diff --git a/src/sys/ubixfs/Makefile b/src/sys/ubixfs/Makefile index f0d265d..cc4ef5e 100644 --- a/src/sys/ubixfs/Makefile +++ b/src/sys/ubixfs/Makefile @@ -16,7 +16,7 @@ .cc.s: $(CXX) ${CFLAGS} ${INCLUDES} -S -o $@ $< .c.o: - $(CC) ${CFLAGS} ${INCLUDES} -c -o $@ $< + $(CC) ${CFLAGS} ${INCLUDES} -W -Wall -c -o $@ $< .c.s: $(CC) ${CFLAGS} ${INCLUDES} -S -o $@ $< .S.o: diff --git a/src/sys/ubixfs/dirCache.c b/src/sys/ubixfs/dirCache.c index b57b1f5..df3f97f 100644 --- a/src/sys/ubixfs/dirCache.c +++ b/src/sys/ubixfs/dirCache.c @@ -37,6 +37,7 @@ struct directoryEntry * ubixfs_findName(struct directoryEntry * dirList, char * name) { int i; +kprintf("in findname: %s\n", name); if (dirList == NULL || name == NULL) return NULL; for (i = 0; dirList[i].fileName != NULL; i++) { if (strcmp(dirList[i].fileName, name) == 0) return &dirList[i]; @@ -51,7 +52,7 @@ unsigned int i = 0x0; char dirName[256]; char * nextDir = NULL; -kprintf("looking for %s\n", name); +kprintf("looking for %s\n", name); assert(name); assert(head); assert(*name); @@ -82,11 +83,12 @@ * name points to a null terminated directory name * if nextDir isn't null, then make sure that this dir is present */ - +kprintf("nextdir: %s\n", nextDir); if (*nextDir != '\0') { while (tmp != NULL) { +kprintf("looking at: %s\n", tmp->name); if (strcmp(tmp->name, dirName) == 0) { - if ((tmp->attributes & typeFile) == typeFile + if ((*tmp->attributes & typeFile) == typeFile || tmp->fileListHead == NULL) { /* if we're here, then there are no subdirs cached to look through */ @@ -94,17 +96,18 @@ if (dirList == NULL) return NULL; kprintf("creating new node %s", dirList->fileName); tmp = ubixfs_cacheAdd(tmp, ubixfs_cacheNew(dirList->fileName)); - tmp->attributes = dirList->attributes; - tmp->permissions = dirList->permissions; - tmp->size = dirList->size; -kprintf(" size: %d\n", tmp->size); - tmp->startCluster = dirList->startCluster; + tmp->attributes = &dirList->attributes; + tmp->permissions = &dirList->permissions; + tmp->size = &dirList->size; +kprintf(" size: %d\n", *tmp->size); + tmp->startCluster = &dirList->startCluster; tmp->present = 0; return tmp; } else return ubixfs_cacheFind(tmp->fileListHead, nextDir); } /* if */ tmp = tmp->next; } /* while */ + /* it wasn't present, return NULL */ return NULL; } /* if */ @@ -113,6 +116,7 @@ * dir listing here */ while (tmp != NULL) { +kprintf("bottom level looking at: %s\n", tmp->name); assert(tmp->name); /* don't forget to check to see if it's a directory */ if (strcmp(tmp->name, name) == 0) { @@ -142,19 +146,20 @@ } /* while */ /* if we're here, then one level of the dir isn't cached */ - tmp = head->parent; - assert(tmp->info); - dirList = ubixfs_findName((struct directoryEntry *)tmp->info, name); - if (dirList == NULL) return NULL; + tmp = head->parent; + assert(tmp); + assert(tmp->info); + dirList = ubixfs_findName((struct directoryEntry *)tmp->info, name); + if (dirList == NULL) return NULL; kprintf("creating new node %s", dirList->fileName); - tmp = ubixfs_cacheAdd(tmp, ubixfs_cacheNew(dirList->fileName)); - tmp->attributes = dirList->attributes; - tmp->permissions = dirList->permissions; - tmp->size = dirList->size; -kprintf(" size: %d\n", tmp->size); - tmp->startCluster = dirList->startCluster; - tmp->present = 0; - return tmp; + tmp = ubixfs_cacheAdd(tmp, ubixfs_cacheNew(dirList->fileName)); + tmp->attributes = &dirList->attributes; + tmp->permissions = &dirList->permissions; + tmp->size = &dirList->size; +kprintf(" size: %d\n", *tmp->size); + tmp->startCluster = &dirList->startCluster; + tmp->present = 0; + return tmp; #if 0 return NULL; /* couldn't find it */ #endif @@ -167,8 +172,11 @@ tmp->parent = tmp; tmp->prev = tmp->next = tmp->fileListHead = tmp->fileListTail = NULL; tmp->info = NULL; - tmp->size = tmp->present = tmp->dirty = tmp->startCluster = 0; - tmp->attributes = tmp->permissions = 0; + tmp->size = NULL; + tmp->present = tmp->dirty = 0; + tmp->startCluster = NULL; + tmp->attributes = NULL; + tmp->permissions = NULL; tmp->name = (char *)kmalloc(strlen(name)); strcpy(tmp->name, name); return tmp; @@ -234,6 +242,9 @@ /*** $Log$ + Revision 1.21 2004/07/25 22:21:52 flameshadow + chg: re-enabled kprintf() in ubixfs_cacheFind() + Revision 1.20 2004/07/24 17:19:24 flameshadow chg: Temporarily disabled the moving of the found cache node to the front of the list. It seems to cause problems later (race condition, possibly) @@ -278,6 +289,9 @@ Revision 1.5 2004/07/20 19:21:30 reddawg You like leaving out $Log$ + You like leaving out Revision 1.21 2004/07/25 22:21:52 flameshadow + You like leaving out chg: re-enabled kprintf() in ubixfs_cacheFind() + You like leaving out You like leaving out Revision 1.20 2004/07/24 17:19:24 flameshadow You like leaving out chg: Temporarily disabled the moving of the found cache node to the front You like leaving out of the list. It seems to cause problems later (race condition, possibly) diff --git a/src/sys/ubixfs/ubixfs.c b/src/sys/ubixfs/ubixfs.c index 483a5e7..c1c6dab 100644 --- a/src/sys/ubixfs/ubixfs.c +++ b/src/sys/ubixfs/ubixfs.c @@ -68,6 +68,25 @@ */ + do { + cacheNode = ubixfs_cacheFind(fsInfo->dirCache, file); +assert(cacheNode); + if (cacheNode == NULL) return 0; + if (cacheNode->present == 1) break; + if (*cacheNode->size != 0 && cacheNode->info == NULL) { + kprintf("allocating space for %s\n", cacheNode->name); + cacheNode->info = kmalloc(UBIXFS_ALIGN(*cacheNode->size)); + fd->size = *cacheNode->size; + + ubixfs_loadData(fd, + cacheNode->info, + *cacheNode->size, + *cacheNode->startCluster); + cacheNode->present = 1; +kprintf("here\n"); + } /* if */ + } while(1); +#if 0 /* UBU */ @@ -88,12 +107,15 @@ */ if (cacheNode->size != 0 && cacheNode->info == NULL) { kprintf("allocating space for %s\n", cacheNode->name); - cacheNode->info = kmalloc(UBIXFS_ALIGN(cacheNode->size)); - fd->size = cacheNode->size; /* */ /* UBU what is the best way to keep these in sync? */ + cacheNode->info = kmalloc(UBIXFS_ALIGN(*cacheNode->size)); + fd->size = *cacheNode->size; /* */ /* UBU what is the best way to keep these in sync? */ /* UBU */ - ubixfs_loadData(fd,cacheNode->info,cacheNode->size,cacheNode->startCluster); + ubixfs_loadData(fd, + cacheNode->info, + *cacheNode->size, + *cacheNode->startCluster); cacheNode->present = 1; } /* if */ /* @@ -102,17 +124,18 @@ } while (1); /* */ +#endif assert(cacheNode); if (cacheNode == NULL) return 0; if ((fd->mode & fileRead) == fileRead) { - fd->start = cacheNode->startCluster; - fd->size = cacheNode->size; - fd->perms = cacheNode->permissions; + fd->start = *cacheNode->startCluster; + fd->size = *cacheNode->size; + fd->perms = *cacheNode->permissions; fd->dirBlock = 0x0; /* Directory Start Sector */ /* if (cacheNode->size != 0x0 && cacheNode->info == NULL) { - cacheNode->info = kmalloc(UBIXFS_ALIGN(cacheNode->size)); + cacheNode->info = kmalloc(UBIXFS_ALIGN(*cacheNode->size)); ubixfs_loadData(fd,cacheNode->info,cacheNode->size,cacheNode->startCluster); cacheNode->present = 0x1; } @@ -469,10 +492,16 @@ /* Set up root directory cache */ fsInfo->dirCache = ubixfs_cacheNew("/"); assert(fsInfo->dirCache); - fsInfo->dirCache->present = 1; - fsInfo->dirCache->size = 0x4000; - fsInfo->dirCache->startCluster = fsInfo->rootDir; fsInfo->dirCache->info = (struct directoryEntry *)kmalloc(0x4000); /* allocate root dir */ + fsInfo->dirCache->present = 1; + fsInfo->dirCache->size = kmalloc(sizeof(fsInfo->dirCache->size)); + fsInfo->dirCache->startCluster = kmalloc(sizeof(fsInfo->dirCache->startCluster)); + fsInfo->dirCache->attributes = kmalloc(sizeof(fsInfo->dirCache->attributes)); + fsInfo->dirCache->permissions = kmalloc(sizeof(fsInfo->dirCache->permissions)); + + *fsInfo->dirCache->size = 0x4000; + *fsInfo->dirCache->startCluster = fsInfo->rootDir; + assert(fsInfo->dirCache->info); /* Read root dir in from disk it is always 0x4000 bytes long */ mp->device->devInfo->read(mp->device->devInfo->info, @@ -536,6 +565,9 @@ /*** $Log$ + Revision 1.35 2004/07/26 19:15:49 reddawg + test code, fixes and the like + Revision 1.34 2004/07/24 23:04:44 reddawg Changes... mark let me know if you fault at pid 185 when you type stress diff --git a/src/sys/vfs/file.c b/src/sys/vfs/file.c index 2832d14..a73bc28 100644 --- a/src/sys/vfs/file.c +++ b/src/sys/vfs/file.c @@ -222,6 +222,7 @@ i++; } /* Search For The File */ +kprintf("vfsOpenFile(%s)\n", path); if (tmpFd->mp->fs->vfsOpenFile((char *)path,tmpFd) == 1) { /* If The File Is Found Then Set Up The Descriptor */ tmpFd->buffer = (char *)kmalloc(4096); @@ -261,6 +262,11 @@ /*** $Log$ + Revision 1.13 2004/07/23 09:10:06 reddawg + ubixfs: cleaned up some functions played with the caching a bit + vfs: renamed a bunch of functions + cleaned up a few misc bugs + Revision 1.12 2004/07/22 22:37:03 reddawg Caching is working now the FS is extremely fast but needs to be optimized to do 32bit copies over 8bit