diff --git a/src/vm/mmap.c b/src/vm/mmap.c index 3d6bd79..528c597 100644 --- a/src/vm/mmap.c +++ b/src/vm/mmap.c @@ -15,6 +15,21 @@ mmap_init (struct thread *t) return hash_init (&t->mmap_files, mmap_hash, mmap_less, NULL); } +struct mmap_entry * +mmap_get (mapid_t mapping) +{ + struct mmap_entry fake_mmap_entry; + fake_mmap_entry.mapping = mapping; + + struct hash_elem *e + = hash_find (&thread_current ()->mmap_files, &fake_mmap_entry.elem); + + if (e == NULL) + return NULL; + + return hash_entry (e, struct mmap_entry, elem); +} + /* Inserts a new mmap entry into the mmap table for the current thread. Upage is the start address of the file data in the user VM. */ struct mmap_entry * diff --git a/src/vm/mmap.h b/src/vm/mmap.h index a64210a..5f7143b 100644 --- a/src/vm/mmap.h +++ b/src/vm/mmap.h @@ -18,6 +18,7 @@ struct mmap_entry { }; bool mmap_init (struct thread *t); +struct mmap_entry *mmap_get (mapid_t mapping); struct mmap_entry *mmap_insert (struct file *file, void *upage); void mmap_destroy (void);