Home | History | Annotate | Line # | Download | only in common
linux_exec.c revision 1.33
      1 /*	$NetBSD: linux_exec.c,v 1.33 1998/10/04 00:02:31 fvdl Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1994, 1995, 1998 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Christos Zoulas, Frank van der Linden, Eric Haszlakiewicz and
      9  * Thor Lancelot Simon.
     10  *
     11  * Redistribution and use in source and binary forms, with or without
     12  * modification, are permitted provided that the following conditions
     13  * are met:
     14  * 1. Redistributions of source code must retain the above copyright
     15  *    notice, this list of conditions and the following disclaimer.
     16  * 2. Redistributions in binary form must reproduce the above copyright
     17  *    notice, this list of conditions and the following disclaimer in the
     18  *    documentation and/or other materials provided with the distribution.
     19  * 3. All advertising materials mentioning features or use of this software
     20  *    must display the following acknowledgement:
     21  *        This product includes software developed by the NetBSD
     22  *        Foundation, Inc. and its contributors.
     23  * 4. Neither the name of The NetBSD Foundation nor the names of its
     24  *    contributors may be used to endorse or promote products derived
     25  *    from this software without specific prior written permission.
     26  *
     27  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     28  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     29  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     30  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     31  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     37  * POSSIBILITY OF SUCH DAMAGE.
     38  */
     39 
     40 #include <sys/param.h>
     41 #include <sys/systm.h>
     42 #include <sys/kernel.h>
     43 #include <sys/proc.h>
     44 #include <sys/malloc.h>
     45 #include <sys/namei.h>
     46 #include <sys/vnode.h>
     47 #include <sys/mount.h>
     48 #include <sys/exec.h>
     49 #include <sys/exec_elf.h>
     50 
     51 #include <sys/mman.h>
     52 #include <sys/syscallargs.h>
     53 
     54 #include <vm/vm.h>
     55 #include <vm/vm_param.h>
     56 #include <vm/vm_map.h>
     57 
     58 #include <machine/cpu.h>
     59 #include <machine/reg.h>
     60 
     61 #include <compat/linux/common/linux_types.h>
     62 #include <compat/linux/common/linux_signal.h>
     63 #include <compat/linux/common/linux_siginfo.h>
     64 #include <compat/linux/common/linux_util.h>
     65 #include <compat/linux/common/linux_exec.h>
     66 #include <compat/linux/common/linux_machdep.h>
     67 
     68 #include <compat/linux/linux_syscallargs.h>
     69 #include <compat/linux/linux_syscall.h>
     70 
     71 
     72 const char linux_emul_path[] = "/emul/linux";
     73 
     74 /*
     75  * Execve(2). Just check the alternate emulation path, and pass it on
     76  * to the NetBSD execve().
     77  */
     78 int
     79 linux_sys_execve(p, v, retval)
     80 	struct proc *p;
     81 	void *v;
     82 	register_t *retval;
     83 {
     84 	struct linux_sys_execve_args /* {
     85 		syscallarg(char *) path;
     86 		syscallarg(char **) argv;
     87 		syscallarg(char **) envp;
     88 	} */ *uap = v;
     89 	struct sys_execve_args ap;
     90 	caddr_t sg;
     91 
     92 	sg = stackgap_init(p->p_emul);
     93 	LINUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
     94 
     95 	SCARG(&ap, path) = SCARG(uap, path);
     96 	SCARG(&ap, argp) = SCARG(uap, argp);
     97 	SCARG(&ap, envp) = SCARG(uap, envp);
     98 
     99 	return sys_execve(p, &ap, retval);
    100 }
    101