Fix: Update writability of the last page after loading as a workaround to calculating the offset, w/ G

This commit is contained in:
sBubshait
2024-11-29 15:45:44 +00:00
parent 92d0b68243
commit c8b93c57ee

View File

@@ -179,18 +179,23 @@ try_fetch_page (void *upage, bool write)
if (page == NULL)
return false;
/* An attempt to write to a non-writeable should fail. */
if (write && !page->writable)
{
pagedir_set_writable(thread_current()->pagedir, upage, write);
page->writable = true;
return true;
}
return false;
/* Load the page into memory based on the type of data it is expecting. */
bool success = false;
switch (page->type) {
case PAGE_EXECUTABLE:
return page_load (page, write);
success = page_load (page, page->writable);
break;
default:
return false;
}
}
if (success && page->writable &&
!pagedir_is_writable(thread_current()->pagedir, upage))
pagedir_set_writable(thread_current()->pagedir, upage, true);
return success;
}