diff --git a/src/sys/include/ubixfs/ubixfs.h b/src/sys/include/ubixfs/ubixfs.h index 78df9e4..df8588a 100644 --- a/src/sys/include/ubixfs/ubixfs.h +++ b/src/sys/include/ubixfs/ubixfs.h @@ -36,6 +36,9 @@ #include #include +#define UBIXFS_ALIGN_SIZE 0x1000 +#define UBIXFS_ALIGN(size) (size + ((((size) % UBIXFS_ALIGN_SIZE) == 0)? 0 : (UBIXFS_ALIGN_SIZE - ((size) % UBIXFS_ALIGN_SIZE)))) + #define UBIXDISKMAGIC ((uInt32)0x45) /* The disk magic number */ #define MAXUBIXPARTITIONS 16 #define blockSize 8 @@ -155,6 +158,9 @@ /*** $Log$ + Revision 1.16 2004/07/20 21:28:16 flameshadow + oops + Revision 1.14 2004/07/20 19:36:49 reddawg UBU Tags diff --git a/src/sys/ubixfs/ubixfs.c b/src/sys/ubixfs/ubixfs.c index 2b03f0a..c229855 100644 --- a/src/sys/ubixfs/ubixfs.c +++ b/src/sys/ubixfs/ubixfs.c @@ -137,7 +137,38 @@ /* Return */ return; } - + +/*UBU*/ +static int ubixfs_loadData(fileDescriptor *fd,char *data,uInt32 size,uInt32 batIndex) { + long i = 0x0; + + struct ubixFSInfo *fsInfo = NULL; + + assert(fd); + assert(fd->mp); + assert(fd->mp->fsInfo); + + fsInfo = fd->mp->fsInfo; + + /* If The File Size Is Greater Then The Offset Lets Goto Work */ + + size += 4095; + for (i=0x0; i fd->size) { + /* Set File EOF If There Is Nothing To Do */ + fd->status = fdEof; + return(size); + } + if (i != 0x0) + batIndex = fsInfo->blockAllocationTable[batIndex].nextBlock;; + + fd->mp->device->devInfo->read(fd->mp->device->devInfo->info,data+i,fd->mp->diskLabel->partitions[fd->mp->partition].pOffset+fsInfo->blockAllocationTable[batIndex].realSector,blockSize); + } + /* Return */ + return(size); + } + int openFileUbixFS(char *file, fileDescriptor *fd) { int x = 0; @@ -156,7 +187,6 @@ assert(fd->mp->device->devInfo->read); assert(fsInfo); assert(fsInfo->dirCache); - do { cacheNode = ubixfs_cacheFind(fsInfo->dirCache, file); if (cacheNode == NULL) return 0; @@ -164,7 +194,9 @@ /* one level of the cache wasn't loaded */ if (cacheNode->size != 0 && cacheNode->info == NULL) { kprintf("allocating space for %s\n", cacheNode->name); - cacheNode->info = kmalloc(cacheNode->size); + cacheNode->info = kmalloc(UBIXFS_ALIGN(cacheNode->size)); + fd->size = cacheNode->size; //UBU do we need this anymopre or can we change things + ubixfs_loadData(fd,cacheNode->info,cacheNode->size,cacheNode->startCluster); cacheNode->present = 1; } /* if */ } while (1); @@ -314,6 +346,39 @@ /* Verified Functions */ + +int readUbixFS(fileDescriptor *fd,char *data,long offset,long size) { + int i = 0x0; + char *buffer = 0x0; + struct ubixFSInfo *fsInfo = NULL; + struct cacheNode * cacheNode = NULL; + + assert(fd); + assert(fd->mp); + assert(fd->mp->fsInfo); + + fsInfo = fd->mp->fsInfo; + cacheNode = ubixfs_cacheFind(fsInfo->dirCache, fd->fileName); + + if (cacheNode->present != 1) + kpanic("ERROR with cache node\n"); + + buffer = (char *)cacheNode->info; + + for (i=0x0; i fd->size) { + /* Set File EOF If There Is Nothing To Do */ + data[i] = '\0'; + fd->status = fdEof; + return(size); + } + /* Copy Data From Buffer To Data */ + data[i] = buffer[i + offset]; + } + /* Return */ + return(size); + } + /************************************************************************ Function: int readUbixFS(fileDescriptor *fd,char *data,long offset,long size) @@ -321,7 +386,7 @@ Notes: ************************************************************************/ -int readUbixFS(fileDescriptor *fd,char *data,long offset,long size) { +int readUbixFS_old(fileDescriptor *fd,char *data,long offset,long size) { int blockCount = 0x0; int batIndex; long i = 0x0; @@ -469,6 +534,9 @@ /*** $Log$ + Revision 1.30 2004/07/22 19:01:59 flameshadow + chg: more directory and file caching + Revision 1.29 2004/07/22 16:34:32 flameshadow add: file and dir caching kinda work diff --git a/src/sys/vfs/file.c b/src/sys/vfs/file.c index c42f844..207555e 100644 --- a/src/sys/vfs/file.c +++ b/src/sys/vfs/file.c @@ -166,7 +166,7 @@ /* Allocate Memory For File Descriptor */ tmpFd = (fileDescriptor *)kmalloc(sizeof(fileDescriptor)); - path = tmpFd->fileName; + path = &tmpFd->fileName; if (strstr(file,":")) { mountPoint = (char *)strtok((char *)file,":"); sprintf(path,strtok(NULL,"\n")); @@ -225,7 +225,7 @@ if (tmpFd->mp->fs->vfsOpenFile((char *)path,tmpFd) == 1) { /* If The File Is Found Then Set Up The Descriptor */ tmpFd->buffer = (char *)kmalloc(4096); - sprintf(tmpFd->fileName,"%s",file); + //sprintf(tmpFd->fileName,"%s",file); /* Set Its Status To Open */ tmpFd->status = fdOpen; /* Initial File Offset Is Zero */ @@ -261,6 +261,9 @@ /*** $Log$ + Revision 1.11 2004/07/22 19:43:36 reddawg + ok we are absolute now...... ? + Revision 1.10 2004/07/21 10:02:09 reddawg devfs: renamed functions device system: renamed functions