diff options
Diffstat (limited to 'userspace')
| -rw-r--r-- | userspace/Makefile | 2 | ||||
| -rw-r--r-- | userspace/foolshell.c | 26 | ||||
| -rw-r--r-- | userspace/init.c | 10 | ||||
| -rw-r--r-- | userspace/test.txt | 5 |
4 files changed, 19 insertions, 24 deletions
diff --git a/userspace/Makefile b/userspace/Makefile index 74e0943..dbc2d0f 100644 --- a/userspace/Makefile +++ b/userspace/Makefile @@ -39,6 +39,8 @@ ext2.img: $(PROGS) @mkdir -p mnt/boot @echo "Welcome to FoolOs\nWe hope you will enjoy your stay." > mnt/home/miguel/hello.txt @mkdir -p mnt/bin + @mkdir -p mnt/doc/test + @cp test.txt mnt/doc/test/ @cp $(PROGS) mnt/bin @cp fonts/binfont.bin mnt/ @echo "++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++." > mnt/home/miguel/hello.brain diff --git a/userspace/foolshell.c b/userspace/foolshell.c index 984cc4f..3c1fb50 100644 --- a/userspace/foolshell.c +++ b/userspace/foolshell.c @@ -52,15 +52,9 @@ void prompt() int main(int argc, char **argv) { -/* - printf("_impure_ptr: 0x%08x\n",_impure_ptr); - printf("argv= 0x%08x \n",argv); - printf("environ= 0x%08x \n",environ); -*/ bool silent=false; for(int i=0;i<argc;i++) { -// printf("%i:%s\n",i+1,argv[i]); if(!strcmp(argv[i],"--silent"))silent=true; } @@ -69,6 +63,7 @@ int main(int argc, char **argv) char *buf=calloc(sizeof(char),256); setvbuf(stdin,NULL,_IONBF,0); + setvbuf(stdout,NULL,_IONBF,0); while(1) { @@ -217,12 +212,10 @@ int process(char *buf) // printf("adjusted: '%s'\n",buf); if(buf[0]==0)setenv("PWD","/",1); else setenv("PWD",buf,1); - } else if(!strcmp(command,"exit")) { - exit(1); - + _exit(1); } else if(!strcmp(command,"echo")) { @@ -253,23 +246,18 @@ int process(char *buf) else { int pid=_fork(); - if(pid!=0) - { - // printf("new task pid: %i \n",pid); - } + if(pid==0) { - char buf[256]; sprintf(buf,"%s",token[0]); _execve(buf,token,environ); - //sprintf(buf,"%s/%s",getenv("PATH"),token[0]); - sprintf(buf,"%s/%s","/bin",token[0]); + sprintf(buf,"%s/%s",getenv("PATH"),token[0]); _execve(buf,token,environ); puts("foolshell: command not found"); - exit(1); + exit(0); } - int status; - if(strcmp(token[1],"branch"))_wait(&status); + + if(token[1]!=NULL&&strcmp(token[1],"branch"))_wait(pid); } return 0; diff --git a/userspace/init.c b/userspace/init.c index e04e7ce..a367fd9 100644 --- a/userspace/init.c +++ b/userspace/init.c @@ -7,28 +7,28 @@ int main(int argc, char **argv) char *argv1[]={"/bin/foolshell",0}; char *env1[]={"PS1=\033[34m$\033[37m","PWD=/home/miguel","PATH=/bin","TERM=fool-term",0}; + printf("fool-init\n"); time_t ltime; time(<ime); - printf("fool-init: current time: %s", ctime(<ime)); + printf("fool-init: current time: %s\n", ctime(<ime)); // loop forever and spawn shells if the top-shell exits while(1) { int pid=_fork(); + printf("fool-init: forked pid=%d\n", pid); - int status; if(pid==0) { _execve("/bin/foolshell",argv1,env1); // replace process with our foolshell :) - puts("FATAL ERROR: Something terrible happened. Unable to Execute SHELL!"); - while(1);// hang + while(1) puts("FATAL ERROR: Something terrible happened. Unable to Execute SHELL!\n"); } // wait until our child process state changes (exits) // and respawn SHELL - _wait(&status); + _wait(pid); printf("fool-init: catched exit of process %d.\n",pid); printf("fool-init: respawning a Fools Shell\n"); diff --git a/userspace/test.txt b/userspace/test.txt new file mode 100644 index 0000000..d44e39c --- /dev/null +++ b/userspace/test.txt @@ -0,0 +1,5 @@ +HELLO THIS IS A TEXTFILE +USED FOR TESTING THE FOOL OS EXT2 RAM IMAGE +TRY TO READ ME! + +BYE |
