Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/compat/netbsd32 split up netbsd32_netbsd.c into 9 new fi...
details: https://anonhg.NetBSD.org/src/rev/6685efc9c47c
branches: trunk
changeset: 503540:6685efc9c47c
user: mrg <mrg%NetBSD.org@localhost>
date: Thu Feb 08 13:19:33 2001 +0000
description:
split up netbsd32_netbsd.c into 9 new files, leaving only those syscalls that
have no special interpretations besides simple syscall args conversion.
diffstat:
sys/compat/netbsd32/files.netbsd32 | 11 +-
sys/compat/netbsd32/netbsd32_execve.c | 491 +++++
sys/compat/netbsd32/netbsd32_fs.c | 799 ++++++++
sys/compat/netbsd32/netbsd32_ipc.c | 503 +++++
sys/compat/netbsd32/netbsd32_netbsd.c | 3235 +--------------------------------
sys/compat/netbsd32/netbsd32_select.c | 159 +
sys/compat/netbsd32/netbsd32_signal.c | 160 +
sys/compat/netbsd32/netbsd32_socket.c | 389 +++
sys/compat/netbsd32/netbsd32_sysctl.c | 266 ++
sys/compat/netbsd32/netbsd32_time.c | 644 ++++++
sys/compat/netbsd32/netbsd32_wait.c | 204 ++
11 files changed, 3631 insertions(+), 3230 deletions(-)
diffs (truncated from 7112 to 300 lines):
diff -r 253c0e2ed875 -r 6685efc9c47c sys/compat/netbsd32/files.netbsd32
--- a/sys/compat/netbsd32/files.netbsd32 Thu Feb 08 13:11:31 2001 +0000
+++ b/sys/compat/netbsd32/files.netbsd32 Thu Feb 08 13:19:33 2001 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.netbsd32,v 1.8 2001/02/07 13:13:01 mrg Exp $
+# $NetBSD: files.netbsd32,v 1.9 2001/02/08 13:19:33 mrg Exp $
#
# config file description for machine-independent netbsd32 compat code.
# included by ports that need it.
@@ -9,7 +9,16 @@
file compat/netbsd32/netbsd32_exec_elf32.c compat_netbsd32 & exec_elf32
file compat/netbsd32/netbsd32_exec_aout.c compat_netbsd32 & exec_aout
file compat/netbsd32/netbsd32_netbsd.c compat_netbsd32
+file compat/netbsd32/netbsd32_execve.c compat_netbsd32
+file compat/netbsd32/netbsd32_fs.c compat_netbsd32
file compat/netbsd32/netbsd32_ioctl.c compat_netbsd32
+file compat/netbsd32/netbsd32_ipc.c compat_netbsd32
+file compat/netbsd32/netbsd32_select.c compat_netbsd32
+file compat/netbsd32/netbsd32_signal.c compat_netbsd32
+file compat/netbsd32/netbsd32_socket.c compat_netbsd32
+file compat/netbsd32/netbsd32_sysctl.c compat_netbsd32
+file compat/netbsd32/netbsd32_time.c compat_netbsd32
+file compat/netbsd32/netbsd32_wait.c compat_netbsd32
file compat/netbsd32/netbsd32_sysent.c compat_netbsd32
file compat/netbsd32/netbsd32_compat_09.c compat_netbsd32 & (compat_09 | compat_sunos)
file compat/netbsd32/netbsd32_compat_10.c compat_netbsd32 & compat_10
diff -r 253c0e2ed875 -r 6685efc9c47c sys/compat/netbsd32/netbsd32_execve.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/netbsd32/netbsd32_execve.c Thu Feb 08 13:19:33 2001 +0000
@@ -0,0 +1,491 @@
+/* $NetBSD: netbsd32_execve.c,v 1.1 2001/02/08 13:19:33 mrg Exp $ */
+
+/*
+ * Copyright (c) 1998, 2001 Matthew R. Green
+ * 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.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ */
+
+#if defined(_KERNEL) && !defined(_LKM)
+#include "opt_ktrace.h"
+#endif
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/malloc.h>
+#include <sys/mount.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+#include <sys/ktrace.h>
+#include <sys/vnode.h>
+#include <sys/file.h>
+#include <sys/filedesc.h>
+#include <sys/namei.h>
+
+#include <uvm/uvm_extern.h>
+
+#include <sys/syscallargs.h>
+#include <sys/proc.h>
+#include <sys/acct.h>
+#include <sys/exec.h>
+
+#include <compat/netbsd32/netbsd32.h>
+#include <compat/netbsd32/netbsd32_syscall.h>
+#include <compat/netbsd32/netbsd32_syscallargs.h>
+
+/* this is provided by kern/kern_exec.c */
+extern int exec_maxhdrsz;
+extern struct lock exec_lock;
+
+/*
+ * Need to completly reimplement this syscall due to argument copying.
+ */
+/* ARGSUSED */
+int
+netbsd32_execve(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct netbsd32_execve_args /* {
+ syscallarg(const netbsd32_charp) path;
+ syscallarg(netbsd32_charpp) argp;
+ syscallarg(netbsd32_charpp) envp;
+ } */ *uap = v;
+ struct sys_execve_args ua;
+ caddr_t sg;
+
+ NETBSD32TOP_UAP(path, const char);
+ NETBSD32TOP_UAP(argp, char *);
+ NETBSD32TOP_UAP(envp, char *);
+ sg = stackgap_init(p->p_emul);
+ CHECK_ALT_EXIST(p, &sg, SCARG(&ua, path));
+
+ return netbsd32_execve2(p, &ua, retval);
+}
+
+int
+netbsd32_execve2(p, uap, retval)
+ struct proc *p;
+ struct sys_execve_args *uap;
+ register_t *retval;
+{
+ /* Function args */
+ int error, i;
+ struct exec_package pack;
+ struct nameidata nid;
+ struct vattr attr;
+ struct ucred *cred = p->p_ucred;
+ char *argp;
+ netbsd32_charp const *cpp;
+ char *dp;
+ netbsd32_charp sp;
+ long argc, envc;
+ size_t len;
+ char *stack;
+ struct ps_strings arginfo;
+ struct vmspace *vm;
+ char **tmpfap;
+ int szsigcode;
+ struct exec_vmcmd *base_vcp = NULL;
+
+ /*
+ * Init the namei data to point the file user's program name.
+ * This is done here rather than in check_exec(), so that it's
+ * possible to override this settings if any of makecmd/probe
+ * functions call check_exec() recursively - for example,
+ * see exec_script_makecmds().
+ */
+ NDINIT(&nid, LOOKUP, NOFOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
+
+ /*
+ * initialize the fields of the exec package.
+ */
+ pack.ep_name = SCARG(uap, path);
+ pack.ep_hdr = malloc(exec_maxhdrsz, M_EXEC, M_WAITOK);
+ pack.ep_hdrlen = exec_maxhdrsz;
+ pack.ep_hdrvalid = 0;
+ pack.ep_ndp = &nid;
+ pack.ep_emul_arg = NULL;
+ pack.ep_vmcmds.evs_cnt = 0;
+ pack.ep_vmcmds.evs_used = 0;
+ pack.ep_vap = &attr;
+ pack.ep_flags = 0;
+
+ lockmgr(&exec_lock, LK_SHARED, NULL);
+
+ /* see if we can run it. */
+ if ((error = check_exec(p, &pack)) != 0)
+ goto freehdr;
+
+ /* XXX -- THE FOLLOWING SECTION NEEDS MAJOR CLEANUP */
+
+ /* allocate an argument buffer */
+ argp = (char *) uvm_km_valloc_wait(exec_map, NCARGS);
+#ifdef DIAGNOSTIC
+ if (argp == (vaddr_t) 0)
+ panic("netbsd32_execve: argp == NULL");
+#endif
+ dp = argp;
+ argc = 0;
+
+ /* copy the fake args list, if there's one, freeing it as we go */
+ if (pack.ep_flags & EXEC_HASARGL) {
+ tmpfap = pack.ep_fa;
+ while (*tmpfap != NULL) {
+ char *cp;
+
+ cp = *tmpfap;
+ while (*cp)
+ *dp++ = *cp++;
+ dp++;
+
+ FREE(*tmpfap, M_EXEC);
+ tmpfap++; argc++;
+ }
+ FREE(pack.ep_fa, M_EXEC);
+ pack.ep_flags &= ~EXEC_HASARGL;
+ }
+
+ /* Now get argv & environment */
+ if (!(cpp = (netbsd32_charp *)SCARG(uap, argp))) {
+ error = EINVAL;
+ goto bad;
+ }
+
+ if (pack.ep_flags & EXEC_SKIPARG)
+ cpp++;
+
+ while (1) {
+ len = argp + ARG_MAX - dp;
+ if ((error = copyin(cpp, &sp, sizeof(sp))) != 0)
+ goto bad;
+ if (!sp)
+ break;
+ if ((error = copyinstr((char *)(u_long)sp, dp,
+ len, &len)) != 0) {
+ if (error == ENAMETOOLONG)
+ error = E2BIG;
+ goto bad;
+ }
+ dp += len;
+ cpp++;
+ argc++;
+ }
+
+ envc = 0;
+ /* environment need not be there */
+ if ((cpp = (netbsd32_charp *)SCARG(uap, envp)) != NULL ) {
+ while (1) {
+ len = argp + ARG_MAX - dp;
+ if ((error = copyin(cpp, &sp, sizeof(sp))) != 0)
+ goto bad;
+ if (!sp)
+ break;
+ if ((error = copyinstr((char *)(u_long)sp,
+ dp, len, &len)) != 0) {
+ if (error == ENAMETOOLONG)
+ error = E2BIG;
+ goto bad;
+ }
+ dp += len;
+ cpp++;
+ envc++;
+ }
+ }
+
+ dp = (char *) ALIGN(dp);
+
+ szsigcode = pack.ep_es->es_emul->e_esigcode -
+ pack.ep_es->es_emul->e_sigcode;
+
+ /* Now check if args & environ fit into new stack */
+ if (pack.ep_flags & EXEC_32)
+ len = ((argc + envc + 2 + pack.ep_es->es_arglen) *
+ sizeof(int) + sizeof(int) + dp + STACKGAPLEN +
+ szsigcode + sizeof(struct ps_strings)) - argp;
+ else
+ len = ((argc + envc + 2 + pack.ep_es->es_arglen) *
+ sizeof(char *) + sizeof(int) + dp + STACKGAPLEN +
+ szsigcode + sizeof(struct ps_strings)) - argp;
+
+ len = ALIGN(len); /* make the stack "safely" aligned */
+
+ if (len > pack.ep_ssize) { /* in effect, compare to initial limit */
+ error = ENOMEM;
+ goto bad;
+ }
+
+ /* adjust "active stack depth" for process VSZ */
+ pack.ep_ssize = len; /* maybe should go elsewhere, but... */
+
+ /*
+ * Do whatever is necessary to prepare the address space
+ * for remapping. Note that this might replace the current
+ * vmspace with another!
+ */
+ uvmspace_exec(p, VM_MIN_ADDRESS, (vaddr_t)pack.ep_minsaddr);
+
+ /* Now map address space */
+ vm = p->p_vmspace;
+ vm->vm_taddr = (char *) pack.ep_taddr;
+ vm->vm_tsize = btoc(pack.ep_tsize);
+ vm->vm_daddr = (char *) pack.ep_daddr;
+ vm->vm_dsize = btoc(pack.ep_dsize);
+ vm->vm_ssize = btoc(pack.ep_ssize);
+ vm->vm_maxsaddr = (char *) pack.ep_maxsaddr;
+ vm->vm_minsaddr = (char *) pack.ep_minsaddr;
+
+ /* create the new process's VM space by running the vmcmds */
+#ifdef DIAGNOSTIC
+ if (pack.ep_vmcmds.evs_used == 0)
+ panic("netbsd32_execve: no vmcmds");
+#endif
+ for (i = 0; i < pack.ep_vmcmds.evs_used && !error; i++) {
+ struct exec_vmcmd *vcp;
+
+ vcp = &pack.ep_vmcmds.evs_cmds[i];
+ if (vcp->ev_flags & VMCMD_RELATIVE) {
Home |
Main Index |
Thread Index |
Old Index