diff --git a/src/userprog/syscall.c b/src/userprog/syscall.c index 102458f..f0aaf47 100644 --- a/src/userprog/syscall.c +++ b/src/userprog/syscall.c @@ -193,10 +193,17 @@ syscall_open (const char *file) } static int -syscall_filesize (int fd UNUSED) +syscall_filesize (int fd) { - //TODO - return 0; + struct open_file *file_info = fd_get_file (fd); + if (file_info == NULL) + return -1; + + lock_acquire (&filesys_lock); + int bytes = file_length (file_info->file); + lock_release (&filesys_lock); + + return bytes; } static int @@ -261,10 +268,17 @@ syscall_seek (int fd, unsigned position) } static unsigned -syscall_tell (int fd UNUSED) +syscall_tell (int fd) { - //TODO - return 0; + struct open_file *file_info = fd_get_file (fd); + if (file_info == NULL) + return 0; + + lock_acquire (&filesys_lock); + unsigned pos = file_tell (file_info->file); + lock_release (&filesys_lock); + + return pos; } static void