Skip to content
Snippets Groups Projects
Commit ca0bafc6 authored by a2-stratford's avatar a2-stratford
Browse files

Bugfixes

syscall_open.c
line 16: Added file_name to store input
line 18: Changed to use file_name
line 21: Added to put a pointer to the file inside file_descriptor
parent ec0c4f29
No related branches found
No related tags found
2 merge requests!22Merge Feature/system calls,!15Alex/27 implement open system call
...@@ -13,10 +13,11 @@ ...@@ -13,10 +13,11 @@
void syscall_open(struct intr_frame *f) { void syscall_open(struct intr_frame *f) {
struct file_map *f_map; // Create f_map struct instance struct file_map *f_map; // Create f_map struct instance
// pop off first int argument from interrupt frame // pop off first int argument from interrupt frame
f_map->file_descriptor = *((int*)f->esp + 1); char* file_name = (void*)(*(int*)f->esp + 1);
// Described in system_calls.h, opens the file // Described in system_calls.h, opens the file
f_map->file = file_open(f_map->file_descriptor); f_map->file = file_open(file_name);
if (f_map->file == NULL) // Checking if file is empty or non-existent if (f_map->file == NULL) // Checking if file is empty or non-existent
f->eax = -1; // Returning a failure state f->eax = -1; // Returning a failure state
f_map->file_descriptor = f_map->file;
f->eax = f_map->file_descriptor; // Returning the file descriptor f->eax = f_map->file_descriptor; // Returning the file descriptor
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment