summaryrefslogtreecommitdiff
path: root/kernel/syscalls.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/syscalls.c')
-rw-r--r--kernel/syscalls.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/kernel/syscalls.c b/kernel/syscalls.c
index 23c88a7..9fc1a7f 100644
--- a/kernel/syscalls.c
+++ b/kernel/syscalls.c
@@ -307,11 +307,8 @@ int syscall_select(int maxxfd,struct timeval *tv, fd_set **fd_sets, uint32_t pid
if(!test)FD_ZERO(fd_sets[2]); // we dont give a shit about exceptions! :P TODO!!!
-
return ret;
-
-
}
//TODO: use fd and inode (instead of path)... now this is a crazy trick how it works..
@@ -331,7 +328,7 @@ struct dirent *syscall_opendir(const char *name,struct dirent *dirs,int none,uin
if(ret==-1)
{
// no it does not!
- set_errno(ENOENT);
+ set_errno(ENOENT);
return NULL;
}
@@ -392,29 +389,33 @@ int copy_args(char **in, char **out)
int syscall_execve(const char *name, char *const argv[], char *const env[], int pid)
{
uint32_t alloc;
- uint32_t entry_global=load_elf(name,&alloc);
-
- fixme("not overwrite yourself?");
+ char **argv1= VMEM_USER_ENV;
+ char **env1 = VMEM_USER_ENV+1024*2;
int arg_count=0;
- while(argv[arg_count]!=NULL)arg_count++;
+ //*argv1=NULL;
+ //*env1=NULL;
- char **argv1=VMEM_USER_ENV;
+ // TODO!
+ fixme("not overwrite yourself badly here!?");
+ while(argv[arg_count]!=NULL)arg_count++;
if(argv!=NULL)copy_args(argv,argv1);
- else argv1=NULL;
-
- char **env1=VMEM_USER_ENV+1024*2;
if(env!=NULL)copy_args(env,env1);
- else env1=NULL;
- if(!entry_global){
- set_errno(ENOENT);
- return -1;
+ uint32_t entry_global=load_elf(name,&alloc); // overwrites ourselves (in userspace)
+
+ if(!entry_global)
+ {
+ kpanic("no entry point!"); // TODO: rem
+ set_errno(ENOENT);
+ return -1;
}
- uint32_t *stack=VMEM_USER_STACK_TOP-4*32;
+ // here we might overwrite our CURRENT stack!!! oh fuck TODO: check it!
+ uint32_t *stack=VMEM_USER_STACK_TOP-4*32;
*--stack=argv1;
*--stack=arg_count;
*--stack=env1;
+
task_set_name(pid,name);
task_reset(pid,entry_global,stack,alloc);
@@ -444,10 +445,11 @@ uint32_t syscall_fork(int none1, int none2, int none3, int pid)
fds[newpid][i]=fd_dupl(&fds[pid][i]);
open_fd[newpid][i]=true;
}
+
tty[newpid]=tty[pid];
invl[newpid]=invl[pid];
-// fds[newpid][0]=fd_from_ringbuffer(); // TODO fix
-// open_fd[newpid][0]=true;
+// fds[newpid][0]=fd_from_ringbuffer(); // TODO fix
+// open_fd[newpid][0]=true;
return newpid;
}
@@ -747,9 +749,7 @@ uint32_t syscall_generic(uint32_t nr,uint32_t p1, uint32_t p2, uint32_t p3, uint
if(!strcmp(p1,"fcntl")){
klog("todo: quickfix hack for fcntl");
}
-
}
klog("unknown syscall %s / %d we just return 0",p1,nr);
return 0;
}
-