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

Added new file map system to syscall_open

parent 83f222db
No related branches found
No related tags found
2 merge requests!22Merge Feature/system calls,!15Alex/27 implement open system call
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment