syscalls: make execve and vfs_read_file_by_path use follow_path, fix vfs_read_file_by_path name, fix execve-related pagefault
This commit is contained in:
+4
-7
@@ -191,18 +191,14 @@ void test_iso9660()
|
||||
}
|
||||
}
|
||||
|
||||
int vsf_read_file_by_path(const char* path, uint8_t** buffer, l9660_dir* dir)
|
||||
int vfs_read_file_by_path(const char* path, uint8_t** buffer)
|
||||
{
|
||||
l9660_file* file = (l9660_file*)malloc(sizeof(l9660_file));
|
||||
l9660_dir* dir = (l9660_dir*)malloc(sizeof(l9660_dir));
|
||||
|
||||
l9660_status err;
|
||||
|
||||
err = l9660_openat(file, dir, path);
|
||||
if (err != L9660_OK)
|
||||
{
|
||||
debug_log("read_file: err: 0x%X\n", err);
|
||||
return err;
|
||||
}
|
||||
follow_path(path, file, dir);
|
||||
|
||||
debug_log("HEHE %s\n", path);
|
||||
|
||||
@@ -218,6 +214,7 @@ int vsf_read_file_by_path(const char* path, uint8_t** buffer, l9660_dir* dir)
|
||||
|
||||
read = vfs_read_file(file, *buffer);
|
||||
free(file);
|
||||
free(dir);
|
||||
debug_log("bytes read: 0x%X\n", read);
|
||||
|
||||
return 0;
|
||||
|
||||
+4
-4
@@ -131,12 +131,12 @@ void kmain(unsigned int magic, unsigned int info)
|
||||
|
||||
mount_fs();
|
||||
|
||||
l9660_dir* dir = (l9660_dir*)malloc(sizeof(l9660_dir));
|
||||
l9660_file* file = (l9660_file*)malloc(sizeof(l9660_file));
|
||||
l9660_dir dir;
|
||||
l9660_file file;
|
||||
|
||||
follow_path("/katau/core.", file, dir);
|
||||
follow_path("/katau/caller.", &file, &dir);
|
||||
|
||||
exec_from_file(file, ".");
|
||||
exec_from_file(&file, ".");
|
||||
|
||||
while(1)
|
||||
{
|
||||
|
||||
@@ -292,7 +292,7 @@ int sys_execve(TrapFrame *tf) {
|
||||
}
|
||||
|
||||
uint8_t* file_buffer;
|
||||
int err = vsf_read_file_by_path(filename, &file_buffer, root_dir);
|
||||
int err = vfs_read_file_by_path(filename, &file_buffer);
|
||||
if (err != 0) {
|
||||
debug_log("execve: failed to read file '%s'\n", filename);
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user