to the kernel-only page directory. */
pd = cur->pagedir;
@@ -193,7 +284,7 @@ struct Elf32_Phdr
+ #define PF_W 2 /* Writable. */
#define PF_R 4 /* Readable. */
- static bool load_segment (struct file *, const struct Elf32_Phdr *);
-static bool setup_stack (void **esp);
+static bool setup_stack (const char *cmd_line, void **esp);
-
- /* Loads an ELF executable from FILENAME into the current thread.
- Stores the executable's entry point into *EIP
+ static bool validate_segment (const struct Elf32_Phdr *, struct file *);
+ static bool load_segment (struct file *file, off_t ofs, uint8_t *upage,
+ bool writable);
@@ -209,13 +300,15 @@ static bool setup_stack (void **esp);
and its initial stack pointer into *ESP.
Returns true if successful, false otherwise. */
kpage = palloc_get_page (PAL_USER | PAL_ZERO);
if (kpage != NULL)
{
-- success = install_page (((uint8_t *) PHYS_BASE) - PGSIZE, kpage);
+- success = install_page (((uint8_t *) PHYS_BASE) - PGSIZE, kpage, true);
- if (success)
- *esp = PHYS_BASE;
+ uint8_t *upage = ((uint8_t *) PHYS_BASE) - PGSIZE;
-+ if (install_page (upage, kpage))
++ if (install_page (upage, kpage, true))
+ success = init_cmd_line (kpage, upage, cmd_line, esp);
else
palloc_free_page (kpage);