Update mmap to add a get helper function to find a mmap entry from its mapping
This commit is contained in:
@@ -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 *
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user