From eb3d8de87398ef681909598702491b7bb35ae801 Mon Sep 17 00:00:00 2001
From: Alex Stratford <alexander3.stratford@live.uwe.ac.uk>
Date: Wed, 4 Dec 2019 00:34:58 +0000
Subject: [PATCH] Finished the file_search function line 80..90: Added the
 file_search function

---
 userprog/syscall.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/userprog/syscall.c b/userprog/syscall.c
index 3a6db12..b2a467f 100644
--- a/userprog/syscall.c
+++ b/userprog/syscall.c
@@ -88,15 +88,15 @@ syscall_handler (struct intr_frame *f UNUSED)
 
 static struct list *file_list;
 
+// Goes through all the files in the file_list and looks for the 
 void file_search(struct file_map *f) {
-	// TODO: Write file search
 	struct file_map *curr_file;
-	*curr_file->list_element = list_begin(file_list);
-	while (
-		(curr_file->file_descriptor != f->file_descriptor) && 
-		(*curr_file->list_element != file_list->tail)
+	struct list_elem *list_element;
+	*list_element = *list_begin(file_list);
+	while ((curr_file->file_descriptor != f->file_descriptor) &&
+		(is_tail(curr_file->list_element) == false)
 		) {
-		list_next(*curr_file->list_element);
+		*list_element = curr_file->list_element;
+		list_next(list_element);
 	}
-	f->file = NULL;
 }
\ No newline at end of file
-- 
GitLab