syscalls: add chdir and getcwd syscalls, not tested yet
This commit is contained in:
@@ -230,6 +230,22 @@ int sys_close(TrapFrame *tf)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int sys_chdir(TrapFrame *tf)
|
||||
{
|
||||
return fat_opendir(current->cwd, (const char*)tf->ebx);
|
||||
}
|
||||
|
||||
int sys_getcwd(TrapFrame *tf)
|
||||
{
|
||||
int len = tf->ecx;
|
||||
|
||||
if(len >= 260)
|
||||
return (int)NULL;
|
||||
|
||||
memcpy((void*)tf->ebx, current->cwd->fat->name, current->cwd->fat->namelen);
|
||||
return tf->ebx;
|
||||
}
|
||||
|
||||
int sys_getpid(TrapFrame *tf)
|
||||
{
|
||||
return current->pid;
|
||||
@@ -268,9 +284,18 @@ void handle_syscall(TrapFrame *tf)
|
||||
tf->eax = sys_close(tf);
|
||||
break;
|
||||
|
||||
case 12://chdir
|
||||
tf->eax = sys_chdir(tf);
|
||||
break;
|
||||
|
||||
case 20://getpid
|
||||
tf->eax = sys_getpid(tf);
|
||||
break;
|
||||
|
||||
case 183://getcwd
|
||||
tf->eax = sys_getcwd(tf);
|
||||
break;
|
||||
|
||||
default:
|
||||
debug_log("unknown syscall: %X\n", tf->eax);
|
||||
tf->eax = -1;
|
||||
|
||||
Reference in New Issue
Block a user