Fix: Update writability of the last page after loading as a workaround to calculating the offset, w/ G
This commit is contained in:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user