diff --git a/userprog/syscall.c b/userprog/syscall.c index 55e9ffe91f27173f2ef6daa1d311dcd6e1bb3148..4d82e20bdda44ef7d9aaba8da4204e3d3b4bc392 100644 --- a/userprog/syscall.c +++ b/userprog/syscall.c @@ -78,3 +78,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 diff --git a/userprog/system_calls.h b/userprog/system_calls.h index 21d6f9f95f9ba4a77c47687ad5f95a1c9de9c25e..c063331cf819351a84a6d061aad305a5a9c8d4bd 100644 --- a/userprog/system_calls.h +++ b/userprog/system_calls.h @@ -36,7 +36,7 @@ void syscall_wait(struct intr_frame *f); /* * Returns the size, in bytes, of the file open as fd. */ -int syscall_filesize(struct intr_frame *f) +void syscall_filesize(struct intr_frame *f) /* * NOTE: There are more system calls implemented by Pintos but we are not