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:
+1
-1
@@ -18,7 +18,7 @@ int main() {
|
|||||||
// The first argument is the path to the executable
|
// The first argument is the path to the executable
|
||||||
// The second is the array of arguments
|
// The second is the array of arguments
|
||||||
// The third is the array of environment variables
|
// 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
|
// This part of the code will only be reached if execve fails
|
||||||
perror("execve failed");
|
perror("execve failed");
|
||||||
|
|||||||
+1
-1
@@ -19,7 +19,7 @@ size_t vfs_read_file_length(l9660_file *file, uint8_t* buffer, size_t length);
|
|||||||
|
|
||||||
void test_iso9660();
|
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);
|
void follow_path(const char* path, l9660_file* file, l9660_dir* dir);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
+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_file* file = (l9660_file*)malloc(sizeof(l9660_file));
|
||||||
|
l9660_dir* dir = (l9660_dir*)malloc(sizeof(l9660_dir));
|
||||||
|
|
||||||
l9660_status err;
|
l9660_status err;
|
||||||
|
|
||||||
err = l9660_openat(file, dir, path);
|
follow_path(path, file, dir);
|
||||||
if (err != L9660_OK)
|
|
||||||
{
|
|
||||||
debug_log("read_file: err: 0x%X\n", err);
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
debug_log("HEHE %s\n", path);
|
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);
|
read = vfs_read_file(file, *buffer);
|
||||||
free(file);
|
free(file);
|
||||||
|
free(dir);
|
||||||
debug_log("bytes read: 0x%X\n", read);
|
debug_log("bytes read: 0x%X\n", read);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
+4
-4
@@ -131,12 +131,12 @@ void kmain(unsigned int magic, unsigned int info)
|
|||||||
|
|
||||||
mount_fs();
|
mount_fs();
|
||||||
|
|
||||||
l9660_dir* dir = (l9660_dir*)malloc(sizeof(l9660_dir));
|
l9660_dir dir;
|
||||||
l9660_file* file = (l9660_file*)malloc(sizeof(l9660_file));
|
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)
|
while(1)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -292,7 +292,7 @@ int sys_execve(TrapFrame *tf) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint8_t* file_buffer;
|
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) {
|
if (err != 0) {
|
||||||
debug_log("execve: failed to read file '%s'\n", filename);
|
debug_log("execve: failed to read file '%s'\n", filename);
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
Reference in New Issue
Block a user