syscalls: hopefully implement chdir syscall
This commit is contained in:
+1
-1
@@ -20,7 +20,7 @@ size_t vfs_read_file_length(l9660_file *file, uint8_t* buffer, size_t length);
|
|||||||
void test_iso9660();
|
void test_iso9660();
|
||||||
|
|
||||||
int vfs_read_file_by_path(const char* path, uint8_t** buffer);
|
int vfs_read_file_by_path(const char* path, uint8_t** buffer);
|
||||||
void follow_path(const char* path, l9660_file* file, l9660_dir* dir);
|
int follow_path(const char* path, l9660_file* file, l9660_dir* dir);
|
||||||
|
|
||||||
l9660_status find_name_for_sector(char* name_buf, int buf_len, l9660_dir* parent_dir, uint32_t child_sector);
|
l9660_status find_name_for_sector(char* name_buf, int buf_len, l9660_dir* parent_dir, uint32_t child_sector);
|
||||||
bool is_root_dir(l9660_dir* dir);
|
bool is_root_dir(l9660_dir* dir);
|
||||||
|
|||||||
+6
-4
@@ -220,7 +220,7 @@ int vfs_read_file_by_path(const char* path, uint8_t** buffer)
|
|||||||
return 0;
|
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 pos = 0;
|
||||||
int start_from_root = 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)
|
if(status != L9660_OK)
|
||||||
{
|
{
|
||||||
debug_log("FUCKFUCKFUCKFUCK BLYAAAT!!!!!\n");
|
debug_log("FUCKFUCKFUCKFUCK BLYAAAT!!!!!\n");
|
||||||
return;
|
return status;
|
||||||
}
|
}
|
||||||
*dir = dir2;
|
*dir = dir2;
|
||||||
}
|
}
|
||||||
@@ -275,15 +275,17 @@ void follow_path(const char* path, l9660_file* file, l9660_dir* dir)
|
|||||||
if(status != L9660_OK)
|
if(status != L9660_OK)
|
||||||
{
|
{
|
||||||
debug_log("PIZDAPIZDA BLYAAAT!!!!!\n");
|
debug_log("PIZDAPIZDA BLYAAAT!!!!!\n");
|
||||||
return;
|
return status;
|
||||||
}
|
}
|
||||||
return;
|
return status;
|
||||||
}
|
}
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
debug_log("\n");
|
debug_log("\n");
|
||||||
//printf("buf: %s\n", buf);
|
//printf("buf: %s\n", buf);
|
||||||
debug_log("isdir: %X\n", isdir);
|
debug_log("isdir: %X\n", isdir);
|
||||||
|
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef L9660_BIG_ENDIAN
|
#ifdef L9660_BIG_ENDIAN
|
||||||
|
|||||||
+30
-1
@@ -406,6 +406,35 @@ int sys_execve(TrapFrame *tf) {
|
|||||||
|
|
||||||
int sys_chdir(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, "/");
|
||||||
//strcat(current->cwd->fat->path, (char*)tf->ebx);
|
//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);
|
debug_log("mapping page %X to %X\n", phys_addr, virt_addr);
|
||||||
memset(virt_addr, 0, 0x1000);
|
memset(virt_addr, 0, 0x1000);
|
||||||
current->brk = (void*)tf->ebx;
|
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;
|
return (uint32_t)current->brk;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user