diff --git a/userprog/syscall.c b/userprog/syscall.c index a104087f96233896df559ed9c72e37c0c3ea2b14..0d416297093bcec6ada3125813697f92197782a2 100644 --- a/userprog/syscall.c +++ b/userprog/syscall.c @@ -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 diff --git a/userprog/syscall.h b/userprog/syscall.h index 90590967a9f96f9ea359d15c672b815dfb4379cb..4adc2988a944f4e68b80475e5f6449503ca06849 100644 --- a/userprog/syscall.h +++ b/userprog/syscall.h @@ -3,4 +3,6 @@ void syscall_init (void); +void file_search(struct file_map *f); + #endif /* userprog/syscall.h */ diff --git a/userprog/syscall_filesize.c b/userprog/syscall_filesize.c index ebfbf76167d58126c5c6cee9bb7da6c6764922c6..8bdba551c98197a851636f5d306ce45d5d8b3467 100644 --- a/userprog/syscall_filesize.c +++ b/userprog/syscall_filesize.c @@ -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