Add a posix_spawn syscall, as discussed on tech-kern.

Based on the summer of code project by Charles Zhang, heavily reworked
later by me - all bugs are likely mine.
Ok: core, releng.
This commit is contained in:
martin 2012-02-11 23:16:15 +00:00
parent 61f6cea600
commit f8c7c04bbe
21 changed files with 1154 additions and 294 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: syscall.c,v 1.38 2012/02/06 02:14:12 matt Exp $ */
/* $NetBSD: syscall.c,v 1.39 2012/02/11 23:16:15 martin Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -89,7 +89,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.38 2012/02/06 02:14:12 matt Exp $");
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.39 2012/02/11 23:16:15 martin Exp $");
#include "opt_sa.h"
@ -342,3 +342,13 @@ child_return(void *arg)
userret(l);
ktrsysret(SYS_fork, 0, 0);
}
/*
* Process the tail end of a posix_spawn() for the child.
*/
void
cpu_spawn_return(struct lwp *l)
{
userret(l);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: syscall.c,v 1.51 2010/12/20 00:25:26 matt Exp $ */
/* $NetBSD: syscall.c,v 1.52 2012/02/11 23:16:15 martin Exp $ */
/*-
* Copyright (c) 2000, 2003 The NetBSD Foundation, Inc.
@ -71,7 +71,7 @@
#include <sys/param.h>
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.51 2010/12/20 00:25:26 matt Exp $");
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.52 2012/02/11 23:16:15 martin Exp $");
#include "opt_sa.h"
@ -336,3 +336,14 @@ child_return(void *arg)
userret(l);
ktrsysret(SYS_fork, 0, 0);
}
/*
* Process the tail end of a posix_spawn() for the child.
*/
void
cpu_spawn_return(struct lwp *l)
{
userret(l);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: m68k_syscall.c,v 1.46 2011/02/08 20:20:16 rmind Exp $ */
/* $NetBSD: m68k_syscall.c,v 1.47 2012/02/11 23:16:15 martin Exp $ */
/*-
* Portions Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: m68k_syscall.c,v 1.46 2011/02/08 20:20:16 rmind Exp $");
__KERNEL_RCSID(0, "$NetBSD: m68k_syscall.c,v 1.47 2012/02/11 23:16:15 martin Exp $");
#include "opt_execfmt.h"
#include "opt_compat_netbsd.h"
@ -446,3 +446,14 @@ upcallret(struct lwp *l)
machine_userret(l, f, 0);
}
/*
* Process the tail end of a posix_spawn() for the child.
*/
void
cpu_spawn_return(struct lwp *l)
{
struct frame *f = (struct frame *)l->l_md.md_regs;
machine_userret(l, f, 0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: mips_machdep.c,v 1.251 2011/12/12 19:03:10 mrg Exp $ */
/* $NetBSD: mips_machdep.c,v 1.252 2012/02/11 23:16:15 martin Exp $ */
/*
* Copyright 2002 Wasabi Systems, Inc.
@ -112,7 +112,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: mips_machdep.c,v 1.251 2011/12/12 19:03:10 mrg Exp $");
__KERNEL_RCSID(0, "$NetBSD: mips_machdep.c,v 1.252 2012/02/11 23:16:15 martin Exp $");
#define __INTR_PRIVATE
#include "opt_cputype.h"
@ -2380,3 +2380,14 @@ mips_watchpoint_init(void)
curcpu()->ci_cpuwatch_count = cpuwatch_discover();
}
#endif
/*
* Process the tail end of a posix_spawn() for the child.
*/
void
cpu_spawn_return(struct lwp *l)
{
userret(l);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: powerpc_machdep.c,v 1.61 2011/12/12 19:03:11 mrg Exp $ */
/* $NetBSD: powerpc_machdep.c,v 1.62 2012/02/11 23:16:16 martin Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: powerpc_machdep.c,v 1.61 2011/12/12 19:03:11 mrg Exp $");
__KERNEL_RCSID(0, "$NetBSD: powerpc_machdep.c,v 1.62 2012/02/11 23:16:16 martin Exp $");
#include "opt_altivec.h"
#include "opt_modular.h"
@ -323,6 +323,17 @@ startlwp(void *arg)
userret(l, tf);
}
/*
* Process the tail end of a posix_spawn() for the child.
*/
void
cpu_spawn_return(struct lwp *l)
{
struct trapframe * const tf = l->l_md.md_utf;
userret(l, tf);
}
void
upcallret(struct lwp *l)
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: syscall.c,v 1.25 2011/03/27 18:47:09 martin Exp $ */
/* $NetBSD: syscall.c,v 1.26 2012/02/11 23:16:16 martin Exp $ */
/*
* Copyright (c) 1996
@ -49,7 +49,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.25 2011/03/27 18:47:09 martin Exp $");
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.26 2012/02/11 23:16:16 martin Exp $");
#include "opt_sparc_arch.h"
#include "opt_multiprocessor.h"
@ -399,3 +399,14 @@ child_return(void *arg)
ktrsysret((l->l_proc->p_lflag & PL_PPWAIT) ? SYS_vfork : SYS_fork,
0, 0);
}
/*
* Process the tail end of a posix_spawn() for the child.
*/
void
cpu_spawn_return(struct lwp *l)
{
userret(l, l->l_md.md_tf->tf_pc, 0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: syscall.c,v 1.39 2011/03/27 18:47:09 martin Exp $ */
/* $NetBSD: syscall.c,v 1.40 2012/02/11 23:16:16 martin Exp $ */
/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
@ -79,7 +79,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.39 2011/03/27 18:47:09 martin Exp $");
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.40 2012/02/11 23:16:16 martin Exp $");
#include "opt_sa.h"
@ -481,6 +481,16 @@ child_return(void *arg)
ktrsysret((l->l_proc->p_lflag & PL_PPWAIT) ? SYS_vfork : SYS_fork, 0, 0);
}
/*
* Process the tail end of a posix_spawn() for the child.
*/
void
cpu_spawn_return(struct lwp *l)
{
userret(l, l->l_md.md_tf->tf_pc, 0);
}
/*
* Start a new LWP
*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: syscall.c,v 1.19 2011/07/03 02:18:21 matt Exp $ */
/* $NetBSD: syscall.c,v 1.20 2012/02/11 23:16:16 martin Exp $ */
/*
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
@ -33,7 +33,7 @@
/* All bugs are subject to removal without further notice */
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.19 2011/07/03 02:18:21 matt Exp $");
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.20 2012/02/11 23:16:16 martin Exp $");
#include "opt_multiprocessor.h"
#include "opt_sa.h"
@ -158,3 +158,13 @@ child_return(void *arg)
userret(l, l->l_md.md_utf, 0);
ktrsysret(SYS_fork, 0, 0);
}
/*
* Process the tail end of a posix_spawn() for the child.
*/
void
cpu_spawn_return(struct lwp *l)
{
userret(l, l->l_md.md_utf, 0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: syscall.c,v 1.8 2012/01/05 17:26:57 reinoud Exp $ */
/* $NetBSD: syscall.c,v 1.9 2012/02/11 23:16:16 martin Exp $ */
/*-
* Copyright (c) 1998, 2000, 2009 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.8 2012/01/05 17:26:57 reinoud Exp $");
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.9 2012/02/11 23:16:16 martin Exp $");
#include "opt_sa.h"
@ -88,6 +88,16 @@ child_return(void *arg)
ktrsysret(SYS_fork, 0, 0);
}
/*
* Process the tail end of a posix_spawn() for the child.
*/
void
cpu_spawn_return(struct lwp *l)
{
userret(l);
}
void
syscall_intern(struct proc *p)
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: exec_elf.c,v 1.36 2012/02/04 18:12:02 joerg Exp $ */
/* $NetBSD: exec_elf.c,v 1.37 2012/02/11 23:16:16 martin Exp $ */
/*-
* Copyright (c) 1994, 2000, 2005 The NetBSD Foundation, Inc.
@ -57,7 +57,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.36 2012/02/04 18:12:02 joerg Exp $");
__KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.37 2012/02/11 23:16:16 martin Exp $");
#ifdef _KERNEL_OPT
#include "opt_pax.h"
@ -84,6 +84,7 @@ __KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.36 2012/02/04 18:12:02 joerg Exp $");
#include <compat/common/compat_util.h>
#include <sys/pax.h>
#include <uvm/uvm_param.h>
extern struct emul emul_netbsd;
@ -416,9 +417,19 @@ elf_load_file(struct lwp *l, struct exec_package *epp, char *path,
u_long phsize;
Elf_Addr addr = *last;
struct proc *p;
bool use_topdown;
p = l->l_proc;
if (p->p_vmspace)
use_topdown = p->p_vmspace->vm_map.flags & VM_MAP_TOPDOWN;
else
#ifdef __USING_TOPDOWN_VM
use_topdown = true;
#else
use_topdown = false;
#endif
/*
* 1. open file
* 2. read filehdr
@ -562,7 +573,7 @@ elf_load_file(struct lwp *l, struct exec_package *epp, char *path,
flags = VMCMD_BASE;
if (addr == ELF_LINK_ADDR)
addr = ph0->p_vaddr;
if (p->p_vmspace->vm_map.flags & VM_MAP_TOPDOWN)
if (use_topdown)
addr = ELF_TRUNC(addr, ph0->p_align);
else
addr = ELF_ROUND(addr, ph0->p_align);

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_lwp.c,v 1.165 2011/12/15 00:05:18 jmcneill Exp $ */
/* $NetBSD: kern_lwp.c,v 1.166 2012/02/11 23:16:17 martin Exp $ */
/*-
* Copyright (c) 2001, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@ -211,7 +211,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.165 2011/12/15 00:05:18 jmcneill Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.166 2012/02/11 23:16:17 martin Exp $");
#include "opt_ddb.h"
#include "opt_lockdebug.h"
@ -871,7 +871,8 @@ lwp_startup(struct lwp *prev, struct lwp *new)
}
KPREEMPT_DISABLE(new);
spl0();
pmap_activate(new);
if (__predict_true(new->l_proc->p_vmspace))
pmap_activate(new);
/* Note trip through cpu_switchto(). */
pserialize_switchpoint();

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_proc.c,v 1.180 2011/05/13 22:22:03 rmind Exp $ */
/* $NetBSD: kern_proc.c,v 1.181 2012/02/11 23:16:17 martin Exp $ */
/*-
* Copyright (c) 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.180 2011/05/13 22:22:03 rmind Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.181 2012/02/11 23:16:17 martin Exp $");
#ifdef _KERNEL_OPT
#include "opt_kstack.h"
@ -836,7 +836,7 @@ proc_free_mem(struct proc *p)
* of the process.
* Also mksess should only be set if we are creating a process group
*
* Only called from sys_setsid and sys_setpgid.
* Only called from sys_setsid, sys_setpgid and posix_spawn/spawn_return.
*/
int
proc_enterpgrp(struct proc *curp, pid_t pid, pid_t pgid, bool mksess)

View File

@ -1,4 +1,4 @@
/* $NetBSD: sys_descrip.c,v 1.25 2012/01/25 14:04:09 christos Exp $ */
/* $NetBSD: sys_descrip.c,v 1.26 2012/02/11 23:16:17 martin Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sys_descrip.c,v 1.25 2012/01/25 14:04:09 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: sys_descrip.c,v 1.26 2012/02/11 23:16:17 martin Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -122,7 +122,7 @@ sys_dup(struct lwp *l, const struct sys_dup_args *uap, register_t *retval)
/*
* Duplicate a file descriptor to a particular value.
*/
static int
int
dodup(struct lwp *l, int from, int to, int flags, register_t *retval)
{
int error;

View File

@ -1,4 +1,4 @@
$NetBSD: syscalls.master,v 1.253 2012/02/01 05:34:41 dholland Exp $
$NetBSD: syscalls.master,v 1.254 2012/02/11 23:16:17 martin Exp $
; @(#)syscalls.master 8.2 (Berkeley) 1/13/94
@ -927,3 +927,8 @@
const struct timespec *tptr); }
473 STD RUMP { int|sys||__quotactl(const char *path, \
struct quotactl_args *args); }
474 NOERR { int|sys||posix_spawn(pid_t *pid, const char *path, \
const struct posix_spawn_file_actions *file_actions, \
const struct posix_spawnattr *attrp, \
char *const *argv, char *const *envp); }

View File

@ -1,4 +1,4 @@
/* $NetBSD: vfs_syscalls.c,v 1.447 2012/02/01 05:46:45 dholland Exp $ */
/* $NetBSD: vfs_syscalls.c,v 1.448 2012/02/11 23:16:17 martin Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@ -70,7 +70,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.447 2012/02/01 05:46:45 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.448 2012/02/11 23:16:17 martin Exp $");
#ifdef _KERNEL_OPT
#include "opt_fileassoc.h"
@ -119,6 +119,7 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.447 2012/02/01 05:46:45 dholland
static int change_flags(struct vnode *, u_long, struct lwp *);
static int change_mode(struct vnode *, int, struct lwp *l);
static int change_owner(struct vnode *, uid_t, gid_t, struct lwp *, int);
static int do_open(lwp_t *, struct pathbuf *, int, int, int *);
/*
* This table is used to maintain compatibility with 4.3BSD
@ -1463,6 +1464,78 @@ chdir_lookup(const char *path, int where, struct vnode **vpp, struct lwp *l)
return (error);
}
/*
* Internals of sys_open - path has already been converted into a pathbuf
* (so we can easily reuse this function from other parts of the kernel,
* like posix_spawn post-processing).
*/
static int
do_open(lwp_t *l, struct pathbuf *pb, int open_flags, int open_mode, int *fd)
{
struct proc *p = l->l_proc;
struct cwdinfo *cwdi = p->p_cwdi;
file_t *fp;
struct vnode *vp;
int flags, cmode;
int indx, error;
struct nameidata nd;
flags = FFLAGS(open_flags);
if ((flags & (FREAD | FWRITE)) == 0)
return EINVAL;
if ((error = fd_allocfile(&fp, &indx)) != 0) {
pathbuf_destroy(pb);
return error;
}
/* We're going to read cwdi->cwdi_cmask unlocked here. */
cmode = ((open_mode &~ cwdi->cwdi_cmask) & ALLPERMS) &~ S_ISTXT;
NDINIT(&nd, LOOKUP, FOLLOW | TRYEMULROOT, pb);
l->l_dupfd = -indx - 1; /* XXX check for fdopen */
if ((error = vn_open(&nd, flags, cmode)) != 0) {
fd_abort(p, fp, indx);
if ((error == EDUPFD || error == EMOVEFD) &&
l->l_dupfd >= 0 && /* XXX from fdopen */
(error =
fd_dupopen(l->l_dupfd, &indx, flags, error)) == 0) {
*fd = indx;
pathbuf_destroy(pb);
return (0);
}
if (error == ERESTART)
error = EINTR;
pathbuf_destroy(pb);
return error;
}
l->l_dupfd = 0;
vp = nd.ni_vp;
pathbuf_destroy(pb);
if ((error = open_setfp(l, fp, vp, indx, flags)))
return error;
VOP_UNLOCK(vp);
*fd = indx;
fd_affix(p, fp, indx);
return 0;
}
int
fd_open(const char *path, int open_flags, int open_mode, int *fd)
{
struct pathbuf *pb;
if ((open_flags & (FREAD | FWRITE)) == 0)
return EINVAL;
pb = pathbuf_create(path);
if (pb == NULL)
return ENOMEM;
return do_open(curlwp, pb, open_flags, open_mode, fd);
}
/*
* Check permissions, allocate an open file structure,
* and call the device open routine if any.
@ -1475,59 +1548,23 @@ sys_open(struct lwp *l, const struct sys_open_args *uap, register_t *retval)
syscallarg(int) flags;
syscallarg(int) mode;
} */
struct proc *p = l->l_proc;
struct cwdinfo *cwdi = p->p_cwdi;
file_t *fp;
struct vnode *vp;
int flags, cmode;
int indx, error;
struct pathbuf *pb;
struct nameidata nd;
int result, flags, error;
flags = FFLAGS(SCARG(uap, flags));
if ((flags & (FREAD | FWRITE)) == 0)
return (EINVAL);
error = pathbuf_copyin(SCARG(uap, path), &pb);
if (error) {
return error;
}
if ((error = fd_allocfile(&fp, &indx)) != 0) {
pathbuf_destroy(pb);
return error;
}
/* We're going to read cwdi->cwdi_cmask unlocked here. */
cmode = ((SCARG(uap, mode) &~ cwdi->cwdi_cmask) & ALLPERMS) &~ S_ISTXT;
NDINIT(&nd, LOOKUP, FOLLOW | TRYEMULROOT, pb);
l->l_dupfd = -indx - 1; /* XXX check for fdopen */
if ((error = vn_open(&nd, flags, cmode)) != 0) {
fd_abort(p, fp, indx);
if ((error == EDUPFD || error == EMOVEFD) &&
l->l_dupfd >= 0 && /* XXX from fdopen */
(error =
fd_dupopen(l->l_dupfd, &indx, flags, error)) == 0) {
*retval = indx;
pathbuf_destroy(pb);
return (0);
}
if (error == ERESTART)
error = EINTR;
pathbuf_destroy(pb);
return (error);
}
l->l_dupfd = 0;
vp = nd.ni_vp;
pathbuf_destroy(pb);
if ((error = open_setfp(l, fp, vp, indx, flags)))
if (error)
return error;
VOP_UNLOCK(vp);
*retval = indx;
fd_affix(p, fp, indx);
return (0);
error = do_open(l, pb, SCARG(uap, flags), SCARG(uap, mode), &result);
if (error)
return error;
*retval = result;
return 0;
}
int

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.141 2012/02/01 05:34:42 dholland Exp $
# $NetBSD: Makefile,v 1.142 2012/02/11 23:16:18 martin Exp $
.include <bsd.sys.mk>
@ -32,8 +32,8 @@ INCS= acct.h agpio.h aio.h ansi.h aout_mids.h ataio.h atomic.h audioio.h \
scanio.h sched.h scsiio.h sdt.h select.h selinfo.h sem.h sha1.h \
sha2.h shm.h siginfo.h signal.h signalvar.h sigtypes.h simplelock.h \
sleepq.h socket.h \
socketvar.h sockio.h specificdata.h stat.h statvfs.h \
syscall.h syscallargs.h sysctl.h stdarg.h stdint.h swap.h \
socketvar.h sockio.h spawn.h specificdata.h stat.h \
statvfs.h syscall.h syscallargs.h sysctl.h stdarg.h stdint.h swap.h \
syncobj.h syslimits.h syslog.h \
tape.h termios.h time.h timeb.h timepps.h times.h \
timex.h tls.h trace.h tree.h tty.h ttychars.h ttycom.h \

View File

@ -1,4 +1,4 @@
/* $NetBSD: filedesc.h,v 1.62 2012/01/25 00:28:35 christos Exp $ */
/* $NetBSD: filedesc.h,v 1.63 2012/02/11 23:16:18 martin Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -181,6 +181,7 @@ struct proc;
* Kernel global variables and routines.
*/
void fd_sys_init(void);
int fd_open(const char*, int, int, int*);
int fd_dupopen(int, int *, int, int);
int fd_alloc(struct proc *, int, int *);
void fd_tryexpand(struct proc *);
@ -209,6 +210,7 @@ int fd_dup2(file_t *, unsigned, int);
int fd_clone(file_t *, unsigned, int, const struct fileops *, void *);
void fd_set_exclose(struct lwp *, int, bool);
int pipe1(struct lwp *, register_t *, int);
int dodup(struct lwp *, int, int, int, register_t *);
void cwd_sys_init(void);
struct cwdinfo *cwdinit(void);

View File

@ -1,4 +1,4 @@
/* $NetBSD: proc.h,v 1.314 2012/01/28 12:22:33 rmind Exp $ */
/* $NetBSD: proc.h,v 1.315 2012/02/11 23:16:18 martin Exp $ */
/*-
* Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@ -485,6 +485,7 @@ void cpu_lwp_fork(struct lwp *, struct lwp *, void *, size_t,
void (*)(void *), void *);
void cpu_lwp_free(struct lwp *, int);
void cpu_lwp_free2(struct lwp *);
void cpu_spawn_return(struct lwp*);
#ifdef __HAVE_SYSCALL_INTERN
void syscall_intern(struct proc *);

86
sys/sys/spawn.h Normal file
View File

@ -0,0 +1,86 @@
/* $NetBSD: spawn.h,v 1.1 2012/02/11 23:16:18 martin Exp $ */
/*-
* Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: src/include/spawn.h,v 1.3.2.1.4.1 2010/06/14 02:09:06 kensmith Exp $
*/
#ifndef _SYS_SPAWN_H_
#define _SYS_SPAWN_H_
#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/sigtypes.h>
#include <sys/signal.h>
#include <sys/sched.h>
struct posix_spawnattr {
short sa_flags;
pid_t sa_pgroup;
struct sched_param sa_schedparam;
int sa_schedpolicy;
sigset_t sa_sigdefault;
sigset_t sa_sigmask;
};
typedef struct posix_spawn_file_actions_entry {
enum { FAE_OPEN, FAE_DUP2, FAE_CLOSE } fae_action;
int fae_fildes;
union {
struct {
char *path;
#define fae_path fae_data.open.path
int oflag;
#define fae_oflag fae_data.open.oflag
mode_t mode;
#define fae_mode fae_data.open.mode
} open;
struct {
int newfildes;
#define fae_newfildes fae_data.dup2.newfildes
} dup2;
} fae_data;
} posix_spawn_file_actions_entry_t;
struct posix_spawn_file_actions {
int size; /* size of fae array */
int len; /* how many slots are used */
posix_spawn_file_actions_entry_t *fae;
};
typedef struct posix_spawnattr posix_spawnattr_t;
typedef struct posix_spawn_file_actions posix_spawn_file_actions_t;
#define POSIX_SPAWN_RESETIDS 0x01
#define POSIX_SPAWN_SETPGROUP 0x02
#define POSIX_SPAWN_SETSCHEDPARAM 0x04
#define POSIX_SPAWN_SETSCHEDULER 0x08
#define POSIX_SPAWN_SETSIGDEF 0x10
#define POSIX_SPAWN_SETSIGMASK 0x20
#endif /* !_SYS_SPAWN_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: uvm_glue.c,v 1.154 2012/02/01 23:43:49 para Exp $ */
/* $NetBSD: uvm_glue.c,v 1.155 2012/02/11 23:16:18 martin Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: uvm_glue.c,v 1.154 2012/02/01 23:43:49 para Exp $");
__KERNEL_RCSID(0, "$NetBSD: uvm_glue.c,v 1.155 2012/02/11 23:16:18 martin Exp $");
#include "opt_kgdb.h"
#include "opt_kstack.h"
@ -426,7 +426,8 @@ uvm_proc_exit(struct proc *p)
pmap_activate(l);
KPREEMPT_ENABLE(l);
uvmspace_free(ovm);
if (__predict_true(ovm!=NULL))
uvmspace_free(ovm);
}
void