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)
|
if (page == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
/* An attempt to write to a non-writeable should fail. */
|
||||||
if (write && !page->writable)
|
if (write && !page->writable)
|
||||||
{
|
return false;
|
||||||
pagedir_set_writable(thread_current()->pagedir, upage, write);
|
|
||||||
page->writable = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Load the page into memory based on the type of data it is expecting. */
|
/* Load the page into memory based on the type of data it is expecting. */
|
||||||
|
bool success = false;
|
||||||
switch (page->type) {
|
switch (page->type) {
|
||||||
case PAGE_EXECUTABLE:
|
case PAGE_EXECUTABLE:
|
||||||
return page_load (page, write);
|
success = page_load (page, page->writable);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return false;
|
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