summaryrefslogtreecommitdiffstats
path: root/sys/kern/exec_subr.c
diff options
context:
space:
mode:
authorart <art@openbsd.org>2002-10-06 22:39:25 +0000
committerart <art@openbsd.org>2002-10-06 22:39:25 +0000
commit1e04e3513f8bb50132d4eeb2d323415375d65772 (patch)
tree0fc3b171cf1ba1b65d63bd93bc2482de8265bc22 /sys/kern/exec_subr.c
parentNo more need to initialize the result list before uvm_pglistalloc. (diff)
downloadwireguard-openbsd-1e04e3513f8bb50132d4eeb2d323415375d65772.tar.xz
wireguard-openbsd-1e04e3513f8bb50132d4eeb2d323415375d65772.zip
Move out the execution of vmcmds into a separate function.
Diffstat (limited to 'sys/kern/exec_subr.c')
-rw-r--r--sys/kern/exec_subr.c39
1 files changed, 36 insertions, 3 deletions
diff --git a/sys/kern/exec_subr.c b/sys/kern/exec_subr.c
index a76ffdf3ad2..57e87626bb8 100644
--- a/sys/kern/exec_subr.c
+++ b/sys/kern/exec_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exec_subr.c,v 1.20 2002/10/02 23:56:32 mickey Exp $ */
+/* $OpenBSD: exec_subr.c,v 1.21 2002/10/06 22:39:25 art Exp $ */
/* $NetBSD: exec_subr.c,v 1.9 1994/12/04 03:10:42 mycroft Exp $ */
/*
@@ -107,8 +107,7 @@ vmcmdset_extend(evsp)
}
void
-kill_vmcmds(evsp)
- struct exec_vmcmd_set *evsp;
+kill_vmcmds(struct exec_vmcmd_set *evsp)
{
struct exec_vmcmd *vcp;
int i;
@@ -129,6 +128,40 @@ kill_vmcmds(evsp)
evsp->evs_cnt = EXEC_DEFAULT_VMCMD_SETSIZE;
}
+int
+exec_process_vmcmds(struct proc *p, struct exec_package *epp)
+{
+ struct exec_vmcmd *base_vc = NULL;
+ int error = 0;
+ int i;
+
+ for (i = 0; i < epp->ep_vmcmds.evs_used && !error; i++) {
+ struct exec_vmcmd *vcp;
+
+ vcp = &epp->ep_vmcmds.evs_cmds[i];
+
+ if (vcp->ev_flags & VMCMD_RELATIVE) {
+#ifdef DIAGNOSTIC
+ if (base_vc == NULL)
+ panic("exec_process_vmcmds: RELATIVE no base");
+#endif
+ vcp->ev_addr += base_vc->ev_addr;
+ }
+ error = (*vcp->ev_proc)(p, vcp);
+ if (vcp->ev_flags & VMCMD_BASE) {
+#ifdef DIAGNOSTIC
+ if (base_vc != NULL)
+ panic("exec_process_vmcmds: multiple BASE");
+#endif
+ base_vc = vcp;
+ }
+ }
+
+ kill_vmcmds(&epp->ep_vmcmds);
+
+ return (error);
+}
+
/*
* vmcmd_map_pagedvn():
* handle vmcmd which specifies that a vnode should be mmap'd.