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

Update syscall_filesize.c for file neatness

parent f5b06759
No related branches found
No related tags found
2 merge requests!22Merge Feature/system calls,!6Implemented filesize system call
...@@ -2,10 +2,12 @@ ...@@ -2,10 +2,12 @@
#include "filesys/file.h" #include "filesys/file.h"
int syscall_filesize(struct intr_frame *file_descriptor) { int syscall_filesize(struct intr_frame *file_descriptor) {
struct file_map *file_map = get_file(file_descriptor); // Described in system_calls.h, stores file descriptors mapped to files // Described in system_calls.h, stores file descriptors mapped to files
struct file_map *file_map = get_file(file_descriptor);
int size; int size;
if (file_map == NULL) // Checking if file is empty or non-existent if (file_map == NULL) // Checking if file is empty or non-existent
return -1; return -1; // Returning failure state
size = file_length(file_map->file); // Using the file_length function in file.h to get the length and store it // Using the file_length function in file.h to get the length and store it
size = file_length(file_map->file);
return size; return size;
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment