From 6a3ef39feb635f529da9e36975ba77a26c1ff3b4 Mon Sep 17 00:00:00 2001 From: Michal Idziorek Date: Sun, 23 Nov 2014 14:00:52 +0100 Subject: passing argv and argc to main, and fixed ELF load. --- userspace/shell.c | 13 +++++++------ userspace/simple.c | 3 ++- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'userspace') diff --git a/userspace/shell.c b/userspace/shell.c index ae39c1a..06a03d2 100644 --- a/userspace/shell.c +++ b/userspace/shell.c @@ -1,7 +1,7 @@ #include #include -#include #include + #include "../fs/fs.h" void hello() { @@ -18,16 +18,15 @@ void prompt() { int main(int argc, char **argv) { -// hello(); - FILE *input; - input=fopen("input.txt","r"); +// hello(); + char *buf=malloc(256); while(1) { prompt(); - fgets(buf,255,input); + fgets(buf,255,stdin); buf[strlen(buf)-1]=0; // remove \n process(buf); } @@ -65,10 +64,12 @@ char **tokenize(char *buf) i++; } token[c][t]=0; + // printf("token %i : <%s>\n",c, token[c]); c++; + token[c]=NULL; } @@ -103,7 +104,7 @@ int process(char *buf) } else if(!strcmp(command,"exec")) { - execve(atoi(token[1]),0,0); + execve(atoi(token[1]),token,0); } else if(!strcmp(command,"echo")) diff --git a/userspace/simple.c b/userspace/simple.c index d4c48c2..5322584 100644 --- a/userspace/simple.c +++ b/userspace/simple.c @@ -1,12 +1,13 @@ int main(int argc, char **argv) { + int i; printf("argv: 0x%08X\n",argv); for(i=0;i