Fix Bug in fd_get_file declaration use open_file instead of file, w/ E

This commit is contained in:
sBubshait
2024-11-08 15:54:28 +00:00
parent 5424276603
commit a80084e907

View File

@@ -44,6 +44,7 @@ static void syscall_seek (int fd, unsigned position);
static unsigned syscall_tell (int fd); static unsigned syscall_tell (int fd);
static void syscall_close (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); static void *validate_user_pointer (const void *ptr, size_t size);
/* A struct defining a syscall_function pointer along with its arity. */ /* 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 /* Gets a file from its descriptor (FD number). If there is no file with the fd
FD it returns NULL. */ FD it returns NULL. */
static struct file * static struct open_file *
fd_get_file (int fd) fd_get_file (int fd)
{ {
/* We have to set up a fake open_file in order to be able to search the hash /* 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; struct open_file *fake_file_info;
fake_file_info->fd = fd; fake_file_info->fd = fd;
struct file *file struct hash_elem *e
= hash_find (thread_current ()->open_files, fake_file_info->elem); = 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 /* Validates if a block of memory starting at PTR and of size SIZE bytes is