Skip to content
Snippets Groups Projects
Commit a952dffb authored by ja3-saxby's avatar ja3-saxby
Browse files

Merge branch 'Alex/19-implement-remove-system-call' into 'feature/system-calls'

Implementing the remove syscall

See merge request !17
parents 8793cd7e 65c1d052
No related branches found
No related tags found
2 merge requests!22Merge Feature/system calls,!17Implementing the remove syscall
......@@ -68,6 +68,7 @@ userprog_SRC += userprog/syscall_open.c
userprog_SRC += userprog/syscall_halt.c
userprog_SRC += userprog/syscall_wait.c
userprog_SRC += userprog/syscall_create.c
userprog_SRC += userprog/syscall_remove.c
userprog_SRC += userprog/syscall_write.c
userprog_SRC += userprog/file_descriptors_map.c
......
......@@ -69,7 +69,10 @@ syscall_handler (struct intr_frame *f UNUSED)
break;
case SYSCALL_CREATE:
syscall_create(f);
break;
break;
case SYSCALL_REMOVE:
syscall_remove(f);
break;
case SYSCALL_WRITE:
syscall_write(f);
break;
......
/*
* Deletes the file called file. Returns true if successful, false otherwise.
* A file may be removed regardless of whether it is open or closed, and
* Removing an open file does not close it. See Removing an Open File, for
* Details.
*
* Authored by Alex Stratford
*/
#include "system_calls.h"
#include "threads/interrupt.h" // Dependency for intr_frame struct
#include "filesys/file.h" // Dependency for and file struct
#include "filesys/filesys.h" // Dependency for filesys_remove
void syscall_remove(struct intr_frame *f) {
// pop off first int argument from interrupt frame
char* file_name = (void*)*((int*)f->esp + 1);
// Described in filesys.h, opens the file
if (filesys_remove(file_name) == false) { // Checking if file is empty or non-existent
f->eax = false; // Returning a failure state
return;
}
f->eax = true;
}
......@@ -49,6 +49,14 @@ void syscall_write(struct intr_frame *f);
*/
void syscall_open(struct intr_frame *f);
/*
* Deletes the file called file. Returns true if successful, false otherwise.
* A file may be removed regardless of whether it is open or closed, and
* Removing an open file does not close it. See Removing an Open File, for
* Details.
*/
void syscall_remove(struct intr_frame *f);
/*
* special additional stuff for handling file descriptors because they're annoying
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment