Implement writing to file system files in the write system call, w/ E
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user