diff --git a/src/bin/shell/main.c b/src/bin/shell/main.c index 3456bae..fad89fc 100755 --- a/src/bin/shell/main.c +++ b/src/bin/shell/main.c @@ -29,34 +29,29 @@ void _start() { main(); - } - -void gets(char *buffer) { - int count=0,ch=0; - while (1) { - ch = fgetc(stdin); - if(ch == 10) { - printf("\n"); - break; - } - else if(ch == 8 && count > 0) count-=2; - else if(ch == 0) count--; - else buffer[count] = ch; - printf("%c",ch); - count ++; - } - buffer[count] = '\0'; } +struct currentInfo { + char pwd[256]; + }; + int main() { unsigned char buffer[256],*tmp; int cPid = 0; + struct currentInfo curInfo[1];// = 0x900000; + sprintf(curInfo[0].pwd,"/"); while (1) { printf("UbixOS: "); gets((char *)&buffer); - if (0 == memcmp(buffer, "uname", 5)) + tmp = &buffer; + while (tmp[0] == ' ') { + tmp++; + } + if (0 == memcmp(tmp, "uname", 5)) printf("UbixOS v0.01a " __DATE__" " __TIME__ " \n"); - if (memcmp(buffer,"stress", 6) == 0) { + else if (0 == memcmp(tmp, "pwd", 3)) + printf("Pwd: [%s]\n",curInfo[0].pwd); + else if (memcmp(tmp,"stress", 6) == 0) { while (1) { cPid = fork(); printf("Pid: [%i]\n",cPid); @@ -69,14 +64,11 @@ } } } - if (memcmp(buffer,"exec", 4) == 0) { - tmp = &buffer; - tmp += 5; + else if (*tmp > 0) { cPid = fork(); - printf("Pid: [%i]\n",cPid); if (!cPid) { if (exec(tmp) == 0) { - printf("Error Starting Application: [%s]\n",tmp); + printf("%s: Command Not Found.\n",tmp); } exit(1); } diff --git a/src/lib/libc/Makefile b/src/lib/libc/Makefile index 29386ca..6a4b13b 100755 --- a/src/lib/libc/Makefile +++ b/src/lib/libc/Makefile @@ -16,6 +16,9 @@ #Objects OBJS = +#Sub Sections +SUBS = ./stdio/*.o ./sys/*.o ./string/*.o ./stdlib/*.o + #Output OUTPUT = libc.so @@ -24,7 +27,8 @@ (cd stdlib;make) (cd sys;make) (cd string;make) - $(LD) -o $(OUTPUT) $(OBJS) ./stdio/*.o ./sys/*.o ./string/*.o ./stdlib/*.o +# $(LD) -o $(OUTPUT) $(OBJS) ./stdio/*.o ./sys/*.o ./string/*.o ./stdlib/*.o + $(GCC) -nostdlib -shared -soname libc.so -o $(OUTPUT) $(OBJS) $(SUBS) # Compile the source files .cc.o: diff --git a/src/lib/libc/include/stdio.h b/src/lib/libc/include/stdio.h index 39669da..1cf3bbd 100755 --- a/src/lib/libc/include/stdio.h +++ b/src/lib/libc/include/stdio.h @@ -50,4 +50,8 @@ int fwrite(const void *ptr,int size,FILE *fd); int fgetc(FILE *fd); +//New Functions Listed From Here On Till I'm Done Writing A libc +int sprintf(char *string, const char *format, ...); +char *gets(char *string); + #endif \ No newline at end of file diff --git a/src/lib/libc/stdio/Makefile b/src/lib/libc/stdio/Makefile index e3c5b87..7570829 100755 --- a/src/lib/libc/stdio/Makefile +++ b/src/lib/libc/stdio/Makefile @@ -15,7 +15,7 @@ REMOVE = rm -f #Objects -OBJS = printf.o vsprintf.o fd.o vfprintf.o fopen.o fwrite.o fgetc.o +OBJS = printf.o vsprintf.o fd.o vfprintf.o fopen.o fwrite.o fgetc.o sprintf.o gets.o #Output OUTPUT = libc.so diff --git a/src/lib/libc/stdio/gets.c b/src/lib/libc/stdio/gets.c new file mode 100755 index 0000000..ab7bbc1 --- /dev/null +++ b/src/lib/libc/stdio/gets.c @@ -0,0 +1,42 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id$ + +**************************************************************************************/ + +#include + +char *gets(char *string) { + int count=0,ch=0; + while (1) { + ch = fgetc(stdin); + if(ch == 10) { + printf("\n"); + break; + } + else if(ch == 8 && count > 0) count-=2; + else if(ch == 0) count--; + else string[count] = ch; + printf("%c",ch); + count ++; + } + string[count] = '\0'; + return(string); + } \ No newline at end of file diff --git a/src/lib/libc/stdio/sprintf.c b/src/lib/libc/stdio/sprintf.c new file mode 100755 index 0000000..dc19025 --- /dev/null +++ b/src/lib/libc/stdio/sprintf.c @@ -0,0 +1,33 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id$ + +**************************************************************************************/ + +#include + +int sprintf(char *string, const char *format, ...) { + vaList args; + int retVal = 0x0; + vaStart(args, format); + retVal = vsprintf(string,format,args); + vaEnd(args) + return(retVal); + } \ No newline at end of file diff --git a/src/sys/include/ubixfs/file.h b/src/sys/include/ubixfs/file.h index 0142921..e3d36aa 100755 --- a/src/sys/include/ubixfs/file.h +++ b/src/sys/include/ubixfs/file.h @@ -32,24 +32,24 @@ #define fdRead 3 #define fdEof 4 -struct fileDescriptor { - struct fileDescriptor *next; - uShort id; - uShort status; - uShort mode; - uShort offset; - uLong size; - uShort length; - uLong start; - uChar fileName[22]; - uChar buffer[512]; - }; +typedef struct fileDescriptorStruct { + struct fileDescriptorStruct *next; + uShort status; + uShort mode; + uShort offset; + uLong size; + uShort length; + uLong start; + uChar fileName[22]; + uChar buffer[512]; + } fileDescriptor; -extern struct fileDescriptor *fdTable; +extern fileDescriptor *fdTable; +extern fileDescriptor *lastFd; -int fopen(const char *file,int mode); -int fclose(int fd); -int feof(int fd); -int fgetc(int fd); +fileDescriptor *fopen(const char *file,const char *flags); +int fclose(fileDescriptor *fd); +int feof(fileDescriptor *fd); +int fgetc(fileDescriptor *fd); #endif diff --git a/src/sys/include/ubixfs/ubixfs.h b/src/sys/include/ubixfs/ubixfs.h index 67b011f..0c4ebc7 100755 --- a/src/sys/include/ubixfs/ubixfs.h +++ b/src/sys/include/ubixfs/ubixfs.h @@ -51,9 +51,9 @@ }; void initUbixFS(); -int findFile(char *file,struct fileDescriptor *fd); +int findFile(char *file,fileDescriptor *fd); int readFile(char *file); -int getFileByte(struct fileDescriptor *fd,int offset); +int getFileByte(fileDescriptor *fd,int offset); extern int startSector; diff --git a/src/sys/include/ubixos/vitals.h b/src/sys/include/ubixos/vitals.h new file mode 100755 index 0000000..05dfb14 --- /dev/null +++ b/src/sys/include/ubixos/vitals.h @@ -0,0 +1,36 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id$ + +**************************************************************************************/ + +#ifndef _VITALS_H +#define _VITALS_H + +#include + +typedef struct vitalsStruct { + uLong openFiles; + } vitalsNode; + +extern vitalsNode *systemVitals; + +void initVitals(); +#endif \ No newline at end of file diff --git a/src/sys/init/main.c b/src/sys/init/main.c index 7b5a341..edc2af2 100755 --- a/src/sys/init/main.c +++ b/src/sys/init/main.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -87,6 +88,7 @@ clearScreen(); //Clear The Screen outputVersion(); //Display Version Info initPagingSystem(); //Initialize Paging System + initVitals(); //Initialize Vitals Tracking init8259(); //Initialize PIC initIdt(); //Initialize IDT initKeyboard(); //Initialize Keyboard diff --git a/src/sys/kernel/Makefile b/src/sys/kernel/Makefile index 74a4617..d618def 100755 --- a/src/sys/kernel/Makefile +++ b/src/sys/kernel/Makefile @@ -14,7 +14,7 @@ REMOVE = rm -fr # Objects -OBJS = io.o version.o kprintf.o vsprintf.o idt.o schedule.o exec.o dma.o idlethread.o syscall.o fork.o kmalloc.o spinlock.o +OBJS = io.o version.o kprintf.o vsprintf.o idt.o schedule.o exec.o dma.o idlethread.o syscall.o fork.o kmalloc.o spinlock.o vitals.o all: $(OBJS) diff --git a/src/sys/kernel/exec.c b/src/sys/kernel/exec.c index 03ebc5e..7a01cd1 100755 --- a/src/sys/kernel/exec.c +++ b/src/sys/kernel/exec.c @@ -45,10 +45,10 @@ ************************************************************************/ void execFile(char *file) { - int fd=0,i=0,x=0,eStart=0; + int i=0,x=0,eStart=0; char *binarySpace = (char *)0x7C0000; char *newLoc; - struct fileDescriptor *tmpFd = 0x0; + fileDescriptor *tmpFd = 0x0; elfHeader *binaryHeader = (elfHeader *)0x7C0000; elfProgramheader *programHeader; //Get A New Task For This Proccess @@ -62,13 +62,7 @@ : : "d" ((uLong *)(_current->tss.cr3)) ); //Lets Find The File - fd = fopen(file,1); - //Loop Through The File List To Get Information About This File Descriptor - for (tmpFd=fdTable;tmpFd;tmpFd=tmpFd->next) { - if (tmpFd->id == fd) { - break; - } - } + tmpFd = fopen(file,"r"); //If We Dont Find the File Return if (!tmpFd) { return; @@ -78,11 +72,11 @@ remapPage(findFreePage(_current->id),(0x7C0000 + (0x1000 * i))); } //Load The Binary Into Memory Byte For Byte I Should Find A Faster Way - for (i=0;feof(fd) == 0;i++) { - binarySpace[i] = fgetc(fd); - } + for (i=0;feof(tmpFd) == 0;i++) { + binarySpace[i] = fgetc(tmpFd); + } //Close The File - fclose(fd); + fclose(tmpFd); //Set programHeader To Point To Loaded Binary So We Can Gather Info programHeader = (elfProgramheader *)(0x7C0000 + binaryHeader->ePhoff); //Loop Through The Header And Load Sections Which Need To Be Loaded @@ -108,6 +102,8 @@ } //Now Lets Make A Clean Stack newLoc = (char *)0x5DC000; + remapPage(findFreePage(_current->id),0x5DB000); + setPageAttribute(0x5DB000,(pageDefault | pageStack)); remapPage(findFreePage(_current->id),0x5DC000); setPageAttribute(0x5DC000,(pageDefault | pageStack)); for (i=0;i<4096;i++) { diff --git a/src/sys/kernel/syscall.c b/src/sys/kernel/syscall.c index 2a4870c..85f58c0 100755 --- a/src/sys/kernel/syscall.c +++ b/src/sys/kernel/syscall.c @@ -83,39 +83,33 @@ void sysExec() { - int fd = 0,i = 0,x = 0; + int i = 0,x = 0; int *status; uLong eStart = 0; char *binarySpace = (char *)0x7C0000; char *newLoc; char *file; - struct fileDescriptor *tmpFd = 0x0; + fileDescriptor *tmpFd = 0x0; elfHeader *binaryHeader = (elfHeader *)0x7C0000; elfProgramheader *programHeader; asm("":"=b"(file),"=c"(status)); asm("sti"); - fd = (int)fopen(file,1); + tmpFd = fopen(file,"r"); //If We Dont Find the File Return - if (fd == -1) { + if (tmpFd == 0x0) { *status = 0; return; } - //Loop Through The File List To Get Information About This File Descriptor - for (tmpFd=fdTable;tmpFd;tmpFd=tmpFd->next) { - if (tmpFd->id == fd) { - break; - } - } //Now We Must Allocate Memory To Load The Binary Into for (i=0;i<((tmpFd->size+4095)/4096);i++) { remapPage(findFreePage(_current->id),(0x7C0000 + (0x1000 * i))); } //Load The Binary Into Memory Byte For Byte I Should Find A Faster Way - for (i=0;feof(fd) == 0;i++) { - binarySpace[i] = fgetc(fd); + for (i=0;feof(tmpFd) == 0;i++) { + binarySpace[i] = fgetc(tmpFd); } //Close The File - fclose(fd); + fclose(tmpFd); //Set programHeader To Point To Loaded Binary So We Can Gather Info programHeader = (elfProgramheader *)(0x7C0000 + binaryHeader->ePhoff); //Loop Through The Header And Load Sections Which Need To Be Loaded diff --git a/src/sys/kernel/vitals.c b/src/sys/kernel/vitals.c new file mode 100755 index 0000000..595d142 --- /dev/null +++ b/src/sys/kernel/vitals.c @@ -0,0 +1,43 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors +in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its +contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id$ + +**************************************************************************************/ + +#include +#include + +vitalsNode *systemVitals = 0x0; + +/************************************************************************ + +Function: void initVitals(); +Description: This Initializes The Systems Vital Monitor +Notes: + +************************************************************************/ +void initVitals() { + //Allocate Memory For System Vitals + systemVitals = (vitalsNode *)kmalloc(sizeof(vitalsNode)); + //Set Up Default Information + systemVitals->openFiles = 0x0; + //Return + return; + } \ No newline at end of file diff --git a/src/sys/ubixfs/file.c b/src/sys/ubixfs/file.c index 50fef42..5cf5034 100755 --- a/src/sys/ubixfs/file.c +++ b/src/sys/ubixfs/file.c @@ -23,66 +23,152 @@ #include #include +#include #include +#include -struct fileDescriptor *fdTable = 0x0; +fileDescriptor *fdTable = 0x0, *lastFd = 0x0; int sprintf(char *buf,const char *fmt, ...); -int fclose(int fd) { - struct fileDescriptor *tmpFd; - for (tmpFd=fdTable;tmpFd;tmpFd=tmpFd->next) { - if (tmpFd->id == fd) { - tmpFd->status = fdAvail; - break; +/************************************************************************ + +Function: fileDescriptor *fopen(const char *file,cont char *flags) +Description: This Will Open A File And Return A File Descriptor +Notes: + +08/05/02 - Just Started A Rewrite Of This Function Should Work Out Well + +************************************************************************/ + +fileDescriptor *fopen(const char *file,const char *flags) { + fileDescriptor *tmpFd = 0x0; + //Allocate Memory For File Descriptor + tmpFd = (fileDescriptor *)kmalloc(sizeof(fileDescriptor)); + //Search For The File + if (findFile((char *)file,tmpFd) == 1) { + //If The File Is Found Then Set Up The Descriptor + sprintf(tmpFd->fileName,"%s",file); + //This Will Set Up The Descriptor Modes + while (flags[0]) { + switch(flags[0]) { + case 'w': + case 'W': + tmpFd->mode = 1; + break; + case 'r': + case 'R': + tmpFd->mode = 0; + break; + default: + break; + } + flags++; } + //Set Its Status To Open + tmpFd->status = fdOpen; + //Initial File Offset Is Zero + tmpFd->offset = 0x0; + //Pointer To Next Descriptor Is NULL + tmpFd->next = 0x0; + //If This Is The First File Descriptor Then Set It Up To Be Starting Fd + if (fdTable == 0x0) { + fdTable = tmpFd; + lastFd = tmpFd; + } + else { + //If There Is Already A Starting FD Set This Up As The Last One + lastFd->next = tmpFd; + lastFd = tmpFd; + } + systemVitals->openFiles++; + //Return The FD + return(lastFd); + } + else { + //If The File Was Not Found Free The Memory + kfree(tmpFd); + } + //Return NULL + return(0x0); + } + +/************************************************************************ + +Function: int feof(fileDescriptor *fd) +Description: Check A File Descriptor For EOF And Return Result +Notes: + +************************************************************************/ +int feof(fileDescriptor *fd) { + if (fd->status == fdEof) { + return(-1); } return(0); } -int feof(int fd) { - struct fileDescriptor *tmpFd; +/************************************************************************ + +Function: int fclose(fileDescriptor *fd); +Description: This Will Close And Free A File Descriptor +Notes: + +************************************************************************/ +int fclose(fileDescriptor *fd) { + fileDescriptor *tmpFd,*prevFd; + prevFd = fdTable; + //Search For File Descriptor for (tmpFd=fdTable;tmpFd;tmpFd=tmpFd->next) { - if (tmpFd->id == fd) { - if (tmpFd->status == fdEof) { - return(-1); + if (tmpFd == fd) { + //If Fd Is The First FD Then Reset fdTable + if (tmpFd == fdTable) { + fdTable = tmpFd->next; + kfree(fd); + systemVitals->openFiles--; + return(1); } + //If FD Is The lastFd Then Reset lastFd + else if (tmpFd == lastFd) { + prevFd->next = 0x0; + lastFd = prevFd; + kfree(fd); + systemVitals->openFiles--; + return(1); + } + //This One Is Easy We Just Free The Fd And Adjust Pointers else { - return(0); + prevFd->next = tmpFd->next; + kfree(fd); + systemVitals->openFiles--; + return(1); } } + //Set Previous File Descriptor Pointer + prevFd = tmpFd; } - return(0); + //Return NULL If Descriptor Was Not Found + return(0x0); } -int fopen(const char *file,int mode) { - int ret=0; - struct fileDescriptor *tmpFdTable = 0x0; - for (tmpFdTable=fdTable;tmpFdTable;tmpFdTable=tmpFdTable->next) { - if (tmpFdTable->status == fdAvail) { - ret = findFile((char *)file,tmpFdTable); - if (ret == 1) { - sprintf(tmpFdTable->fileName,"%s",file); - tmpFdTable->mode = mode; - tmpFdTable->status = fdOpen; - tmpFdTable->offset = 0; - return(tmpFdTable->id); - } - else { return((int)-1); } - } - } - return((int)-1); - } +/************************************************************************ -int fgetc(int fd) { +Function: int fgetc(fileDescriptor *fd) +Description: This Will Return The Next Character In A FD Stream +Notes: + +************************************************************************/ +int fgetc(fileDescriptor *fd) { int ch = 0; - struct fileDescriptor *tmpFd = 0x0; + fileDescriptor *tmpFd = 0x0; + //Search For File Descriptor for (tmpFd=fdTable;tmpFd;tmpFd=tmpFd->next) { - if (tmpFd->id == fd) { + //If Found Return Next Char + if (tmpFd == fd) { ch = getFileByte(tmpFd,tmpFd->offset); tmpFd->offset++; return(ch); } } + //Return NULL If FD Is Not Found return(0x0); } \ No newline at end of file diff --git a/src/sys/ubixfs/ubixfs.c b/src/sys/ubixfs/ubixfs.c index 25b4283..2f3d742 100755 --- a/src/sys/ubixfs/ubixfs.c +++ b/src/sys/ubixfs/ubixfs.c @@ -32,9 +32,7 @@ int startSector; void initUbixFS() { - int i=0; struct bootSect *bs = 0x0; - struct fileDescriptor *tmpFdTable = 0x0; char data[512]; readBlock(0,data,1); bs = (void *)data; @@ -46,7 +44,7 @@ kprintf("Insert System Disk\n"); initUbixFS(); } - fdTable = kmalloc(sizeof(struct fileDescriptor)); +/* fdTable = kmalloc(sizeof(struct fileDescriptor)); tmpFdTable = fdTable; for (i=0;istatus = fdAvail; @@ -58,7 +56,7 @@ tmpFdTable->next = kmalloc(sizeof(struct fileDescriptor)); } tmpFdTable = tmpFdTable->next; - } + } */ } int kstrcmp(char *str1, char *str2) { @@ -81,7 +79,7 @@ return(0); } -int getFileByte(struct fileDescriptor *fd,int offset) { +int getFileByte(fileDescriptor *fd,int offset) { int ch=0,mp=0; mp = offset/512; if ((offset%512 == 0) && (fd->status == fdRead)) { @@ -101,7 +99,7 @@ return(ch); } -int findFile(char *file,struct fileDescriptor *fd) { +int findFile(char *file,fileDescriptor *fd) { int x=0; bool ret = TRUE; struct fileTableEntry *ft; diff --git a/src/sys/vmm/memory.c b/src/sys/vmm/memory.c index 2a8baef..35d3a2a 100755 --- a/src/sys/vmm/memory.c +++ b/src/sys/vmm/memory.c @@ -193,7 +193,7 @@ void freeProcessPages(pid_t pid) { int i=0,x=0; uLong *tmpPageTable = 0x0; - uLong *tmpPageDir = parentPageDirAddr; + uLong *tmpPageDir = (uLong *)parentPageDirAddr; //Check Page Directory For An Avail Page Table for (i=0;i