From a80084e9077abe7a936872a526be0c1eea725bf5 Mon Sep 17 00:00:00 2001 From: sBubshait Date: Fri, 8 Nov 2024 15:54:28 +0000 Subject: [PATCH] Fix Bug in fd_get_file declaration use open_file instead of file, w/ E --- src/userprog/syscall.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/userprog/syscall.c b/src/userprog/syscall.c index ee91f43..faeac2d 100644 --- a/src/userprog/syscall.c +++ b/src/userprog/syscall.c @@ -44,6 +44,7 @@ static void syscall_seek (int fd, unsigned position); static unsigned syscall_tell (int fd); static void syscall_close (int fd); +static struct open_file *fd_get_file (int fd); static void *validate_user_pointer (const void *ptr, size_t size); /* A struct defining a syscall_function pointer along with its arity. */ @@ -283,7 +284,7 @@ fd_less (const struct hash_elem *a_, const struct hash_elem *b_, /* Gets a file from its descriptor (FD number). If there is no file with the fd FD it returns NULL. */ -static struct file * +static struct open_file * fd_get_file (int fd) { /* We have to set up a fake open_file in order to be able to search the hash @@ -291,10 +292,10 @@ fd_get_file (int fd) struct open_file *fake_file_info; fake_file_info->fd = fd; - struct file *file - = hash_find (thread_current ()->open_files, fake_file_info->elem); + struct hash_elem *e + = hash_find (&thread_current ()->open_files, &fake_file_info->elem); - return file; + return hash_entry (e, struct open_file, elem); } /* Validates if a block of memory starting at PTR and of size SIZE bytes is