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

Modified syscall_open

syscall_open.c
line 14: Commented out current code
line 18: Changed to create new file struct
line 19: Changed to use file struct and brace guard statement
line 21: Added return to exit early
line 22: Closing brace for guard statement
line 23: Commented out old code
line 24: Returning pointer to file struct
parent ca0bafc6
No related branches found
No related tags found
2 merge requests!22Merge Feature/system calls,!15Alex/27 implement open system call
......@@ -11,13 +11,15 @@
#include "filesys/file.h" // Dependency for file_open and file struct
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
char* file_name = (void*)(*(int*)f->esp + 1);
// Described in system_calls.h, opens the file
f_map->file = file_open(file_name);
if (f_map->file == NULL) // Checking if file is empty or non-existent
struct file *file = file_open(file_name);
if (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
return;
}
//f_map.file_descriptor = f_map.file;
f->eax = file;//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