syscalls: add chdir and getcwd syscalls, not tested yet

This commit is contained in:
2025-07-16 15:42:35 +03:00
parent aac4375b8e
commit 359e5c6d78
2 changed files with 26 additions and 0 deletions
+25
View File
@@ -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;