From 81e76e3699f99102d2f37023a42156522ccb1159 Mon Sep 17 00:00:00 2001 From: Alex Stratford <alexander3.stratford@live.uwe.ac.uk> Date: Tue, 3 Dec 2019 18:38:19 +0000 Subject: [PATCH] Removed syscall_exit.c and fixed merge request issues --- userprog/syscall.c | 7 ++----- userprog/syscall_filesize.c | 15 +++++++++++---- userprog/system_calls.h | 11 ++--------- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/userprog/syscall.c b/userprog/syscall.c index 3c01e63..55e9ffe 100644 --- a/userprog/syscall.c +++ b/userprog/syscall.c @@ -58,9 +58,6 @@ syscall_handler (struct intr_frame *f UNUSED) case SYSCALL_HALT: syscall_halt(f); break; - case SYSCALL_EXIT: - syscall_exit(f); - break; case SYSCALL_EXEC: syscall_exec(f); break; @@ -78,6 +75,6 @@ syscall_handler (struct intr_frame *f UNUSED) break; default: printf ("WARNING: Invalid Syscall (%d)\n", syscall_number); - thread_exit (); - } + thread_exit(); + } } diff --git a/userprog/syscall_filesize.c b/userprog/syscall_filesize.c index cdf87d0..ebfbf76 100644 --- a/userprog/syscall_filesize.c +++ b/userprog/syscall_filesize.c @@ -1,13 +1,20 @@ +/* + * Returns the size, in bytes, of the file open as fd. + * + * Authored by Alex Stratford + */ + #include "system_calls.h" #include "filesys/file.h" -int syscall_filesize(struct intr_frame *file_descriptor) { +int syscall_filesize(struct intr_frame *f) { + // 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); - int size; if (file_map == 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 - size = file_length(file_map->file); - return size; + int size = file_length(file_map->file); + f->eax = size; } \ No newline at end of file diff --git a/userprog/system_calls.h b/userprog/system_calls.h index ab1d03a..21d6f9f 100644 --- a/userprog/system_calls.h +++ b/userprog/system_calls.h @@ -18,14 +18,6 @@ struct file_map */ void syscall_halt(struct intr_frame *f); -/* - * Terminates the current user program, returning status to the kernel. If the - * process's parent waits for it (see below), this is the status that will be - * returned. Conventionally, a status of 0 indicates success and nonzero - * values indicate errors. - */ -void syscall_exit(struct intr_frame *f); - /* * Runs the executable whose name is given in cmd_line, passing any given * arguments, and returns the new process's program id (pid). Must return pid @@ -44,7 +36,8 @@ void syscall_wait(struct intr_frame *f); /* * Returns the size, in bytes, of the file open as fd. */ -int syscall_filesize(struct intr_frame *file_descriptor) +int syscall_filesize(struct intr_frame *f) + /* * NOTE: There are more system calls implemented by Pintos but we are not * implementing them because the assignment brief does not ask of it. -- GitLab