Source-Changes-HG archive

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

[src/trunk]: src/sys/compat/linux Emulate the Linux clone(2) system call.



details:   https://anonhg.NetBSD.org/src/rev/b2bae4520de5
branches:  trunk
changeset: 472954:b2bae4520de5
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Thu May 13 23:42:34 1999 +0000

description:
Emulate the Linux clone(2) system call.

diffstat:

 sys/compat/linux/arch/alpha/syscalls.master |   4 +-
 sys/compat/linux/arch/i386/syscalls.master  |   4 +-
 sys/compat/linux/arch/m68k/syscalls.master  |   4 +-
 sys/compat/linux/common/linux_misc.c        |  50 +++++++++++++++++++++++++++-
 4 files changed, 53 insertions(+), 9 deletions(-)

diffs (127 lines):

diff -r cea3870fc1a4 -r b2bae4520de5 sys/compat/linux/arch/alpha/syscalls.master
--- a/sys/compat/linux/arch/alpha/syscalls.master       Thu May 13 23:37:19 1999 +0000
+++ b/sys/compat/linux/arch/alpha/syscalls.master       Thu May 13 23:42:34 1999 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.9 1999/03/30 07:34:49 tron Exp $
+       $NetBSD: syscalls.master,v 1.10 1999/05/13 23:42:34 thorpej Exp $
 
 ;      @(#)syscalls.master     8.1 (Berkeley) 7/19/93
 
@@ -459,7 +459,7 @@
 309    UNIMPL          get_kernel_syms
 310    UNIMPL          syslog
 311    NOARGS          { int sys_reboot(int opt); }
-312    UNIMPL          clone
+312    UNIMPL          { int linux_sys_clone(int flags, void *stack); }
 ; XXX XAX does alpha linux really have a.out exec?
 #ifdef EXEC_AOUT
 313    STD             { int linux_sys_uselib(char *path); }
diff -r cea3870fc1a4 -r b2bae4520de5 sys/compat/linux/arch/i386/syscalls.master
--- a/sys/compat/linux/arch/i386/syscalls.master        Thu May 13 23:37:19 1999 +0000
+++ b/sys/compat/linux/arch/i386/syscalls.master        Thu May 13 23:42:34 1999 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.32 1999/03/30 02:22:49 abs Exp $
+       $NetBSD: syscalls.master,v 1.33 1999/05/13 23:42:34 thorpej Exp $
 
 ;      @(#)syscalls.master     8.1 (Berkeley) 7/19/93
 
@@ -204,7 +204,7 @@
                            caddr_t ptr); }
 118    NOARGS          { int sys_fsync(int fd); }
 119    STD             { int linux_sys_sigreturn(struct linux_sigcontext *scp); }
-120    UNIMPL          clone
+120    STD             { int linux_sys_clone(int flags, void *stack); }
 121    NOARGS          { int compat_09_sys_setdomainname(char *name, \
                            int len); }
 122    STD             { int linux_sys_uname(struct linux_utsname *up); }
diff -r cea3870fc1a4 -r b2bae4520de5 sys/compat/linux/arch/m68k/syscalls.master
--- a/sys/compat/linux/arch/m68k/syscalls.master        Thu May 13 23:37:19 1999 +0000
+++ b/sys/compat/linux/arch/m68k/syscalls.master        Thu May 13 23:42:34 1999 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.5 1999/03/30 07:29:05 tron Exp $
+       $NetBSD: syscalls.master,v 1.6 1999/05/13 23:42:34 thorpej Exp $
 
 ;      @(#)syscalls.master     8.1 (Berkeley) 7/19/93
 
@@ -226,7 +226,7 @@
                            caddr_t ptr); }
 118    NOARGS          { int sys_fsync(int fd); }
 119    STD             { int linux_sys_sigreturn(void); }
-120    UNIMPL          clone
+120    STD             { int linux_sys_clone(int flags, void *stack); }
 #if !defined(_KERNEL) || defined(COMPAT_09)
 121    NOARGS          { int compat_09_sys_setdomainname(char *name, \
                            int len); }
diff -r cea3870fc1a4 -r b2bae4520de5 sys/compat/linux/common/linux_misc.c
--- a/sys/compat/linux/common/linux_misc.c      Thu May 13 23:37:19 1999 +0000
+++ b/sys/compat/linux/common/linux_misc.c      Thu May 13 23:42:34 1999 +0000
@@ -1,11 +1,12 @@
-/*     $NetBSD: linux_misc.c,v 1.55 1999/05/13 01:00:50 thorpej Exp $  */
+/*     $NetBSD: linux_misc.c,v 1.56 1999/05/13 23:42:34 thorpej Exp $  */
 
 /*-
- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
+ * Copyright (c) 1995, 1998, 1999 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
- * by Frank van der Linden and Eric Haszlakiewicz.
+ * by Frank van der Linden and Eric Haszlakiewicz; by Jason R. Thorpe
+ * of the Numerical Aerospace Simulation Facility, NASA Ames Research Center.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -103,6 +104,7 @@
 #include <compat/linux/common/linux_dirent.h>
 #include <compat/linux/common/linux_util.h>
 #include <compat/linux/common/linux_misc.h>
+#include <compat/linux/common/linux_sched.h>
 
 
 /* Local linux_misc.c functions: */
@@ -914,3 +916,45 @@
 
        return sys___sysctl(p, &bsa, retval);
 }
+
+int
+linux_sys_clone(p, v, retval)
+       struct proc *p;
+       void *v;
+       register_t *retval;
+{
+       struct linux_sys_clone_args /* {
+               syscallarg(int) flags;
+               syscallarg(void *) stack;
+       } */ *uap = v;
+       int flags, sig;
+
+       /*
+        * We don't support the Linux CLONE_PID or CLONE_PTRACE flags.
+        */
+       if (SCARG(uap, flags) & (LINUX_CLONE_PID|LINUX_CLONE_PTRACE))
+               return (EINVAL);
+
+       flags = 0;
+
+       if (SCARG(uap, flags) & LINUX_CLONE_VM)
+               flags |= FORK_SHAREVM;
+       if (SCARG(uap, flags) & LINUX_CLONE_FS)
+               flags |= FORK_SHARECWD;
+       if (SCARG(uap, flags) & LINUX_CLONE_FILES)
+               flags |= FORK_SHAREFILES;
+       if (SCARG(uap, flags) & LINUX_CLONE_SIGHAND)
+               flags |= FORK_SHARESIGS;
+       if (SCARG(uap, flags) & LINUX_CLONE_VFORK)
+               flags |= FORK_PPWAIT;
+
+       sig = SCARG(uap, flags) & LINUX_CLONE_CSIGNAL;
+
+       /*
+        * Note that Linux does not provide a portable way of specifying
+        * the stack area; the caller must know if the stack grows up
+        * or down.  So, we pass a stack size of 0, so that the code
+        * that makes this adjustment is a noop.
+        */
+       return (fork1(p, flags, sig, SCARG(uap, stack), 0, retval, NULL));
+}



Home | Main Index | Thread Index | Old Index