diff --git a/src/userprog/syscall.c b/src/userprog/syscall.c index 9a42214..4bd8732 100644 --- a/src/userprog/syscall.c +++ b/src/userprog/syscall.c @@ -258,7 +258,15 @@ syscall_write (int fd, const void *buffer, unsigned size) else { /* Writing to a file. */ - return 0; // TODO: Implement Write to Files + struct open_file *file_info = fd_get_file (fd); + if (file_info == NULL) + return 0; + + lock_acquire (&filesys_lock); + int bytes = file_write (file_info->file, buffer, size); + lock_release (&filesys_lock); + + return bytes; } }