Combine syscall code with final stack initialization code #32

Merged
td1223 merged 27 commits from read-only-exec into userprog-merge 2024-11-11 22:23:20 +00:00
4 changed files with 105 additions and 13 deletions
Showing only changes of commit 5424276603 - Show all commits

View File

@@ -281,6 +281,22 @@ fd_less (const struct hash_elem *a_, const struct hash_elem *b_,
return a->fd < b->fd; return a->fd < b->fd;
} }
/* Gets a file from its descriptor (FD number). If there is no file with the fd
FD it returns NULL. */
static struct file *
fd_get_file (int fd)
{
/* We have to set up a fake open_file in order to be able to search the hash
table. See hash.h. */
struct open_file *fake_file_info;
fake_file_info->fd = fd;
struct file *file
= hash_find (thread_current ()->open_files, fake_file_info->elem);
return file;
}
/* Validates if a block of memory starting at PTR and of size SIZE bytes is /* Validates if a block of memory starting at PTR and of size SIZE bytes is
fully contained within user virtual memory. Kills the thread (by calling fully contained within user virtual memory. Kills the thread (by calling
thread_exit) if the memory is invalid. Otherwise, returns the PTR given. thread_exit) if the memory is invalid. Otherwise, returns the PTR given.