Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Cache struct exec_package * for readability. No fu...
details: https://anonhg.NetBSD.org/src/rev/efedb109e167
branches: trunk
changeset: 328632:efedb109e167
user: uebayasi <uebayasi%NetBSD.org@localhost>
date: Fri Apr 11 02:27:20 2014 +0000
description:
Cache struct exec_package * for readability. No functional changes.
diffstat:
sys/kern/kern_exec.c | 246 +++++++++++++++++++++++++-------------------------
1 files changed, 124 insertions(+), 122 deletions(-)
diffs (truncated from 538 to 300 lines):
diff -r bc1c80ee3eb4 -r efedb109e167 sys/kern/kern_exec.c
--- a/sys/kern/kern_exec.c Fri Apr 11 01:49:45 2014 +0000
+++ b/sys/kern/kern_exec.c Fri Apr 11 02:27:20 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_exec.c,v 1.377 2014/02/19 15:23:20 maxv Exp $ */
+/* $NetBSD: kern_exec.c,v 1.378 2014/04/11 02:27:20 uebayasi Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.377 2014/02/19 15:23:20 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.378 2014/04/11 02:27:20 uebayasi Exp $");
#include "opt_exec.h"
#include "opt_execfmt.h"
@@ -583,6 +583,7 @@
char * const *envs, execve_fetch_element_t fetch_element,
struct execve_data * restrict data)
{
+ struct exec_package * const epp = &data->ed_pack;
int error;
struct proc *p;
char *dp, *sp;
@@ -650,29 +651,28 @@
/*
* initialize the fields of the exec package.
*/
- data->ed_pack.ep_name = path;
- data->ed_pack.ep_kname = data->ed_pathstring;
- data->ed_pack.ep_resolvedname = data->ed_resolvedpathbuf;
- data->ed_pack.ep_hdr = kmem_alloc(exec_maxhdrsz, KM_SLEEP);
- data->ed_pack.ep_hdrlen = exec_maxhdrsz;
- data->ed_pack.ep_hdrvalid = 0;
- data->ed_pack.ep_emul_arg = NULL;
- data->ed_pack.ep_emul_arg_free = NULL;
- memset(&data->ed_pack.ep_vmcmds, 0, sizeof(data->ed_pack.ep_vmcmds));
- data->ed_pack.ep_vap = &data->ed_attr;
- data->ed_pack.ep_flags = 0;
- MD_TOPDOWN_INIT(&data->ed_pack);
- data->ed_pack.ep_emul_root = NULL;
- data->ed_pack.ep_interp = NULL;
- data->ed_pack.ep_esch = NULL;
- data->ed_pack.ep_pax_flags = 0;
- memset(data->ed_pack.ep_machine_arch, 0,
- sizeof(data->ed_pack.ep_machine_arch));
+ epp->ep_name = path;
+ epp->ep_kname = data->ed_pathstring;
+ epp->ep_resolvedname = data->ed_resolvedpathbuf;
+ epp->ep_hdr = kmem_alloc(exec_maxhdrsz, KM_SLEEP);
+ epp->ep_hdrlen = exec_maxhdrsz;
+ epp->ep_hdrvalid = 0;
+ epp->ep_emul_arg = NULL;
+ epp->ep_emul_arg_free = NULL;
+ memset(&epp->ep_vmcmds, 0, sizeof(epp->ep_vmcmds));
+ epp->ep_vap = &data->ed_attr;
+ epp->ep_flags = 0;
+ MD_TOPDOWN_INIT(epp);
+ epp->ep_emul_root = NULL;
+ epp->ep_interp = NULL;
+ epp->ep_esch = NULL;
+ epp->ep_pax_flags = 0;
+ memset(epp->ep_machine_arch, 0, sizeof(epp->ep_machine_arch));
rw_enter(&exec_lock, RW_READER);
/* see if we can run it. */
- if ((error = check_exec(l, &data->ed_pack, data->ed_pathbuf)) != 0) {
+ if ((error = check_exec(l, epp, data->ed_pathbuf)) != 0) {
if (error != ENOENT) {
DPRINTF(("%s: check exec failed %d\n",
__func__, error));
@@ -689,8 +689,8 @@
data->ed_argc = 0;
/* copy the fake args list, if there's one, freeing it as we go */
- if (data->ed_pack.ep_flags & EXEC_HASARGL) {
- tmpfap = data->ed_pack.ep_fa;
+ if (epp->ep_flags & EXEC_HASARGL) {
+ tmpfap = epp->ep_fa;
while (tmpfap->fa_arg != NULL) {
const char *cp;
@@ -703,8 +703,8 @@
kmem_free(tmpfap->fa_arg, tmpfap->fa_len);
tmpfap++; data->ed_argc++;
}
- kmem_free(data->ed_pack.ep_fa, data->ed_pack.ep_fa_len);
- data->ed_pack.ep_flags &= ~EXEC_HASARGL;
+ kmem_free(epp->ep_fa, epp->ep_fa_len);
+ epp->ep_flags &= ~EXEC_HASARGL;
}
/* Now get argv & environment */
@@ -715,7 +715,7 @@
}
/* 'i' will index the argp/envp element to be retrieved */
i = 0;
- if (data->ed_pack.ep_flags & EXEC_SKIPARG)
+ if (epp->ep_flags & EXEC_SKIPARG)
i++;
while (1) {
@@ -769,8 +769,8 @@
dp = (char *) ALIGN(dp);
- data->ed_szsigcode = data->ed_pack.ep_esch->es_emul->e_esigcode -
- data->ed_pack.ep_esch->es_emul->e_sigcode;
+ data->ed_szsigcode = epp->ep_esch->es_emul->e_esigcode -
+ epp->ep_esch->es_emul->e_sigcode;
#ifdef __MACHINE_STACK_GROWS_UP
/* See big comment lower down */
@@ -780,17 +780,17 @@
#endif
/* Now check if args & environ fit into new stack */
- if (data->ed_pack.ep_flags & EXEC_32) {
+ if (epp->ep_flags & EXEC_32) {
data->ed_ps_strings_sz = sizeof(struct ps_strings32);
len = ((data->ed_argc + data->ed_envc + 2 +
- data->ed_pack.ep_esch->es_arglen) *
+ epp->ep_esch->es_arglen) *
sizeof(int) + sizeof(int) + dp + RTLD_GAP +
data->ed_szsigcode + data->ed_ps_strings_sz + STACK_PTHREADSPACE)
- data->ed_argp;
} else {
data->ed_ps_strings_sz = sizeof(struct ps_strings);
len = ((data->ed_argc + data->ed_envc + 2 +
- data->ed_pack.ep_esch->es_arglen) *
+ epp->ep_esch->es_arglen) *
sizeof(char *) + sizeof(int) + dp + RTLD_GAP +
data->ed_szsigcode + data->ed_ps_strings_sz + STACK_PTHREADSPACE)
- data->ed_argp;
@@ -804,36 +804,36 @@
/* make the stack "safely" aligned */
len = STACK_LEN_ALIGN(len, STACK_ALIGNBYTES);
- if (len > data->ed_pack.ep_ssize) {
+ if (len > epp->ep_ssize) {
/* in effect, compare to initial limit */
DPRINTF(("%s: stack limit exceeded %zu\n", __func__, len));
goto bad;
}
/* adjust "active stack depth" for process VSZ */
- data->ed_pack.ep_ssize = len;
+ epp->ep_ssize = len;
return 0;
bad:
/* free the vmspace-creation commands, and release their references */
- kill_vmcmds(&data->ed_pack.ep_vmcmds);
+ kill_vmcmds(&epp->ep_vmcmds);
/* kill any opened file descriptor, if necessary */
- if (data->ed_pack.ep_flags & EXEC_HASFD) {
- data->ed_pack.ep_flags &= ~EXEC_HASFD;
- fd_close(data->ed_pack.ep_fd);
+ if (epp->ep_flags & EXEC_HASFD) {
+ epp->ep_flags &= ~EXEC_HASFD;
+ fd_close(epp->ep_fd);
}
/* close and put the exec'd file */
- vn_lock(data->ed_pack.ep_vp, LK_EXCLUSIVE | LK_RETRY);
- VOP_CLOSE(data->ed_pack.ep_vp, FREAD, l->l_cred);
- vput(data->ed_pack.ep_vp);
+ vn_lock(epp->ep_vp, LK_EXCLUSIVE | LK_RETRY);
+ VOP_CLOSE(epp->ep_vp, FREAD, l->l_cred);
+ vput(epp->ep_vp);
pool_put(&exec_pool, data->ed_argp);
freehdr:
- kmem_free(data->ed_pack.ep_hdr, data->ed_pack.ep_hdrlen);
- if (data->ed_pack.ep_emul_root != NULL)
- vrele(data->ed_pack.ep_emul_root);
- if (data->ed_pack.ep_interp != NULL)
- vrele(data->ed_pack.ep_interp);
+ kmem_free(epp->ep_hdr, epp->ep_hdrlen);
+ if (epp->ep_emul_root != NULL)
+ vrele(epp->ep_emul_root);
+ if (epp->ep_interp != NULL)
+ vrele(epp->ep_interp);
rw_exit(&exec_lock);
@@ -857,26 +857,27 @@
static void
execve_free_data(struct execve_data *data)
{
+ struct exec_package * const epp = &data->ed_pack;
/* free the vmspace-creation commands, and release their references */
- kill_vmcmds(&data->ed_pack.ep_vmcmds);
+ kill_vmcmds(&epp->ep_vmcmds);
/* kill any opened file descriptor, if necessary */
- if (data->ed_pack.ep_flags & EXEC_HASFD) {
- data->ed_pack.ep_flags &= ~EXEC_HASFD;
- fd_close(data->ed_pack.ep_fd);
+ if (epp->ep_flags & EXEC_HASFD) {
+ epp->ep_flags &= ~EXEC_HASFD;
+ fd_close(epp->ep_fd);
}
/* close and put the exec'd file */
- vn_lock(data->ed_pack.ep_vp, LK_EXCLUSIVE | LK_RETRY);
- VOP_CLOSE(data->ed_pack.ep_vp, FREAD, curlwp->l_cred);
- vput(data->ed_pack.ep_vp);
+ vn_lock(epp->ep_vp, LK_EXCLUSIVE | LK_RETRY);
+ VOP_CLOSE(epp->ep_vp, FREAD, curlwp->l_cred);
+ vput(epp->ep_vp);
pool_put(&exec_pool, data->ed_argp);
- kmem_free(data->ed_pack.ep_hdr, data->ed_pack.ep_hdrlen);
- if (data->ed_pack.ep_emul_root != NULL)
- vrele(data->ed_pack.ep_emul_root);
- if (data->ed_pack.ep_interp != NULL)
- vrele(data->ed_pack.ep_interp);
+ kmem_free(epp->ep_hdr, epp->ep_hdrlen);
+ if (epp->ep_emul_root != NULL)
+ vrele(epp->ep_emul_root);
+ if (epp->ep_interp != NULL)
+ vrele(epp->ep_interp);
pathbuf_stringcopy_put(data->ed_pathbuf, data->ed_pathstring);
pathbuf_destroy(data->ed_pathbuf);
@@ -887,6 +888,7 @@
execve_runproc(struct lwp *l, struct execve_data * restrict data,
bool no_local_exec_lock, bool is_spawn)
{
+ struct exec_package * const epp = &data->ed_pack;
int error = 0;
struct proc *p;
size_t i;
@@ -915,7 +917,7 @@
base_vcp = NULL;
- if (data->ed_pack.ep_flags & EXEC_32)
+ if (epp->ep_flags & EXEC_32)
aip = &arginfo32;
else
aip = &data->ed_arginfo;
@@ -941,30 +943,30 @@
* vmspace with another!
*/
if (is_spawn)
- uvmspace_spawn(l, data->ed_pack.ep_vm_minaddr,
- data->ed_pack.ep_vm_maxaddr,
- data->ed_pack.ep_flags & EXEC_TOPDOWN_VM);
+ uvmspace_spawn(l, epp->ep_vm_minaddr,
+ epp->ep_vm_maxaddr,
+ epp->ep_flags & EXEC_TOPDOWN_VM);
else
- uvmspace_exec(l, data->ed_pack.ep_vm_minaddr,
- data->ed_pack.ep_vm_maxaddr,
- data->ed_pack.ep_flags & EXEC_TOPDOWN_VM);
+ uvmspace_exec(l, epp->ep_vm_minaddr,
+ epp->ep_vm_maxaddr,
+ epp->ep_flags & EXEC_TOPDOWN_VM);
/* record proc's vnode, for use by procfs and others */
if (p->p_textvp)
vrele(p->p_textvp);
- vref(data->ed_pack.ep_vp);
- p->p_textvp = data->ed_pack.ep_vp;
+ vref(epp->ep_vp);
+ p->p_textvp = epp->ep_vp;
/* Now map address space */
vm = p->p_vmspace;
- vm->vm_taddr = (void *)data->ed_pack.ep_taddr;
- vm->vm_tsize = btoc(data->ed_pack.ep_tsize);
- vm->vm_daddr = (void*)data->ed_pack.ep_daddr;
- vm->vm_dsize = btoc(data->ed_pack.ep_dsize);
- vm->vm_ssize = btoc(data->ed_pack.ep_ssize);
+ vm->vm_taddr = (void *)epp->ep_taddr;
+ vm->vm_tsize = btoc(epp->ep_tsize);
+ vm->vm_daddr = (void*)epp->ep_daddr;
+ vm->vm_dsize = btoc(epp->ep_dsize);
+ vm->vm_ssize = btoc(epp->ep_ssize);
vm->vm_issize = 0;
- vm->vm_maxsaddr = (void *)data->ed_pack.ep_maxsaddr;
- vm->vm_minsaddr = (void *)data->ed_pack.ep_minsaddr;
+ vm->vm_maxsaddr = (void *)epp->ep_maxsaddr;
+ vm->vm_minsaddr = (void *)epp->ep_minsaddr;
#ifdef PAX_ASLR
pax_aslr_init(l, vm);
@@ -972,16 +974,16 @@
/* create the new process's VM space by running the vmcmds */
#ifdef DIAGNOSTIC
- if (data->ed_pack.ep_vmcmds.evs_used == 0)
+ if (epp->ep_vmcmds.evs_used == 0)
panic("%s: no vmcmds", __func__);
#endif
Home |
Main Index |
Thread Index |
Old Index