diff --git a/userprog/syscall_open.c b/userprog/syscall_open.c index 783c561f5c0529c95ae606a3a5e8371a5306b4d2..33345c56ebf5fcafdef965d7ec0e07b7e394de89 100644 --- a/userprog/syscall_open.c +++ b/userprog/syscall_open.c @@ -8,18 +8,19 @@ #include "system_calls.h" #include "threads/interrupt.h" // Dependency for intr_frame struct -#include "filesys/file.h" // Dependency for file_open and file struct +#include "filesys/file.h" // Dependency for and file struct +#include "filesys/filesys.h" // Dependency for filesys_open 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 char* file_name = (void*)(*(int*)f->esp + 1); - // Described in system_calls.h, opens the file - struct file *file = file_open(file_name); + // Described in filesys.h, opens the file + struct file *file = filesys_open(file_name); if (file == NULL) { // Checking if file is empty or non-existent f->eax = -1; // Returning a failure state return; } - //f_map.file_descriptor = f_map.file; - f->eax = file;//f_map.file_descriptor; // Returning the file descriptor + // Described in system_calls.h, get a new file descriptor + int file_descriptor = associate_new_file_descriptor(file); + f->eax = file_descriptor; // Returning the file descriptor } \ No newline at end of file