diff --git a/src/bin/cp/main.c b/src/bin/cp/main.c index 46be7bf..b0ea3b1 100644 --- a/src/bin/cp/main.c +++ b/src/bin/cp/main.c @@ -30,27 +30,42 @@ #include #include -int main(int argc,char **argv) { - int i = 0x0; - char *buffer = (char *)malloc(0x2000); - FILE *in = 0x0; - FILE *out = 0x0; - in = fopen(argv[1],"rb"); - out = fopen(argv[2],"wb"); - /* - while (!feof(in)) { - */ - for (i=0;i<21;i++) { - fread(buffer,0x1000,1,in); - fwrite(buffer,0x1000,1,out); - } - fclose(in); - fclose(out); - return(0x0); - } +int main(int argc,char **argv) +{ + int i = 0x0; + char *buffer = (char *)malloc(4096); + FILE *in = 0x0; + FILE *out = 0x0; + + if(argc != 3) + { + printf("usage: cp \n"); + return 0; + } + + in = fopen(argv[1],"rb"); + out = fopen(argv[2],"wb"); + + if(in == NULL || out == NULL) + { + printf("unable to open file(s) for i/o\n"); + return 1; + } + while (!feof(in)) + { + fread(buffer,4096,1,in); + fwrite(buffer,4096,1,out); + } + fclose(in); + fclose(out); + return(0x0); +} /*** $Log$ + Revision 1.3 2004/05/24 13:40:35 reddawg + Clean Up + END ***/ diff --git a/src/lib/libc_old/stdio/Makefile b/src/lib/libc_old/stdio/Makefile index 592bc8e..6a003ad 100644 --- a/src/lib/libc_old/stdio/Makefile +++ b/src/lib/libc_old/stdio/Makefile @@ -6,7 +6,7 @@ include ../../Makefile.inc #Objects -OBJS = fprintf.o fseek.o printf.o vsprintf.o fd.o vfprintf.o fopen.o fread.o fwrite.o fgetc.o sprintf.o gets.o fclose.o +OBJS = fprintf.o fseek.o printf.o vsprintf.o fd.o vfprintf.o fopen.o fread.o fwrite.o fgetc.o sprintf.o gets.o fclose.o feof.o #Output OUTPUT = libc.so diff --git a/src/lib/libc_old/sys/getpid.c b/src/lib/libc_old/sys/getpid.c index 2a582aa..11ac625 100644 --- a/src/lib/libc_old/sys/getpid.c +++ b/src/lib/libc_old/sys/getpid.c @@ -29,17 +29,21 @@ #include -int getpid(void) { - volatile int pid = 0x0; - asm volatile( - "int %0\n" - : : "i" (0x80),"a" (1),"b" (&pid) - ); - return(pid); - } +int getpid(void) +{ + volatile int pid = 0x0; + asm volatile( + "int %0\n" + : : "i" (0x80),"a" (1),"b" (&pid) + ); + return(pid); +} /*** $Log$ + Revision 1.4 2004/08/02 18:50:13 reddawg + Updates to make some variable volatile to make work with gcc 3.3. However there are still some issues but we have not caused new issues with gcc 2.95 + Revision 1.3 2004/08/01 20:14:18 reddawg Fixens diff --git a/src/lib/libc_old/sys/sched.c b/src/lib/libc_old/sys/sched.c index 17af95d..c0fe422 100644 --- a/src/lib/libc_old/sys/sched.c +++ b/src/lib/libc_old/sys/sched.c @@ -3,11 +3,11 @@ int sched_yield(void) { - volatile int return_val = 0; - asm volatile( - "int %0\n" - : : "i" (0x80),"a" (11) - ); - return return_val; + volatile int return_val = 0; + asm volatile( + "int %0\n" + : : "i" (0x80),"a" (11) + ); + return return_val; } diff --git a/src/sys/devfs/devfs.c b/src/sys/devfs/devfs.c index c564f23..491d128 100644 --- a/src/sys/devfs/devfs.c +++ b/src/sys/devfs/devfs.c @@ -43,56 +43,58 @@ /* Length of dev list */ static int devfs_len = 0x0; -static void devfs_initialize(vfs_mountPoint_t *mp) { - struct devfs_info *fsInfo = 0x0; +static void devfs_initialize(vfs_mountPoint_t *mp) +{ + struct devfs_info *fsInfo = 0x0; - /* Allocate memory for the fsInfo */ - if ((mp->fsInfo = (struct devfs_info *)kmalloc(sizeof(struct devfs_info))) == 0x0) - kpanic("devfs: failed to allocate memor\n"); + /* Allocate memory for the fsInfo */ + if ((mp->fsInfo = (struct devfs_info *)kmalloc(sizeof(struct devfs_info))) == 0x0) + kpanic("devfs: failed to allocate memor\n"); - fsInfo = mp->fsInfo; - fsInfo->deviceList = 0x0; + fsInfo = mp->fsInfo; + fsInfo->deviceList = 0x0; + return; +} - //Return - return; - } +static int devfs_open(char *file,fileDescriptor *fd) +{ + struct devfs_info *fsInfo = fd->mp->fsInfo; + struct devfs_devices *tmpDev = 0x0; + struct device_node *device = 0x0; -static int devfs_open(char *file,fileDescriptor *fd) { - struct devfs_info *fsInfo = fd->mp->fsInfo; - struct devfs_devices *tmpDev = 0x0; - struct device_node *device = 0x0; - spinLock(&devfsSpinLock); - - if (strcmp(file,"/") == 0x0) { - fd->start = -1; - fd->size = devfs_len; - spinUnlock(&devfsSpinLock); - return(0x1); - } + if (strcmp(file,"/") == 0x0) { + fd->start = -1; + fd->size = devfs_len; + return(0x1); + } - for (tmpDev = fsInfo->deviceList;tmpDev != 0x0;tmpDev = tmpDev->next) { - if (strcmp(tmpDev->devName,file) == 0x0) { - switch ((fd->mode & 0x3)) { - case 0: - case 1: - device = device_find(tmpDev->devMajor,tmpDev->devMinor); - (void *)fd->start = tmpDev; - fd->size = device->devInfo->size; - break; - default: - kprintf("Invalid File Mode\n"); - spinUnlock(&devfsSpinLock); - return(-1); - break; - } - spinUnlock(&devfsSpinLock); - return(0x1); - } - } - spinUnlock(&devfsSpinLock); - return(0x0); - } + spinLock(&devfsSpinLock); + for (tmpDev = fsInfo->deviceList;tmpDev != 0x0;tmpDev = tmpDev->next) + { + if (strcmp(tmpDev->devName,file) == 0x0) + { + switch ((fd->mode & 0x3)) + { + case 0: + case 1: + device = device_find(tmpDev->devMajor,tmpDev->devMinor); + fd->start = tmpDev; + fd->size = device->devInfo->size; + break; + default: + kprintf("Invalid File Mode\n"); + spinUnlock(&devfsSpinLock); + return(-1); + break; + } + spinUnlock(&devfsSpinLock); + return(0x1); + } + } + spinUnlock(&devfsSpinLock); + return(0x0); +} /************************************************************************ diff --git a/src/sys/include/sys/tss.h b/src/sys/include/sys/tss.h index f9a3e1a..afd41d5 100644 --- a/src/sys/include/sys/tss.h +++ b/src/sys/include/sys/tss.h @@ -32,44 +32,48 @@ #include -struct tssStruct { - short back_link; - short back_link_reserved; - long esp0; - short ss0; - short ss0_reserved; - long esp1; - short ss1; - short ss1_reserved; - long esp2; - short ss2; - short ss2_reserved; - long cr3; - long eip; - long eflags; - long eax,ecx,edx,ebx; - long esp; - long ebp; - long esi; - long edi; - short es; - short es_reserved; - short cs; - short cs_reserved; - short ss; - short ss_reserved; - short ds; - short ds_reserved; - short fs; - short fs_reserved; - short gs; - short gs_reserved; - short ldt; - short ldt_reserved; - short trace_bitmap; - short io_map; - char io_space[8192]; - }; +struct tssStruct +{ + short back_link; + short back_link_reserved; + long esp0; + short ss0; + short ss0_reserved; + long esp1; + short ss1; + short ss1_reserved; + long esp2; + short ss2; + short ss2_reserved; + long cr3; + long eip; + long eflags; + long eax; + long ecx; + long edx; + long ebx; + long esp; + long ebp; + long esi; + long edi; + short es; + short es_reserved; + short cs; + short cs_reserved; + short ss; + short ss_reserved; + short ds; + short ds_reserved; + short fs; + short fs_reserved; + short gs; + short gs_reserved; + short ldt; + short ldt_reserved; + short trace_bitmap; + short io_map; + char io_space[8192]; +}; struct i387Struct { long cwd; @@ -111,6 +115,9 @@ /*** $Log$ + Revision 1.6 2004/07/27 07:42:29 reddawg + *burp* + Revision 1.5 2004/07/27 07:40:41 reddawg does it compile now? diff --git a/src/sys/include/ubixos/sched.h b/src/sys/include/ubixos/sched.h index 5559f7f..72c8b8e 100644 --- a/src/sys/include/ubixos/sched.h +++ b/src/sys/include/ubixos/sched.h @@ -50,19 +50,20 @@ char cwd[1024]; /* current working dir */ }; -typedef struct taskStruct { - pidType id; - struct taskStruct *prev; - struct taskStruct *next; - struct tssStruct tss; - struct i387Struct i387; - struct osInfo oInfo; - fileDescriptor *imageFd; - tState state; - uInt32 gid; - uInt32 uid; - uInt16 usedMath; - tty_term *term; +typedef struct taskStruct +{ + pidType id; + struct taskStruct *prev; + struct taskStruct *next; + struct tssStruct tss; + struct i387Struct i387; + struct osInfo oInfo; + fileDescriptor *imageFd; + tState state; + uInt32 gid; + uInt32 uid; + uInt16 usedMath; + tty_term *term; } kTask_t; @@ -86,6 +87,9 @@ /*** $Log$ + Revision 1.30 2004/09/11 22:21:11 reddawg + oInfo.cwd is now an array no longer a pointer.. + Revision 1.29 2004/09/08 23:19:58 reddawg hmm diff --git a/src/sys/include/ubixos/syscalls.h b/src/sys/include/ubixos/syscalls.h index 19cd1f2..a8339ad 100644 --- a/src/sys/include/ubixos/syscalls.h +++ b/src/sys/include/ubixos/syscalls.h @@ -44,6 +44,7 @@ void sysCheckPid(); void sysGetFreePage(); +void sysFeof(); void sysFwrite(); void sysFgetc(); void sysFopen(); @@ -83,7 +84,7 @@ sysCheckPid, /** 6 **/ sysGetFreePage, /** 7 **/ sysFopen, /** 8 **/ - invalidCall, /** 9 **/ + sysFeof, /** 9 **/ sysFclose, /** 10 **/ sysSchedYield, /** 11 **/ invalidCall, /** 12 **/ @@ -137,6 +138,10 @@ /*** $Log$ + Revision 1.5 2005/08/04 22:48:39 fsdfs + + added 4 new syscalls: sysAuth(), sysPasswd(), sysAddModule(), sysRmModule() + Revision 1.4 2004/05/26 15:39:22 reddawg mpi: brought mpiDestroyMbox(char *name) in to the userland diff --git a/src/sys/include/vfs/vfs.h b/src/sys/include/vfs/vfs.h index 2a58ecc..4cf289b 100644 --- a/src/sys/include/vfs/vfs.h +++ b/src/sys/include/vfs/vfs.h @@ -46,19 +46,21 @@ #define fileBinary 0x0004 #define fileAppend 0x0008 -struct fileSystem { - struct fileSystem *prev; - struct fileSystem *next; - int (*vfsInitFS)(void *); - int (*vfsRead)(void *,char *,long,long); - int (*vfsWrite)(void *,char *,long,long); - int (*vfsOpenFile)(void *,void *); - int (*vfsUnlink)(char *,void *); - int (*vfsMakeDir)(char *,void *); - int (*vfsRemDir)(char *); - int (*vfsSync)(void); - int vfsType; - }; +struct fileSystem +{ + struct fileSystem *prev; + struct fileSystem *next; + int (*vfsInitFS)(void *); + int (*vfsRead)(void *,char *,long,long); + int (*vfsWrite)(void *,char *,long,long); + int (*vfsFeof)(void *); + int (*vfsOpenFile)(void *,void *); + int (*vfsUnlink)(char *,void *); + int (*vfsMakeDir)(char *,void *); + int (*vfsRemDir)(char *); + int (*vfsSync)(void); + int vfsType; +}; /* VFS Functions */ @@ -80,6 +82,11 @@ /*** $Log$ + Revision 1.5 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 + END ***/ diff --git a/src/sys/kernel/spinlock.c b/src/sys/kernel/spinlock.c index 6c4b722..cf358e2 100644 --- a/src/sys/kernel/spinlock.c +++ b/src/sys/kernel/spinlock.c @@ -30,41 +30,39 @@ #include #include -void spinLockInit(spinLock_t *lock) { - *lock = SPIN_LOCK_INITIALIZER; - } - -void spinUnlock(spinLock_t *lock) { - *lock = 0x0; - /* - register int unlocked; - asm volatile( - "xchgl %0, %1" - : "=&r" (unlocked), "=m" (*lock) : "0" (0) - ); - */ - } - -int spinTryLock(spinLock_t *lock) { - register int locked; - asm volatile("xchgl %0, %1" - : "=&r" (locked), "=m" (*lock) : "0" (1) - ); - return(!locked); - } - -void spinLock(spinLock_t *lock) { - while (!spinTryLock(lock)) - { - while (*lock == 1) - sched_yield(); - } +void spinLockInit(spinLock_t *lock) +{ + *lock = SPIN_LOCK_INITIALIZER; } -void spinLock_scheduler(spinLock_t *lock) { - while (!spinTryLock(lock)) - while (*lock == 1); - } +void spinUnlock(spinLock_t *lock) +{ + *lock = 0x0; +} + +int spinTryLock(spinLock_t *lock) +{ + register int locked; + asm volatile("xchgl %0, %1" + : "=&r" (locked), "=m" (*lock) : "0" (1) + ); + return(!locked); +} + +void spinLock(spinLock_t *lock) +{ + while (!spinTryLock(lock)) + { + while (*lock == 1) + sched_yield(); + } +} + +void spinLock_scheduler(spinLock_t *lock) +{ + while (!spinTryLock(lock)) + while (*lock == 1); +} int spinLockLocked(spinLock_t *lock) { diff --git a/src/sys/vfs/file.c b/src/sys/vfs/file.c index 9b30794..dde0910 100644 --- a/src/sys/vfs/file.c +++ b/src/sys/vfs/file.c @@ -46,6 +46,11 @@ /* USER */ +void sysFeof(userFileDescriptor *userFd) +{ + return; +} + void sysFwrite(char *ptr,int size,userFileDescriptor *userFd) { if (userFd == 0x0) { tty_print(ptr,_current->term); @@ -138,17 +143,15 @@ Notes: ************************************************************************/ -void sysFread(void *data,long size,userFileDescriptor *userFd) { - /* TODO : coredump? */ - if (userFd == NULL) - return; - if (userFd->fd == NULL) - return; - kprintf("X"); - fread(data,size,1,userFd->fd); - kprintf("Y"); - return; - } +void sysFread(void *data,long size,userFileDescriptor *userFd) +{ + if (userFd == NULL) + return; + if (userFd->fd == NULL) + return; + fread(data,size,1,userFd->fd); + return; +} /************************************************************************ @@ -157,54 +160,59 @@ Notes: ************************************************************************/ -void sysFclose(userFileDescriptor *userFd,int *status) { - if (userFd == NULL ) - { - *status = -1; +void sysFclose(userFileDescriptor *userFd,int *status) +{ + if (userFd == NULL ) + { + *status = -1; + return; + } + if (userFd->fd == NULL) + { + *status = -1; + return; + } + *status = fclose(userFd->fd); return; - } - if (userFd->fd == NULL) - { - *status = -1; - return; - } - *status = fclose(userFd->fd); - /* Return */ - return; - } +} /* KERNEL */ -size_t fread(void *ptr,int size,int nmemb,fileDescriptor *fd) { - - if (fd == 0x0) - return(0x0); - - if (nmemb == 0x0) nmemb = 1; //Temp Fix - assert(fd); - //kprintf("fd->fileName: %s:%i\n",fd->fileName,_current->id); - assert(fd->mp); - assert(fd->mp->fs); - fd->mp->fs->vfsRead(fd,ptr,fd->offset,size * nmemb); - fd->offset += size * nmemb; - return(size * nmemb); - } +size_t fread(void *ptr,int size,int nmemb,fileDescriptor *fd) +{ + if (fd == 0x0) + return(0x0); + if (nmemb == 0x0) + nmemb = 1; //Temp Fix -size_t fwrite(void *ptr,int size,int nmemb,fileDescriptor *fd) { - if (fd != 0x0) { - fd->mp->fs->vfsWrite(fd,ptr,fd->offset,size * nmemb); - fd->offset += size * nmemb; - } - return(0x0); - } +#ifdef DEBUG + assert(fd); + assert(fd->mp); + assert(fd->mp->fs); +#endif + fd->mp->fs->vfsRead(fd,ptr,fd->offset,size * nmemb); + fd->offset += size * nmemb; + return(size * nmemb); +} -int fseek(fileDescriptor *tmpFd,long offset,int whence) { - tmpFd->offset = offset+whence; - return(tmpFd->offset); - } +size_t fwrite(void *ptr,int size,int nmemb,fileDescriptor *fd) +{ + if (fd != 0x0) + { + fd->mp->fs->vfsWrite(fd,ptr,fd->offset,size * nmemb); + fd->offset += size * nmemb; + } + return(0x0); +} + +int fseek(fileDescriptor *tmpFd,long offset,int whence) +{ + tmpFd->offset = offset+whence; + return(tmpFd->offset); +} /************************************************************************ @@ -213,12 +221,12 @@ Notes: ************************************************************************/ -int feof(fileDescriptor *fd) { - if (fd->status == fdEof) { - return(-1); - } - return(0); - } +int feof(fileDescriptor *fd) +{ + if (fd->status == fdEof) + return(-1); + return(0); +} /************************************************************************ @@ -227,15 +235,17 @@ Notes: ************************************************************************/ -int fputc(int ch,fileDescriptor *fd) { - if (fd != 0x0) { - ch = fd->mp->fs->vfsWrite(fd,(char *)ch,fd->offset,1); - fd->offset++; - return(ch); - } - /* Return NULL If FD Is Not Found */ - return(0x0); - } +int fputc(int ch,fileDescriptor *fd) +{ + if (fd != 0x0) + { + ch = fd->mp->fs->vfsWrite(fd,(char *)ch,fd->offset,1); + fd->offset++; + return(ch); + } + /* Return NULL If FD Is Not Found */ + return(0x0); +} /************************************************************************ @@ -244,18 +254,18 @@ Notes: ************************************************************************/ -int fgetc(fileDescriptor *fd) { - int ch = 0x0; - /* If Found Return Next Char */ - if (fd != 0x0) { - fd->mp->fs->vfsRead(fd,(char *)&ch,fd->offset,1); - fd->offset++; - return(ch); - } - - /* Return NULL If FD Is Not Found */ - return(0x0); - } +int fgetc(fileDescriptor *fd) +{ + int ch = NULL; + if (fd != NULL) + { + fd->mp->fs->vfsRead(fd,(char *)&ch,fd->offset,1); + fd->offset++; + return(ch); + } + /* Return NULL If FD Is Not Found */ + return NULL; +} /************************************************************************ @@ -268,130 +278,117 @@ ************************************************************************/ fileDescriptor *fopen(const char *file,const char *flags) { - int i = 0x0; - char *path = 0x0; - char *mountPoint = 0x0; - char fileName[1024]; - fileDescriptor *tmpFd = 0x0; + int i = 0x0; + char *path = 0x0; + char *mountPoint = 0x0; + char fileName[1024]; + fileDescriptor *tmpFd = 0x0; - /* Allocate Memory For File Descriptor */ - if((tmpFd = (fileDescriptor *)kmalloc(sizeof(fileDescriptor))) == 0x0) { - kprintf("Error: tmpFd == NULL, File: %s, Line: %i\n",__FILE__,__LINE__); - return(NULL); - } + /* Allocate Memory For File Descriptor */ + if((tmpFd = (fileDescriptor *)kmalloc(sizeof(fileDescriptor))) == 0x0) { + kprintf("Error: tmpFd == NULL, File: %s, Line: %i\n",__FILE__,__LINE__); + return(NULL); + } - sprintf(fileName,"%s",file); + sprintf(fileName,"%s",file); - if (strstr(fileName,":")) { - mountPoint = (char *)strtok((char *)&fileName,":"); - path = strtok(NULL,"\n"); - } - else { - path = fileName; - //path = &fileName; - } + if (strstr(fileName,":")) + { + mountPoint = (char *)strtok((char *)&fileName,":"); + path = strtok(NULL,"\n"); + } + else + path = fileName; - if (path[0] == '/') { - sprintf(tmpFd->fileName,"%s", path); - } - else { - sprintf(tmpFd->fileName,"/%s",path); - } + if (path[0] == '/') + sprintf(tmpFd->fileName,"%s", path); + else + sprintf(tmpFd->fileName,"/%s",path); - /* Find our mount point or set default to sys */ - if (mountPoint == 0x0) { - tmpFd->mp = vfs_findMount("sys"); - } - else { - tmpFd->mp = vfs_findMount(mountPoint); - } + /* Find our mount point or set default to sys */ + if (mountPoint == 0x0) + tmpFd->mp = vfs_findMount("sys"); + else + tmpFd->mp = vfs_findMount(mountPoint); - if (tmpFd->mp == 0x0) { - kprintf("Mount Point Bad\n"); - return(0x0); - } + if (tmpFd->mp == 0x0) + { + kprintf("Mount Point Bad\n"); + return(0x0); + } - /* This Will Set Up The Descriptor Modes */ - tmpFd->mode = 0; - for (i = 0; '\0' != flags[i] ;i++ ) { - switch(flags[i]) { - case 'w': - case 'W': - tmpFd->mode |= fileWrite; - break; - case 'r': - case 'R': - tmpFd->mode |= fileRead; - break; - case 'b': - case 'B': - tmpFd->mode |= fileBinary; - break; - case 'a': - case 'A': - tmpFd->mode |= fileAppend; - break; - default: - kprintf("Invalid mode '%c' for fopen\n", flags[i]); - break; - } - } + /* This Will Set Up The Descriptor Modes */ + tmpFd->mode = 0; + for (i = 0; '\0' != flags[i] ;i++ ) + switch(flags[i]) + { + case 'w': + case 'W': + tmpFd->mode |= fileWrite; + break; + case 'r': + case 'R': + tmpFd->mode |= fileRead; + break; + case 'b': + case 'B': + tmpFd->mode |= fileBinary; + break; + case 'a': + case 'A': + tmpFd->mode |= fileAppend; + break; + default: + kprintf("Invalid mode '%c' for fopen\n", flags[i]); + break; + } - /* Search For The File */ - if (tmpFd->mp->fs->vfsOpenFile(tmpFd->fileName,tmpFd) == 0x1) { - /* If The File Is Found Then Set Up The Descriptor */ + /* Search For The File */ + if (tmpFd->mp->fs->vfsOpenFile(tmpFd->fileName,tmpFd) == 0x1) + { + /* If The File Is Found Then Set Up The Descriptor */ - /* in order to save resources we will allocate the buffer later when it is needed */ + tmpFd->buffer = (char *)kmalloc(4096); + if(tmpFd->buffer == 0x0) + { + kfree(tmpFd); + kprintf("Error: tmpFd->buffer == NULL, File: %s, Line: %i\n",__FILE__,__LINE__); + spinUnlock(&fdTable_lock); + return 0x1; + } - tmpFd->buffer = (char *)kmalloc(4096); - if(tmpFd->buffer == 0x0) - { - kfree(tmpFd); - kprintf("Error: tmpFd->buffer == NULL, File: %s, Line: %i\n",__FILE__,__LINE__); - spinUnlock(&fdTable_lock); - return 0x1; - } + /* Set Its Status To Open */ + tmpFd->status = fdOpen; + + /* Initial File Offset Is Zero */ + tmpFd->offset = 0; + tmpFd->prev = 0x0; - /* Set Its Status To Open */ - tmpFd->status = fdOpen; + spinLock(&fdTable_lock); + /* Increment Number Of Open Files */ + systemVitals->openFiles++; + tmpFd->next = fdTable; + if (fdTable != 0x0) + fdTable->prev = tmpFd; + fdTable = tmpFd; + spinUnlock(&fdTable_lock); + + /* Return The FD */ + return(tmpFd); + } + else + { + spinUnlock(&fdTable_lock); + kfree(tmpFd->buffer); + kfree(tmpFd); + return (NULL); + } - /* Initial File Offset Is Zero */ - tmpFd->offset = 0; - tmpFd->prev = 0x0; - - /* we do not want to be in a spinlock longer than we need to, so - it has been moved to here. */ - spinLock(&fdTable_lock); - - /* Increment Number Of Open Files */ - systemVitals->openFiles++; - - tmpFd->next = fdTable; - - if (fdTable != 0x0) - fdTable->prev = tmpFd; - - fdTable = tmpFd; - - spinUnlock(&fdTable_lock); - - - /* Return The FD */ - return(tmpFd); - } - else { - kfree(tmpFd->buffer); - kfree(tmpFd); - spinUnlock(&fdTable_lock); - - return (NULL); - } - - /* Return NULL */ - return(0x0); - } + /* Return NULL */ + return(0x0); +} /************************************************************************ @@ -402,7 +399,10 @@ ************************************************************************/ int fclose(fileDescriptor *fd) { fileDescriptor *tmpFd = 0x0; + +#ifdef DEBUG assert(fd); +#endif spinLock(&fdTable_lock); diff --git a/src/tools/Makefile b/src/tools/Makefile index 4ab2a49..22cad05 100644 --- a/src/tools/Makefile +++ b/src/tools/Makefile @@ -51,9 +51,9 @@ (cp ../bin/ubistry/ubistry ./) (cp ../sys/boot/mbr/mbr ./) (cp ../bin/ld/ld.so ./) - #(cp /lib/libc.so.5 ./) + (cp /lib/libc.so.5 ./) (cp ../bin/ttyd/ttyd ./) - (./format 50 7000 ${FD_DEVICE} ubix.elf 0 login 3754 init 3754 stat 3754 ubistry 3754 shell 3754 userdb 3754 ls 3754 motd 3754 fdisk 3754 cp 3754 clock 3754 libc_old.so 3754 ld.so 3754 ttyd 3754 ) + (./format 50 2000 ${FD_DEVICE} ubix.elf 0 login 3754 init 3754 stat 3754 ubistry 3754 shell 3754 userdb 3754 ls 3754 motd 3754 fdisk 3754 cp 3754 clock 3754 libc_old.so 3754 ld.so 3754 ttyd 3754 ) # (./format 50 2000 ${FD_DEVICE} ubix.elf 0 login 3754 init 3754 ubistry 3754 shell 3754 userdb 3754 motd 3754 libc_old.so 3754 ld.so 3754 test 3754 libc.so.5 3754) #(./format 263 204361 /dev/md1 ubix.elf 0 format 3754 fdisk 3754 ROM8X14.DPF 3754 init 3754 login 3754 shell 3754 userdb 3754 ls 3754 motd 3754 cp 3754)