From ca0bafc68950bc8421c4aa8c8f0cebc530eec944 Mon Sep 17 00:00:00 2001
From: Alex Stratford <alexander3.stratford@live.uwe.ac.uk>
Date: Wed, 4 Dec 2019 10:01:41 +0000
Subject: [PATCH] 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

---
 userprog/syscall_open.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/userprog/syscall_open.c b/userprog/syscall_open.c
index 386fa26..992856b 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
-- 
GitLab