summaryrefslogtreecommitdiff
path: root/userspace
diff options
context:
space:
mode:
authorMichal Idziorek <m.i@gmx.at>2014-11-23 14:00:52 +0100
committerMichal Idziorek <m.i@gmx.at>2014-11-23 14:00:52 +0100
commit6a3ef39feb635f529da9e36975ba77a26c1ff3b4 (patch)
tree4a65630f27d0779a5bc3cce1927b13465d10b466 /userspace
parent608e66827d8aee1e55424c667777fac017501def (diff)
passing argv and argc to main, and fixed ELF load.
Diffstat (limited to 'userspace')
-rw-r--r--userspace/shell.c13
-rw-r--r--userspace/simple.c3
2 files changed, 9 insertions, 7 deletions
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 <stdio.h>
#include <stdint.h>
-#include <assert.h>
#include <string.h>
+
#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<argc;i++)
{
- printf("param %i: %08X: %s\n",i,argv[i],argv[i]);
+ if(!strcmp(argv[i],"-v"))puts("version 1");
}
puts("bye");