syscalls: hopefully implement chdir syscall
This commit is contained in:
+6
-4
@@ -220,7 +220,7 @@ int vfs_read_file_by_path(const char* path, uint8_t** buffer)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void follow_path(const char* path, l9660_file* file, l9660_dir* dir)
|
||||
int follow_path(const char* path, l9660_file* file, l9660_dir* dir)
|
||||
{
|
||||
int pos = 0;
|
||||
int start_from_root = 0;
|
||||
@@ -263,7 +263,7 @@ void follow_path(const char* path, l9660_file* file, l9660_dir* dir)
|
||||
if(status != L9660_OK)
|
||||
{
|
||||
debug_log("FUCKFUCKFUCKFUCK BLYAAAT!!!!!\n");
|
||||
return;
|
||||
return status;
|
||||
}
|
||||
*dir = dir2;
|
||||
}
|
||||
@@ -275,15 +275,17 @@ void follow_path(const char* path, l9660_file* file, l9660_dir* dir)
|
||||
if(status != L9660_OK)
|
||||
{
|
||||
debug_log("PIZDAPIZDA BLYAAAT!!!!!\n");
|
||||
return;
|
||||
return status;
|
||||
}
|
||||
return;
|
||||
return status;
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
debug_log("\n");
|
||||
//printf("buf: %s\n", buf);
|
||||
debug_log("isdir: %X\n", isdir);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
#ifdef L9660_BIG_ENDIAN
|
||||
|
||||
+30
-1
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user