From b3bebfce8a790975ba941d346e6bcff1b5afecf9 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 13 Jul 2009 09:34:45 -0700 Subject: [PATCH] exec tweaks --- exec.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/exec.c b/exec.c index 1c653de..3be3eed 100644 --- a/exec.c +++ b/exec.c @@ -16,19 +16,21 @@ exec(char *path, char **argv) struct inode *ip; struct proghdr ph; + mem = 0; + sz = 0; + if((ip = namei(path)) == 0) return -1; ilock(ip); - // Compute memory size of new process. - mem = 0; - sz = 0; - - // Program segments. + // Check ELF header if(readi(ip, (char*)&elf, 0, sizeof(elf)) < sizeof(elf)) goto bad; if(elf.magic != ELF_MAGIC) goto bad; + + // Compute memory size of new process. + // Program segments. for(i=0, off=elf.phoff; i