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

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
parent 460808eb
No related branches found
No related tags found
2 merge requests!22Merge Feature/system calls,!6Implemented filesize system call
......@@ -84,3 +84,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
......@@ -3,4 +3,6 @@
void syscall_init (void);
void file_search(struct file_map *f);
#endif /* userprog/syscall.h */
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment