Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Add a posix_spawn syscall, as discussed on tech-kern.



details:   https://anonhg.NetBSD.org/src/rev/288ed9328025
branches:  trunk
changeset: 773651:288ed9328025
user:      martin <martin%NetBSD.org@localhost>
date:      Sat Feb 11 23:16:15 2012 +0000

description:
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.

diffstat:

 sys/arch/alpha/alpha/syscall.c             |    14 +-
 sys/arch/arm/arm/syscall.c                 |    15 +-
 sys/arch/m68k/m68k/m68k_syscall.c          |    15 +-
 sys/arch/mips/mips/mips_machdep.c          |    15 +-
 sys/arch/powerpc/powerpc/powerpc_machdep.c |    15 +-
 sys/arch/sparc/sparc/syscall.c             |    15 +-
 sys/arch/sparc64/sparc64/syscall.c         |    14 +-
 sys/arch/vax/vax/syscall.c                 |    14 +-
 sys/arch/x86/x86/syscall.c                 |    14 +-
 sys/kern/exec_elf.c                        |    17 +-
 sys/kern/kern_exec.c                       |  1039 ++++++++++++++++++++++-----
 sys/kern/kern_lwp.c                        |     7 +-
 sys/kern/kern_proc.c                       |     6 +-
 sys/kern/sys_descrip.c                     |     6 +-
 sys/kern/syscalls.master                   |     7 +-
 sys/kern/vfs_syscalls.c                    |   127 ++-
 sys/sys/Makefile                           |     6 +-
 sys/sys/filedesc.h                         |     4 +-
 sys/sys/proc.h                             |     3 +-
 sys/sys/spawn.h                            |    86 ++
 sys/uvm/uvm_glue.c                         |     7 +-
 21 files changed, 1153 insertions(+), 293 deletions(-)

diffs (truncated from 2236 to 300 lines):

diff -r 7c12a2e54c1e -r 288ed9328025 sys/arch/alpha/alpha/syscall.c
--- a/sys/arch/alpha/alpha/syscall.c    Sat Feb 11 22:09:47 2012 +0000
+++ b/sys/arch/alpha/alpha/syscall.c    Sat Feb 11 23:16:15 2012 +0000
@@ -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 @@
        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);
+}
diff -r 7c12a2e54c1e -r 288ed9328025 sys/arch/arm/arm/syscall.c
--- a/sys/arch/arm/arm/syscall.c        Sat Feb 11 22:09:47 2012 +0000
+++ b/sys/arch/arm/arm/syscall.c        Sat Feb 11 23:16:15 2012 +0000
@@ -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 @@
        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);
+}
+
diff -r 7c12a2e54c1e -r 288ed9328025 sys/arch/m68k/m68k/m68k_syscall.c
--- a/sys/arch/m68k/m68k/m68k_syscall.c Sat Feb 11 22:09:47 2012 +0000
+++ b/sys/arch/m68k/m68k/m68k_syscall.c Sat Feb 11 23:16:15 2012 +0000
@@ -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 @@
 
        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);
+}
diff -r 7c12a2e54c1e -r 288ed9328025 sys/arch/mips/mips/mips_machdep.c
--- a/sys/arch/mips/mips/mips_machdep.c Sat Feb 11 22:09:47 2012 +0000
+++ b/sys/arch/mips/mips/mips_machdep.c Sat Feb 11 23:16:15 2012 +0000
@@ -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 @@
        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);
+}
+
diff -r 7c12a2e54c1e -r 288ed9328025 sys/arch/powerpc/powerpc/powerpc_machdep.c
--- a/sys/arch/powerpc/powerpc/powerpc_machdep.c        Sat Feb 11 22:09:47 2012 +0000
+++ b/sys/arch/powerpc/powerpc/powerpc_machdep.c        Sat Feb 11 23:16:15 2012 +0000
@@ -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 @@
        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)
 {
diff -r 7c12a2e54c1e -r 288ed9328025 sys/arch/sparc/sparc/syscall.c
--- a/sys/arch/sparc/sparc/syscall.c    Sat Feb 11 22:09:47 2012 +0000
+++ b/sys/arch/sparc/sparc/syscall.c    Sat Feb 11 23:16:15 2012 +0000
@@ -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 @@
        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);
+}
+
diff -r 7c12a2e54c1e -r 288ed9328025 sys/arch/sparc64/sparc64/syscall.c
--- a/sys/arch/sparc64/sparc64/syscall.c        Sat Feb 11 22:09:47 2012 +0000
+++ b/sys/arch/sparc64/sparc64/syscall.c        Sat Feb 11 23:16:15 2012 +0000
@@ -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 @@
        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
  */
diff -r 7c12a2e54c1e -r 288ed9328025 sys/arch/vax/vax/syscall.c
--- a/sys/arch/vax/vax/syscall.c        Sat Feb 11 22:09:47 2012 +0000
+++ b/sys/arch/vax/vax/syscall.c        Sat Feb 11 23:16:15 2012 +0000
@@ -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 @@
        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);
+}
diff -r 7c12a2e54c1e -r 288ed9328025 sys/arch/x86/x86/syscall.c
--- a/sys/arch/x86/x86/syscall.c        Sat Feb 11 22:09:47 2012 +0000
+++ b/sys/arch/x86/x86/syscall.c        Sat Feb 11 23:16:15 2012 +0000
@@ -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 @@
        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



Home | Main Index | Thread Index | Old Index