diff --git a/userprog/syscall_open.c b/userprog/syscall_open.c index 386fa269c9cdc95f7b4a27ac02c1d916c79c9afa..992856b6032918ad6960b1e894de7b021da6ff68 100644 --- a/userprog/syscall_open.c +++ b/userprog/syscall_open.c @@ -13,10 +13,11 @@ void syscall_open(struct intr_frame *f) { struct file_map *f_map; // Create f_map struct instance // 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 - 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 f->eax = -1; // Returning a failure state + f_map->file_descriptor = f_map->file; f->eax = f_map->file_descriptor; // Returning the file descriptor } \ No newline at end of file