diff options
| author | Michal Idziorek <m.i@gmx.at> | 2014-11-24 01:54:47 +0100 |
|---|---|---|
| committer | Michal Idziorek <m.i@gmx.at> | 2014-11-24 01:54:47 +0100 |
| commit | 369c62119b9dd60db77fc28e8857ed9c4d498889 (patch) | |
| tree | ea06cc9b95516863cc674bf700e27db601e0529b | |
| parent | 0d36b950f6a560a0312f2dcd326d3bb5362af370 (diff) | |
problems with ENV
| -rw-r--r-- | bochs/bochsrc | 2 | ||||
| -rw-r--r-- | kernel/syscalls.c | 12 | ||||
| -rw-r--r-- | userspace/foolshell.c | 5 | ||||
| -rw-r--r-- | userspace/simple.c | 15 | ||||
| -rw-r--r-- | userspace/sys/Makefile | 1 | ||||
| -rw-r--r-- | userspace/sys/syscalls.c | 5 |
6 files changed, 28 insertions, 12 deletions
diff --git a/bochs/bochsrc b/bochs/bochsrc index 3d5b316..e793779 100644 --- a/bochs/bochsrc +++ b/bochs/bochsrc @@ -56,7 +56,7 @@ #display_library: wx #display_library: x, options="hideIPS" # disable IPS output in status bar display_library: x, options="gui_debug" # use GTK debugger gui -#display_library: term +display_library: term #display_library: x # diff --git a/kernel/syscalls.c b/kernel/syscalls.c index 4023dfe..b5422c5 100644 --- a/kernel/syscalls.c +++ b/kernel/syscalls.c @@ -195,6 +195,7 @@ int syscall_execve(char *name, char **argv, char **env) char *env1="PS1=$ "; char *env2="PATH=/bin"; char environstr[256]; + char **oldenviron=env; char **environ=0xf00001; @@ -227,10 +228,6 @@ int syscall_execve(char *name, char **argv, char **env) } environ[i]=NULL; - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"duplicate env: %s (0x%08X)",environ[0],environ[0]); - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"duplicate env: %s (0x%08X)",environ[1],environ[1]); - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"duplicate env: %s (0x%08X)",environ[2],environ[2]); - } @@ -399,6 +396,13 @@ int syscall_exit(int ret, char **env, int none2) log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"exit (ret=%d) (env=0x%08X)", ret, env); #endif + int i=0; + while(env[i]!=NULL) + { + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"envvar %s (0x%08X)\n" ,env[i],env[i]); + i++; + } + static char *argv[]={"shell","--silent",NULL}; syscall_execve("/bin/foolshell",argv,env); // start shell } diff --git a/userspace/foolshell.c b/userspace/foolshell.c index 7a4f616..9002269 100644 --- a/userspace/foolshell.c +++ b/userspace/foolshell.c @@ -26,7 +26,6 @@ void hello() void prompt() { printf("%s",getenv("PS1")); - printf("%s",getenv("PS1")); } int main(int argc, char **argv) @@ -125,14 +124,14 @@ int process(char *buf) } else if(!strcmp(command,"getenv")) { - printf("%s = %s(0x%08X) \n",token[1],getenv(token[1]),getenv(token[1])); + printf("(0x%08X) put: %s = %s(0x%08X) \n",environ,token[1],getenv(token[1]),getenv(token[1])); } else if(!strcmp(command,"putenv")) { char buf[256]; sprintf(buf,"%s=%s",token[1],token[2]); putenv(buf); - printf("set: %s = %s \n",token[1],getenv(token[1])); + printf("(0x%08X) set: %s = %s \n",environ,token[1],getenv(token[1])); } else { diff --git a/userspace/simple.c b/userspace/simple.c index bd42d9c..e84b072 100644 --- a/userspace/simple.c +++ b/userspace/simple.c @@ -1,15 +1,14 @@ #include <stdlib.h> extern char **environ; + int main(int argc, char **argv) { printf("argv: 0x%08X\n",argv); - printf("env: 0x%08X\n",environ); - - putenv("test=11"); + printf("env: 0x%08X\n",environ); int i=0; while(environ[i]!=NULL) @@ -18,7 +17,15 @@ int main(int argc, char **argv) i++; } - puts("bye"); + putenv("supa=dupa"); + printf("env: 0x%08X\n",environ); + + i=0; + while(environ[i]!=NULL) + { + printf("envvar %s (0x%08X)\n" ,environ[i],environ[i]); + i++; + } return 0; } diff --git a/userspace/sys/Makefile b/userspace/sys/Makefile index 9917d90..e341312 100644 --- a/userspace/sys/Makefile +++ b/userspace/sys/Makefile @@ -4,6 +4,7 @@ CFLAGS+=-w OBJECTS=sys.o syscalls.o crt0.o +full: clean library_install crt_install all: $(OBJECTS) library_install: all diff --git a/userspace/sys/syscalls.c b/userspace/sys/syscalls.c index 9456ea4..fe34f47 100644 --- a/userspace/sys/syscalls.c +++ b/userspace/sys/syscalls.c @@ -2,6 +2,11 @@ char **environ; +void _exit(int ret) +{ + _exit2(ret,environ); +} + void _exit2(int ret,char **environ) { return syscall(SYSCALL_EXIT,ret,environ,0); |
