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:
2025-10-07 23:41:55 +03:00
parent 8c26f54d28
commit 88c1936e83
5 changed files with 11 additions and 14 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ int main() {
// The first argument is the path to the executable
// The second is the array of arguments
// The third is the array of environment variables
execve("callee.", argv, envp);
execve("/katau/callee.", argv, envp);
// This part of the code will only be reached if execve fails
perror("execve failed");
+1 -1
View File
@@ -19,7 +19,7 @@ size_t vfs_read_file_length(l9660_file *file, uint8_t* buffer, size_t length);
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);
void follow_path(const char* path, l9660_file* file, l9660_dir* dir);
#endif
+4 -7
View File
@@ -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
View File
@@ -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)
{
+1 -1
View File
@@ -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;