Implement complete stack initialization, process_wait, and all system calls correctly except exec #34

Merged
td1223 merged 46 commits from userprog-merge into master 2024-11-11 22:56:29 +00:00
4 changed files with 155 additions and 25 deletions
Showing only changes of commit 18694d7b62 - Show all commits

View File

@@ -211,7 +211,7 @@ syscall_read (int fd, void *buffer, unsigned size)
{
/* Only console (fd = 0) or other files, not including STDOUT, (fd > 1) are
allowed. */
if (fd < 0 && fd != STDOUT_FILENO)
if (fd < 0 || fd == STDOUT_FILENO)
return -1;
validate_user_pointer (buffer, size);
@@ -228,7 +228,14 @@ syscall_read (int fd, void *buffer, unsigned size)
else
{
/* Reading from a file. */
return 0; // TODO: Implement Write to Files
struct open_file *file_info = fd_get_file (fd);
if (file_info == NULL)
return -1;
lock_acquire (&filesys_lock);
int bytes_written = file_read (file_info->file, buffer, size);
lock_release (&filesys_lock);
return bytes_written;
}
}