-@@ -316,7 +427,7 @@ load_segment (struct file *file, const s
- commented out. You'll want to use it when implementing VM
- to decide whether to page the segment from its executable or
- from swap. */
-- //bool read_only = (phdr->p_flags & PF_W) == 0;
-+ bool read_only = (phdr->p_flags & PF_W) == 0;
-
- ASSERT (file != NULL);
- ASSERT (phdr != NULL);
-@@ -360,69 +471,129 @@ load_segment (struct file *file, const s
- return false;
- }
-
-- /* Load the segment page-by-page into memory. */
-+ /* Add the segment page-by-page to the hash table. */
- filesz_left = phdr->p_filesz + (phdr->p_vaddr & PGMASK);
-- file_seek (file, ROUND_DOWN (phdr->p_offset, PGSIZE));
-+ file_offset = ROUND_DOWN (phdr->p_offset, PGSIZE);
- for (upage = start; upage < (uint8_t *) end; upage += PGSIZE)
+- file_seek (file, ofs);
+ while (read_bytes > 0 || zero_bytes > 0)