summaryrefslogtreecommitdiff
path: root/sys/compat/linux/linux_exec.c
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>1995-04-22 19:48:19 +0000
committerchristos <christos@NetBSD.org>1995-04-22 19:48:19 +0000
commit44eef7c28be90c7d49f628c88adb08ae84d1c5e3 (patch)
tree00771498308be72677e09c5baf02ca1df5ccdfa8 /sys/compat/linux/linux_exec.c
parent2a83f6028fb608f9bb8482048e7dfe4277548e3d (diff)
- added struct emul to all emulations.
- removed all setup functions. - added copyargs() functions where needed.
Diffstat (limited to 'sys/compat/linux/linux_exec.c')
-rw-r--r--sys/compat/linux/linux_exec.c90
1 files changed, 84 insertions, 6 deletions
diff --git a/sys/compat/linux/linux_exec.c b/sys/compat/linux/linux_exec.c
index 60911c44220..1afba4ef6c2 100644
--- a/sys/compat/linux/linux_exec.c
+++ b/sys/compat/linux/linux_exec.c
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_exec.c,v 1.3 1995/04/07 22:23:22 fvdl Exp $ */
+/* $NetBSD: linux_exec.c,v 1.4 1995/04/22 19:48:34 christos Exp $ */
/*
* Copyright (c) 1995 Frank van der Linden
@@ -56,12 +56,93 @@
#include <machine/cpu.h>
#include <machine/reg.h>
#include <machine/exec.h>
+#include <machine/linux_machdep.h>
#include <compat/linux/linux_types.h>
+#include <compat/linux/linux_syscall.h>
#include <compat/linux/linux_syscallargs.h>
#include <compat/linux/linux_util.h>
#include <compat/linux/linux_exec.h>
+static void *linux_copyargs __P((struct exec_package *, struct ps_strings *,
+ void *, void *));
+
+#define LINUX_AUX_ARGSIZ 2
+
+extern int linux_error[];
+extern struct sysent linux_sysent[];
+extern char *linux_syscallnames[];
+
+struct emul emul_linux = {
+ "linux",
+ linux_error,
+ linux_sendsig,
+ LINUX_SYS_syscall,
+ LINUX_SYS_MAXSYSCALL,
+ linux_sysent,
+ linux_syscallnames,
+ LINUX_AUX_ARGSIZ,
+ linux_copyargs,
+ setregs,
+ linux_sigcode,
+ linux_esigcode,
+};
+
+
+static void *
+linux_copyargs(pack, arginfo, stack, argp)
+ struct exec_package *pack;
+ struct ps_strings *arginfo;
+ void *stack;
+ void *argp;
+{
+ char **cpp = stack;
+ char **stk = stack;
+ char *dp, *sp;
+ size_t len;
+ void *nullp = NULL;
+ int argc = arginfo->ps_nargvstr;
+ int envc = arginfo->ps_nenvstr;
+
+ if (copyout(&argc, cpp++, sizeof(argc)))
+ return NULL;
+
+ /* leave room for envp and argv */
+ cpp += 2;
+ if (copyout(&cpp, &stk[1], sizeof (cpp)))
+ return NULL;
+
+ dp = (char *) (cpp + argc + envc + 2);
+ sp = argp;
+
+ /* XXX don't copy them out, remap them! */
+ arginfo->ps_argvstr = dp; /* remember location of argv for later */
+
+ for (; --argc >= 0; sp += len, dp += len)
+ if (copyout(&dp, cpp++, sizeof(dp)) ||
+ copyoutstr(sp, dp, ARG_MAX, &len))
+ return NULL;
+
+ if (copyout(&nullp, cpp++, sizeof(nullp)))
+ return NULL;
+
+ if (copyout(&cpp, &stk[2], sizeof (cpp)))
+ return NULL;
+
+ arginfo->ps_envstr = dp; /* remember location of envp for later */
+
+ for (; --envc >= 0; sp += len, dp += len)
+ if (copyout(&dp, cpp++, sizeof(dp)) ||
+ copyoutstr(sp, dp, ARG_MAX, &len))
+ return NULL;
+
+ if (copyout(&nullp, cpp++, sizeof(nullp)))
+ return NULL;
+
+ return cpp;
+}
+
+
int
exec_linux_aout_makecmds(p, epp)
struct proc *p;
@@ -92,11 +173,8 @@ exec_linux_aout_makecmds(p, epp)
error = exec_linux_aout_prep_omagic(p, epp);
break;
}
- if (error == 0) {
- epp->ep_sigcode = linux_sigcode;
- epp->ep_esigcode = linux_esigcode;
- epp->ep_emul = EMUL_LINUX;
- }
+ if (error == 0)
+ epp->ep_emul = &emul_linux;
return error;
}