Fit exec on a page. Again

This commit is contained in:
Austin Clements 2011-09-02 15:27:41 -04:00
parent 4e015d81aa
commit 5a97613bab

7
exec.c
View file

@ -50,8 +50,7 @@ exec(char *path, char **argv)
ip = 0;
// Allocate two pages at the next page boundary.
// Make the first inaccessible.
// Use the second as the user stack.
// Make the first inaccessible. Use the second as the user stack.
sz = PGROUNDUP(sz);
if((sz = allocuvm(pgdir, sz, sz + 2*PGSIZE)) == 0)
goto bad;
@ -62,8 +61,7 @@ exec(char *path, char **argv)
for(argc = 0; argv[argc]; argc++) {
if(argc >= MAXARG)
goto bad;
sp -= strlen(argv[argc]) + 1;
sp &= ~3;
sp = (sp - strlen(argv[argc]) + 1) & ~3;
if(copyout(pgdir, sp, argv[argc], strlen(argv[argc]) + 1) < 0)
goto bad;
ustack[3+argc] = sp;
@ -92,7 +90,6 @@ exec(char *path, char **argv)
proc->tf->esp = sp;
switchuvm(proc);
freevm(oldpgdir);
return 0;
bad: