Fix: Insert pages in mmap as PAGE_MMAP instead of PAGE_FILE
This commit is contained in:
@@ -461,10 +461,9 @@ syscall_mmap (int fd, void *addr)
|
||||
/* Check and ensure that there is enough space in the user virtual memory to
|
||||
hold the entire file. */
|
||||
for (off_t ofs = 0; ofs < file_size; ofs += PGSIZE)
|
||||
{
|
||||
if (page_get (thread_current (), addr + ofs) != NULL)
|
||||
return MMAP_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
/* Map the file data into the user virtual memory starting from addr. */
|
||||
for (off_t ofs = 0; ofs < file_size; ofs += PGSIZE)
|
||||
@@ -473,7 +472,7 @@ syscall_mmap (int fd, void *addr)
|
||||
off_t zero_bytes = PGSIZE - read_bytes;
|
||||
|
||||
if (page_insert_file (file, ofs, addr + ofs, read_bytes, zero_bytes, true,
|
||||
PAGE_FILE) == NULL)
|
||||
PAGE_MMAP) == NULL)
|
||||
return MMAP_FAILURE;
|
||||
}
|
||||
|
||||
@@ -482,7 +481,6 @@ syscall_mmap (int fd, void *addr)
|
||||
if (mmap == NULL)
|
||||
return MMAP_FAILURE;
|
||||
|
||||
|
||||
return mmap->mapping;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user