diff options
| author | David Greenman <dg@FreeBSD.org> | 1997-04-03 06:37:49 +0000 |
|---|---|---|
| committer | David Greenman <dg@FreeBSD.org> | 1997-04-03 06:37:49 +0000 |
| commit | 5397377bf130df03558bc83d80ffb75ba425e31d (patch) | |
| tree | 2515d60a1b47d9daf7008c9eca5edd7c51df6a72 | |
| parent | 00699bdaa960c15fe7b92a551c6ce55af3844bf2 (diff) | |
Notes
| -rw-r--r-- | sys/i386/i386/machdep.c | 4 | ||||
| -rw-r--r-- | sys/kern/kern_exec.c | 67 | ||||
| -rw-r--r-- | sys/pc98/i386/machdep.c | 4 | ||||
| -rw-r--r-- | sys/vm/vm_kern.c | 3 | ||||
| -rw-r--r-- | sys/vm/vm_kern.h | 3 |
5 files changed, 42 insertions, 39 deletions
diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index 8e14ae139772..dba723d663e1 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 - * $Id: machdep.c,v 1.209.2.8 1997/01/17 19:28:26 davidg Exp $ + * $Id: machdep.c,v 1.209.2.9 1997/02/14 01:11:30 bde Exp $ */ #include "npx.h" @@ -335,8 +335,6 @@ again: (nswbuf*MAXPHYS) + pager_map_size, TRUE); exec_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr, (16*ARG_MAX), TRUE); - exech_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr, - (16*PAGE_SIZE), TRUE); u_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr, (maxproc*UPAGES*PAGE_SIZE), FALSE); diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index d1970dbf6fca..572963ae3f1f 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: kern_exec.c,v 1.47.2.1 1996/11/09 10:42:28 joerg Exp $ + * $Id: kern_exec.c,v 1.47.2.2 1997/02/19 03:53:35 davidg Exp $ */ #include <sys/param.h> @@ -47,6 +47,7 @@ #include <sys/shm.h> #include <sys/sysctl.h> #include <sys/vnode.h> +#include <sys/buf.h> #include <vm/vm.h> #include <vm/vm_param.h> @@ -102,6 +103,7 @@ execve(p, uap, retval) int error, len, i; struct image_params image_params, *imgp; struct vattr attr; + struct buf *bp = NULL; imgp = &image_params; @@ -158,29 +160,32 @@ interpret: */ error = exec_check_permissions(imgp); - /* - * Lose the lock on the vnode. It's no longer needed, and must not - * exist for the pagefault paging to work below. - */ - VOP_UNLOCK(imgp->vp); - if (error) goto exec_fail_dealloc; /* - * Map the image header (first page) of the file into - * kernel address space + * Get the image header, which we define here as meaning the first + * page of the executable. */ - error = vm_mmap(exech_map, /* map */ - (vm_offset_t *)&imgp->image_header, /* address */ - PAGE_SIZE, /* size */ - VM_PROT_READ, /* protection */ - VM_PROT_READ, /* max protection */ - 0, /* flags */ - (caddr_t)imgp->vp, /* vnode */ - 0); /* offset */ + if (imgp->vp->v_mount && imgp->vp->v_mount->mnt_stat.f_iosize >= PAGE_SIZE) { + /* + * Get a buffer with (at least) the first page. + */ + error = bread(imgp->vp, 0, imgp->vp->v_mount->mnt_stat.f_iosize, + p->p_ucred, &bp); + imgp->image_header = bp->b_data; + } else { + /* + * The filesystem block size is too small, so do this the hard + * way. Malloc some space and read PAGE_SIZE worth of the image + * header into it. + */ + imgp->image_header = malloc(PAGE_SIZE, M_TEMP, M_WAITOK); + error = vn_rdwr(UIO_READ, imgp->vp, (void *)imgp->image_header, PAGE_SIZE, 0, + UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, NULL, p); + } + VOP_UNLOCK(imgp->vp); if (error) { - uprintf("mmap failed: %d\n",error); goto exec_fail_dealloc; } @@ -203,13 +208,16 @@ interpret: if (error) goto exec_fail_dealloc; if (imgp->interpreted) { + /* free old bp/image_header */ + if (bp != NULL) { + brelse(bp); + bp = NULL; + } else { + free((void *)imgp->image_header, M_TEMP); + } /* free old vnode and name buffer */ vrele(ndp->ni_vp); FREE(ndp->ni_cnd.cn_pnbuf, M_NAMEI); - if (vm_map_remove(exech_map, (vm_offset_t)imgp->image_header, - (vm_offset_t)imgp->image_header + PAGE_SIZE)) - panic("execve: header dealloc failed (1)"); - /* set new name to that of the interpreter */ NDINIT(ndp, LOOKUP, LOCKLEAF | FOLLOW | SAVENAME, UIO_SYSSPACE, imgp->interpreter_name, p); @@ -321,9 +329,10 @@ interpret: * free various allocated resources */ kmem_free_wakeup(exec_map, (vm_offset_t)imgp->stringbase, ARG_MAX); - if (vm_map_remove(exech_map, (vm_offset_t)imgp->image_header, - (vm_offset_t)imgp->image_header + PAGE_SIZE)) - panic("execve: header dealloc failed (2)"); + if (bp != NULL) + brelse(bp); + else if (imgp->image_header != NULL) + free((void *)imgp->image_header, M_TEMP); vrele(ndp->ni_vp); FREE(ndp->ni_cnd.cn_pnbuf, M_NAMEI); @@ -332,10 +341,10 @@ interpret: exec_fail_dealloc: if (imgp->stringbase != NULL) kmem_free_wakeup(exec_map, (vm_offset_t)imgp->stringbase, ARG_MAX); - if (imgp->image_header && imgp->image_header != (char *)-1) - if (vm_map_remove(exech_map, (vm_offset_t)imgp->image_header, - (vm_offset_t)imgp->image_header + PAGE_SIZE)) - panic("execve: header dealloc failed (3)"); + if (bp != NULL) + brelse(bp); + else if (imgp->image_header != NULL) + free((void *)imgp->image_header, M_TEMP); if (ndp->ni_vp) vrele(ndp->ni_vp); FREE(ndp->ni_cnd.cn_pnbuf, M_NAMEI); diff --git a/sys/pc98/i386/machdep.c b/sys/pc98/i386/machdep.c index 5102298a36ba..2e867bd2b51d 100644 --- a/sys/pc98/i386/machdep.c +++ b/sys/pc98/i386/machdep.c @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 - * $Id: machdep.c,v 1.11.2.8 1997/01/20 18:30:45 kato Exp $ + * $Id: machdep.c,v 1.11.2.9 1997/02/14 05:37:48 kato Exp $ */ #include "npx.h" @@ -342,8 +342,6 @@ again: (nswbuf*MAXPHYS) + pager_map_size, TRUE); exec_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr, (16*ARG_MAX), TRUE); - exech_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr, - (16*PAGE_SIZE), TRUE); u_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr, (maxproc*UPAGES*PAGE_SIZE), FALSE); diff --git a/sys/vm/vm_kern.c b/sys/vm/vm_kern.c index c5096cb5c93c..29b2ded0cb22 100644 --- a/sys/vm/vm_kern.c +++ b/sys/vm/vm_kern.c @@ -61,7 +61,7 @@ * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. * - * $Id: vm_kern.c,v 1.27.2.1 1997/01/17 19:28:38 davidg Exp $ + * $Id: vm_kern.c,v 1.27.2.2 1997/03/25 04:54:25 dyson Exp $ */ /* @@ -92,7 +92,6 @@ vm_map_t kernel_map=0; vm_map_t kmem_map=0; vm_map_t exec_map=0; -vm_map_t exech_map=0; vm_map_t clean_map=0; vm_map_t u_map=0; vm_map_t buffer_map=0; diff --git a/sys/vm/vm_kern.h b/sys/vm/vm_kern.h index e23ca590512f..e090d74c4118 100644 --- a/sys/vm/vm_kern.h +++ b/sys/vm/vm_kern.h @@ -61,7 +61,7 @@ * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. * - * $Id: vm_kern.h,v 1.8 1996/05/18 03:52:13 dyson Exp $ + * $Id: vm_kern.h,v 1.8.2.1 1997/01/17 19:28:39 davidg Exp $ */ #ifndef _VM_VM_KERN_H_ @@ -77,7 +77,6 @@ extern vm_map_t io_map; extern vm_map_t clean_map; extern vm_map_t phys_map; extern vm_map_t exec_map; -extern vm_map_t exech_map; extern vm_map_t u_map; extern vm_offset_t kernel_vm_end; |
