syscalls: hopefully implement chdir syscall

This commit is contained in:
2025-10-30 22:29:06 +03:00
parent f4b0429062
commit 561de6a4e3
3 changed files with 37 additions and 6 deletions
+30 -1
View File
@@ -406,6 +406,35 @@ int sys_execve(TrapFrame *tf) {
int sys_chdir(TrapFrame *tf)
{
l9660_dir new_cwd;
l9660_file placeholder_file;
int status = follow_path((char*)tf->ebx, &placeholder_file, &new_cwd);
if(status == L9660_OK)
{
*(current->cwd) = new_cwd;
}
switch(status)
{
case L9660_EIO:
return -5;//-EIO
break;
case L9660_EBADFS:
return -5;//EIO as well
break;
case L9660_ENOENT:
return -2;
break;
case L9660_ENOTDIR:
return -20;//ENOTDIR
break;
default:
return -5;//EIO
break;
}
//strcat(current->cwd->fat->path, "/");
//strcat(current->cwd->fat->path, (char*)tf->ebx);
@@ -503,7 +532,7 @@ uint32_t sys_brk(TrapFrame *tf)
debug_log("mapping page %X to %X\n", phys_addr, virt_addr);
memset(virt_addr, 0, 0x1000);
current->brk = (void*)tf->ebx;
debug_log("new brk is %X\n", (uint32_t)current->brk);
//debug_log("new brk is %X\n", (uint32_t)current->brk);
}
return (uint32_t)current->brk;
}