Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern execve_runproc: Isolate ps_strings filling code int...
details: https://anonhg.NetBSD.org/src/rev/dd802a2cf85a
branches: trunk
changeset: 795491:dd802a2cf85a
user: uebayasi <uebayasi%NetBSD.org@localhost>
date: Tue Apr 15 16:44:57 2014 +0000
description:
execve_runproc: Isolate ps_strings filling code into a function.
diffstat:
sys/kern/kern_exec.c | 61 +++++++++++++++++++++++++++++++--------------------
1 files changed, 37 insertions(+), 24 deletions(-)
diffs (97 lines):
diff -r 879613986bf1 -r dd802a2cf85a sys/kern/kern_exec.c
--- a/sys/kern/kern_exec.c Tue Apr 15 16:13:04 2014 +0000
+++ b/sys/kern/kern_exec.c Tue Apr 15 16:44:57 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_exec.c,v 1.397 2014/04/15 16:13:04 uebayasi Exp $ */
+/* $NetBSD: kern_exec.c,v 1.398 2014/04/15 16:44:57 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.397 2014/04/15 16:13:04 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.398 2014/04/15 16:44:57 uebayasi Exp $");
#include "opt_exec.h"
#include "opt_execfmt.h"
@@ -124,6 +124,7 @@
static size_t calcargs(struct execve_data * restrict, const size_t);
static size_t calcstack(struct execve_data * restrict, const size_t);
+static int copyoutpsstrs(struct execve_data * restrict, struct proc *);
static int copyinargs(struct execve_data * restrict, char * const *,
char * const *, execve_fetch_element_t, char **);
static int copyinargstrs(struct execve_data * restrict, char * const *,
@@ -1082,29 +1083,9 @@
goto exec_abort;
}
- /* fill process ps_strings info */
- p->p_psstrp = (vaddr_t)STACK_ALLOC(STACK_GROW(vm->vm_minsaddr,
- STACK_PTHREADSPACE), data->ed_ps_strings_sz);
-
- struct ps_strings32 arginfo32;
- void *aip;
-
- if (epp->ep_flags & EXEC_32) {
- aip = &arginfo32;
- arginfo32.ps_argvstr = (vaddr_t)data->ed_arginfo.ps_argvstr;
- arginfo32.ps_nargvstr = data->ed_arginfo.ps_nargvstr;
- arginfo32.ps_envstr = (vaddr_t)data->ed_arginfo.ps_envstr;
- arginfo32.ps_nenvstr = data->ed_arginfo.ps_nenvstr;
- } else
- aip = &data->ed_arginfo;
-
- /* copy out the process's ps_strings structure */
- if ((error = copyout(aip, (void *)p->p_psstrp, data->ed_ps_strings_sz))
- != 0) {
- DPRINTF(("%s: ps_strings copyout %p->%p size %zu failed\n",
- __func__, aip, (void *)p->p_psstrp, data->ed_ps_strings_sz));
+ error = copyoutpsstrs(data, p);
+ if (error != 0)
goto exec_abort;
- }
cwdexec(p);
fd_closeexec(); /* handle close on exec */
@@ -1400,6 +1381,38 @@
}
static int
+copyoutpsstrs(struct execve_data * restrict data, struct proc *p)
+{
+ struct exec_package * const epp = &data->ed_pack;
+ struct ps_strings32 arginfo32;
+ void *aip;
+ int error;
+
+ /* fill process ps_strings info */
+ p->p_psstrp = (vaddr_t)STACK_ALLOC(STACK_GROW(epp->ep_minsaddr,
+ STACK_PTHREADSPACE), data->ed_ps_strings_sz);
+
+ if (epp->ep_flags & EXEC_32) {
+ aip = &arginfo32;
+ arginfo32.ps_argvstr = (vaddr_t)data->ed_arginfo.ps_argvstr;
+ arginfo32.ps_nargvstr = data->ed_arginfo.ps_nargvstr;
+ arginfo32.ps_envstr = (vaddr_t)data->ed_arginfo.ps_envstr;
+ arginfo32.ps_nenvstr = data->ed_arginfo.ps_nenvstr;
+ } else
+ aip = &data->ed_arginfo;
+
+ /* copy out the process's ps_strings structure */
+ if ((error = copyout(aip, (void *)p->p_psstrp, data->ed_ps_strings_sz))
+ != 0) {
+ DPRINTF(("%s: ps_strings copyout %p->%p size %zu failed\n",
+ __func__, aip, (void *)p->p_psstrp, data->ed_ps_strings_sz));
+ return error;
+ }
+
+ return 0;
+}
+
+static int
copyinargs(struct execve_data * restrict data, char * const *args,
char * const *envs, execve_fetch_element_t fetch_element, char **dpp)
{
Home |
Main Index |
Thread Index |
Old Index