diff --git a/kernel/tests.c b/kernel/tests.c index 1a9b6cb7..333885b6 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -119,7 +119,7 @@ static int STDCALL join_test(void* arg) int test_init(void) { - char* argv[] = {"/bin/tests", NULL}; + char* argv[] = {"/bin/mshell", NULL}; //sem_init(&producing, 1); //sem_init(&consuming, 0); @@ -131,7 +131,7 @@ int test_init(void) //create_kernel_task(NULL, consumer, NULL); //create_kernel_task(NULL, ping, NULL); //create_user_task(NULL, "/bin/hello", argv); - create_user_task(NULL, "/bin/tests", argv); + create_user_task(NULL, "/bin/mshell", argv); //create_user_task(NULL, "/bin/jacobi", argv); return 0; diff --git a/newlib/examples/Makefile b/newlib/examples/Makefile index f63906cb..e184cbf0 100644 --- a/newlib/examples/Makefile +++ b/newlib/examples/Makefile @@ -11,7 +11,7 @@ LDFLAGS = default: all -all: hello tests jacobi hangman +all: hello tests jacobi hangman mshell jacobi: jacobi.o $(CC_FOR_TARGET) -T link.ld -o $@ $(LDFLAGS) $< -lm @@ -37,9 +37,14 @@ hangman: hangman.o $(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $@ chmod a-x $@.sym +mshell: mshell.o + $(CC_FOR_TARGET) -T link.ld -o $@ $(LDFLAGS) $< + $(OBJCOPY_FOR_TARGET) $(KEEP_DEBUG) $@ $@.sym + $(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $@ + chmod a-x $@.sym clean: - $(RM) hello tests *.sym *.o *~ + $(RM) hello hangman jacobi mshell tests *.sym *.o *~ depend: $(CC_FOR_TARGET) -MM $(CFLAGS) *.c > Makefile.dep diff --git a/newlib/examples/hello.c b/newlib/examples/hello.c index fd357d5f..f65ce176 100644 --- a/newlib/examples/hello.c +++ b/newlib/examples/hello.c @@ -27,10 +27,6 @@ extern int errno; int main(int argc, char** argv) { - int i; - char* str = (char *)malloc(40000 * sizeof(char)); - scanf("%s", str); - printf("SCANF: %s", str); - fflush(NULL); + printf("test!"); return errno; } diff --git a/newlib/examples/mshell b/newlib/examples/mshell new file mode 100755 index 00000000..84ece8f5 Binary files /dev/null and b/newlib/examples/mshell differ diff --git a/newlib/examples/mshell.c b/newlib/examples/mshell.c new file mode 100644 index 00000000..af4ee6fe --- /dev/null +++ b/newlib/examples/mshell.c @@ -0,0 +1,53 @@ +#include +#include +#include +#include +#include +#include +#include + +void showlogo() { + printf("\n\n"); + printf("================================================================================\n"); + printf(" m(etalsvm)shell\n\n"); + printf(" Copyright 2010 Stefan Lankes, Chair for Operating Systems,\n"); + printf(" RWTH Aachen University\n\n"); + printf("================================================================================\n"); +} + +void help() { + printf("possible commands: \n"); + printf("exit > exit shell \n"); +} + +int main(int argc, char** argv) +{ + char* command = malloc(1024*sizeof(char)); + int size, status = 0; + pid_t pid; + system("clear"); + showlogo(); + while(1) { + printf("$ "); + size = scanf("%s", command); + if(!strcmp(command, "exit")) { + return 0; + } + if(!strcmp(command, "help")) { + help(); + } else { + pid = fork(); + if (pid == 0) { //child + char* newargv[] = {command, NULL}; + char* newenv[] = {"USER=root", "PATH=/bin:/sbin:/usr/bin", "PWD=/", "TEMP=/tmp", NULL}; + + execve(command, newargv, newenv); + return errno; + } else { + wait(&status); + } + } + } + return errno; +} +