diff options
Diffstat (limited to 'userspace')
| -rw-r--r-- | userspace/Makefile | 16 | ||||
| -rw-r--r-- | userspace/foolshell.c (renamed from userspace/shell.c) | 33 | ||||
| -rw-r--r-- | userspace/ls.c | 8 |
3 files changed, 29 insertions, 28 deletions
diff --git a/userspace/Makefile b/userspace/Makefile index 55e78bc..3327375 100644 --- a/userspace/Makefile +++ b/userspace/Makefile @@ -4,7 +4,7 @@ CFLAGS= CFLAGS+=-w CFLAGS+=-std=gnu11 -PROGS=shell simple brainfuck add checker ls clear +PROGS=foolshell simple brainfuck add checker ls clear ext2.img: $(PROGS) dd if=/dev/zero of=ext2.img bs=512 count=5000 @@ -12,17 +12,19 @@ ext2.img: $(PROGS) mkdir mnt sudo mount ext2.img mnt sudo chown miguel mnt - mkdir mnt/miguel - echo "hello one" > mnt/miguel/test1.txt - echo "hello two" > mnt/test2.txt - cp $^ mnt - cp ~/temp/fool-os-stuff/binutils-build-host-foolos/binutils/readelf mnt + mkdir -p mnt/home/miguel + echo "hello one" > mnt/home/miguel/test1.txt + mkdir -p mnt/bin + cp $^ mnt/bin + cp ~/temp/fool-os-stuff/binutils-build-host-foolos/binutils/readelf mnt/bin + mkdir -p mnt/etc + echo "127.0.0.1 localhost" > mnt/etc/hosts sync sudo umount mnt rm mnt -rf brainfuck: brainfuck.o -shell: shell.o +foolshell: foolshell.o simple: simple.o add: add.o checker: checker.o diff --git a/userspace/shell.c b/userspace/foolshell.c index bb8b873..819c5d6 100644 --- a/userspace/shell.c +++ b/userspace/foolshell.c @@ -3,28 +3,22 @@ #include <stdbool.h> #include <string.h> -// ascci art: http://patorjk.com/software/taag/#p=testall&f=Cards&t=Fool%20OS // void hello() { + // ascci art: http://patorjk.com/software/taag/#p=testall&f=Cards&t=Fool%20OS puts( - " ______ __ ____ _____\n" - " / ____/___ ____ / / / __ \\/ ___/\n" - " / /_ / __ \\/ __ \\/ / / / / /\\__ \\ \n" - " / __/ / /_/ / /_/ / / / /_/ /___/ / \n" - " /_/ \\____/\\____/_/ \\____//____/ \n" - "\n" - - - - - - + " ______ __ ____ _____ \n" + " / ____/___ ____ / / / __ \\/ ___/ \n" + " / /_ / __ \\/ __ \\/ / / / / /\\__ \\ \n" + " / __/ / /_/ / /_/ / / / /_/ /___/ / \n" + " /_/ \\____/\\____/_/ \\____//____/ \n" + " \n" "Welcome to FoolShell v0.2 (Compiled on " __DATE__ " at " __TIME__ "\n" "--------------------------------------------------------------------\n\n" "type 'help' anytime to show shell built-ins\n" - "or execute programms/commands that are on your $PATH (e.g. ls)\n" + "or execute user programms that are in the '/bin' directory (e.g. ls)\n" ); } @@ -112,12 +106,7 @@ int process(char *buf) if(!strcmp(command,"help")) { - puts("foolshell: supported built-in commands: 'help', 'echo [string]', exec [inode_nr],'malloc [bytes]', 'free [address]', 'getenv [var]', 'putenv [var] [val]'"); - } - else if(!strcmp(command,"exec")) - { - execve(atoi(token[1]),token,0); - + puts("foolshell: supported built-in commands: 'help', 'echo [string]', 'malloc [bytes]', 'free [address]', 'getenv [var]', 'putenv [var] [val]'"); } else if(!strcmp(command,"echo")) { @@ -147,6 +136,10 @@ int process(char *buf) } else { + execve(token[0],token,0); + char buf[256]; + sprintf(buf,"/bin/%s",token[0]); + execve(buf,token,0); puts("foolshell: command not found"); } diff --git a/userspace/ls.c b/userspace/ls.c index 50c733b..5b5034b 100644 --- a/userspace/ls.c +++ b/userspace/ls.c @@ -15,7 +15,13 @@ int main(int argc, char **argv) return 0; } - int ls=readdir(atoi(argv[1]),dirs,25); + char *dir=argv[1]; + int ls=readdir(dir,dirs,25); + if(ls==-1) + { + printf("%s: file or directory '%s' not found.\n",argv[0],dir); + return 0; + } int i; |
