Skip to content
Snippets Groups Projects
Commit cbc9aef2 authored by a2-stratford's avatar a2-stratford
Browse files

Added guard condition to seek

Fixed guard condition in filesize to exit properly
parent b7e2b522
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,7 @@ void syscall_filesize(struct intr_frame *f) {
struct file *file = get_associated_file_pointer(file_descriptor);
if (file == NULL) { // Checking if file is empty or non-existent
f->eax -1; // Returning failure state
return;
}
// Using the file_length function in file.h to get the length and store it
int size = file_length(file);
......
......@@ -17,6 +17,9 @@ void syscall_seek(struct intr_frame *f) {
// pop off second int argument from interrupt frame
unsigned file_pos = *((unsigned*)((int*)f->esp + 2));
struct file *file = get_associated_file_pointer(file_descriptor);
if (file == NULL) { // Checking if file is empty or non-existent
return;
}
// Seek through the file
file_seek(file, file_pos);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment