From 2d91384197847a7e8fe2c3f548918a8277d3086d Mon Sep 17 00:00:00 2001 From: Miguel Date: Tue, 18 Sep 2018 03:03:28 +0200 Subject: sysfs, errno, improve foolshell, etc --- userspace/Makefile | 7 +- userspace/foolshell.c | 279 ++++++++++++++++++++++++-------------------------- userspace/init.c | 2 +- 3 files changed, 138 insertions(+), 150 deletions(-) (limited to 'userspace') diff --git a/userspace/Makefile b/userspace/Makefile index dbc2d0f..d39f15f 100644 --- a/userspace/Makefile +++ b/userspace/Makefile @@ -2,6 +2,8 @@ IMAGESIZE=10000 #ext2.img size in Kb ####################### +GIT_REVISION=$(shell git rev-parse HEAD) + CC=i686-foolos-gcc CC=i686-elf-gcc AS=i686-elf-as @@ -9,11 +11,13 @@ CC = @echo "Compiling (i686-elf-gcc) $<..."; i686-elf-gcc AS = @echo "Assembling (i686-elf-as) $<..."; i686-elf-as CFLAGS= -CFLAGS=-w +CFLAGS+=-DGIT_REVISION=\"$(GIT_REVISION)\" +CFLAGS+=-w CFLAGS+=-I.. CFLAGS+=-I/home/miguel/temp/foolos/usr/i686-foolos/include CFLAGS+=-O0 CFLAGS+=-g +CFLAGS+= -Werror=implicit-function-declaration LDFLAGS=-L/home/miguel/temp/foolos/usr/i686-foolos/lib/ LDLIBS=-lc -lm -lg -lnosys @@ -40,6 +44,7 @@ ext2.img: $(PROGS) @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 + @mkdir -p mnt/sys # mountpoint for sysfs @cp test.txt mnt/doc/test/ @cp $(PROGS) mnt/bin @cp fonts/binfont.bin mnt/ diff --git a/userspace/foolshell.c b/userspace/foolshell.c index 0012592..e8b384e 100644 --- a/userspace/foolshell.c +++ b/userspace/foolshell.c @@ -1,47 +1,45 @@ +/** + * @file + * + * Fool's Shell + * ========= + * + * A minimalsitic and naive shell developed along the Fool OS kernel. + * TODO: Free tokenizer / dynamic size! + */ + #include #include #include #include - -#include +#include +#include extern char **environ; -extern struct _reent *_impure_ptr; -uint8_t buf_test[1024*300]; +bool process(char *buf); +bool cd(char *path); -// -void hello() +void version() +{ + puts("Fool's Shell version git-commit:" GIT_REVISION "\ncompiled on " __DATE__ " at " __TIME__); +} +void help() { - // ascci art: http://patorjk.com/software/taag/#p=testall&f=Cards&t=Fool%20OS - puts( - - "\033c" -// "\033[36m" - -// " ______ __ ____ _____ \n" -// " / ____/___ ____ / / / __ \\/ ___/ \n" -// " / /_ / __ \\/ __ \\/ / / / / /\\__ \\ \n" -// " / __/ / /_/ / /_/ / / / /_/ /___/ / \n" -// " /_/ \\____/\\____/_/ \\____//____/ \n" -// " \n" - -// "\033[37;44m" -// " \n" - - " Welcome to FoolShell v0.12 (Compiled on " __DATE__ " at " __TIME__")\n" - " ------------------------------------------------------------------\n\n" - " Please type 'help' anytime, to show shell \"built-ins\". You can execute \n" - " user programms that are in your $PATH directory by simply typing \n" - " their filenames. Get additional information for many, of the available\n" - " commands by invoking them with --help or -h. (e.g. ls --help) \n" - " \n" - - "\033[37;40m" - ); - - printf(" Your $PATH is currently set to: %s\n",getenv("PATH")); - printf(" Type 'ls %s' to list programms on your $PATH.\n\n",getenv("PATH")); + puts( "\nfoolshell: supported built-in commands/functions:\n\n" + + "'env' - show all environment variables\n" + "'getenv [var]' - show environment variable\n" + "'setenv [var] [val]' - set environemnet variable\n" + + "'cd [dir]' - change directory (set $PWD)\n" + "'[binary] [params...]' - run a binary\n" + "'[binary] [params...] &' - run a binary in background\n" + " TODO - pipes\n" + + "'help' - show this message\n" + "'exit' - exit running foolshell\n\n"); + } void prompt() @@ -49,23 +47,32 @@ void prompt() printf("\033[36mfool\033[37m@\033[32mhill\033[33m:%s%s\033[37m",getenv("PWD"),getenv("PS1")); } - int main(int argc, char **argv) { - bool silent=false; for(int i=0;i %s\n",p[pp]); + pp++; + } + t++; + } + + if(pp==0) + { + strcat(buf,"/"); + } + + for(int i=0;i