Update SPT page entry to change type from EXECUTABLE to PAGE_FILE to capture mmaps in addition to executables

This commit is contained in:
sBubshait
2024-12-04 17:51:30 +00:00
parent ad6e4b4059
commit 941e1e067a
5 changed files with 8 additions and 24 deletions

View File

@@ -194,7 +194,7 @@ try_fetch_page (void *upage, bool write)
/* Load the page into memory based on the type of data it is expecting. */
bool success = false;
switch (page->type) {
case PAGE_EXECUTABLE:
case PAGE_FILE:
success = page_load (page, page->writable);
break;
default:

View File

@@ -706,7 +706,7 @@ load_segment (struct file *file, off_t ofs, uint8_t *upage,
/* Add the page metadata to the SPT to be lazy loaded later on */
if (page_insert (file, ofs, upage, page_read_bytes, page_zero_bytes,
writable, PAGE_EXECUTABLE) == NULL)
writable, PAGE_FILE) == NULL)
return false;
/* Advance. */

View File

@@ -444,7 +444,7 @@ syscall_mmap (int fd, void *addr)
off_t zero_bytes = PGSIZE - read_bytes;
if (page_insert (file, ofs, addr + ofs, read_bytes, zero_bytes, true,
PAGE_EXECUTABLE) == NULL)
PAGE_FILE) == NULL)
return MMAP_FAILURE;
}
@@ -457,9 +457,11 @@ syscall_mmap (int fd, void *addr)
return mmap->mapping;
}
/* Handles the syscall for unmapping a memory mapped file. */
/* Handles the syscall for unmapping a memory mapped file.
Pre: mapping is a valid mapping identifier returned by mmap syscall.*/
static void
syscall_munmap (mapid_t mapping UNUSED)
syscall_munmap (mapid_t mapping)
{
}