From 21d14e8870ca1759c72a40788cafc17083b0392d Mon Sep 17 00:00:00 2001 From: Alex Stratford <alexander3.stratford@live.uwe.ac.uk> Date: Tue, 3 Dec 2019 22:58:51 +0000 Subject: [PATCH] Resolving issues in merge request system_calls.h line 38: Fixed return type for syscall_filesize syscall_filesize.c line 12..14: Rewrote to fix undefined function and to condense the code line 14: Added function to search for files in memory syscall.c line 77: Added file_search function skeleton syscall.h line 6: Added file_search declaration --- userprog/syscall.c | 6 ++++++ userprog/syscall.h | 2 ++ userprog/syscall_filesize.c | 11 ++++++----- userprog/system_calls.h | 2 +- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/userprog/syscall.c b/userprog/syscall.c index 55e9ffe..4d82e20 100644 --- a/userprog/syscall.c +++ b/userprog/syscall.c @@ -78,3 +78,9 @@ syscall_handler (struct intr_frame *f UNUSED) thread_exit(); } } + + +void file_search(struct file_map *f) { + // TODO: Write file search + f->file = NULL; +} \ No newline at end of file diff --git a/userprog/syscall.h b/userprog/syscall.h index 9059096..4adc298 100644 --- a/userprog/syscall.h +++ b/userprog/syscall.h @@ -3,4 +3,6 @@ void syscall_init (void); +void file_search(struct file_map *f); + #endif /* userprog/syscall.h */ diff --git a/userprog/syscall_filesize.c b/userprog/syscall_filesize.c index ebfbf76..8bdba55 100644 --- a/userprog/syscall_filesize.c +++ b/userprog/syscall_filesize.c @@ -8,13 +8,14 @@ #include "filesys/file.h" int syscall_filesize(struct intr_frame *f) { + struct file_map *f_map; // Described in system_calls.h // pop off first int argument from interrupt frame - int file_descriptor = *((int*)f->esp + 1); - // Described in system_calls.h, stores file descriptors mapped to files - struct file_map *file_map = get_file(file_descriptor); - if (file_map == NULL) // Checking if file is empty or non-existent + f_map->file_descriptor = *((int*)f->esp + 1); + file_search(); + if (f_map->file == NULL) { // Checking if file is empty or non-existent return -1; // Returning failure state + } // Using the file_length function in file.h to get the length and store it - int size = file_length(file_map->file); + int size = file_length(f_map->file); f->eax = size; } \ No newline at end of file diff --git a/userprog/system_calls.h b/userprog/system_calls.h index 21d6f9f..c063331 100644 --- a/userprog/system_calls.h +++ b/userprog/system_calls.h @@ -36,7 +36,7 @@ void syscall_wait(struct intr_frame *f); /* * Returns the size, in bytes, of the file open as fd. */ -int syscall_filesize(struct intr_frame *f) +void syscall_filesize(struct intr_frame *f) /* * NOTE: There are more system calls implemented by Pintos but we are not -- GitLab