diff options
author | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1998-02-22 01:08:00 +0000 |
---|---|---|
committer | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1998-02-22 01:08:00 +0000 |
commit | 3198f0ab31dac72a4422e72ec3b045b5eaa04797 (patch) | |
tree | 6cefa4857fe19f5278cfa40cf4aaba2f28830748 /sys/compat | |
parent | 8e13cb95000ebf76f3d6b9e351d5dd640a053b17 (diff) |
Remember OS tag when running Linux or SVR4 ELF files. KNF.
Diffstat (limited to 'sys/compat')
-rw-r--r-- | sys/compat/linux/linux_exec.c | 66 | ||||
-rw-r--r-- | sys/compat/linux/linux_exec.h | 6 | ||||
-rw-r--r-- | sys/compat/svr4/svr4_exec.c | 19 | ||||
-rw-r--r-- | sys/compat/svr4/svr4_exec.h | 6 |
4 files changed, 51 insertions, 46 deletions
diff --git a/sys/compat/linux/linux_exec.c b/sys/compat/linux/linux_exec.c index 1f05664cb2b..fcf005fd380 100644 --- a/sys/compat/linux/linux_exec.c +++ b/sys/compat/linux/linux_exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: linux_exec.c,v 1.5 1997/06/17 11:11:10 deraadt Exp $ */ +/* $OpenBSD: linux_exec.c,v 1.6 1998/02/22 01:07:56 niklas Exp $ */ /* $NetBSD: linux_exec.c,v 1.13 1996/04/05 00:01:10 christos Exp $ */ /* @@ -40,6 +40,7 @@ #include <sys/vnode.h> #include <sys/mount.h> #include <sys/exec_elf.h> +#include <sys/exec_olf.h> #include <sys/mman.h> #include <sys/syscallargs.h> @@ -127,14 +128,14 @@ linux_aout_copyargs(pack, arginfo, stack, argp) int envc = arginfo->ps_nenvstr; if (copyout(&argc, cpp++, sizeof(argc))) - return NULL; + return (NULL); /* leave room for envp and argv */ cpp += 2; if (copyout(&cpp, &stk[1], sizeof (cpp))) - return NULL; + return (NULL); - dp = (char *) (cpp + argc + envc + 2); + dp = (char *)(cpp + argc + envc + 2); sp = argp; /* XXX don't copy them out, remap them! */ @@ -143,25 +144,25 @@ linux_aout_copyargs(pack, arginfo, stack, argp) for (; --argc >= 0; sp += len, dp += len) if (copyout(&dp, cpp++, sizeof(dp)) || copyoutstr(sp, dp, ARG_MAX, &len)) - return NULL; + return (NULL); if (copyout(&nullp, cpp++, sizeof(nullp))) - return NULL; + return (NULL); if (copyout(&cpp, &stk[2], sizeof (cpp))) - return NULL; + return (NULL); arginfo->ps_envstr = cpp; /* 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; + return (NULL); if (copyout(&nullp, cpp++, sizeof(nullp))) - return NULL; + return (NULL); - return cpp; + return (cpp); } int @@ -196,7 +197,7 @@ exec_linux_aout_makecmds(p, epp) } if (error == 0) epp->ep_emul = &emul_linux_aout; - return error; + return (error); } /* @@ -233,7 +234,7 @@ exec_linux_aout_prep_zmagic(p, epp) epp->ep_daddr + execp->a_data, NULLVP, 0, VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); - return exec_setup_stack(p, epp); + return (exec_setup_stack(p, epp)); } /* @@ -272,7 +273,7 @@ exec_linux_aout_prep_nmagic(p, epp) NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, bsize, baddr, NULLVP, 0, VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); - return exec_setup_stack(p, epp); + return (exec_setup_stack(p, epp)); } /* @@ -316,7 +317,7 @@ exec_linux_aout_prep_omagic(p, epp) */ dsize = epp->ep_dsize + execp->a_text - roundup(execp->a_text, NBPG); epp->ep_dsize = (dsize > 0) ? dsize : 0; - return exec_setup_stack(p, epp); + return (exec_setup_stack(p, epp)); } int @@ -343,7 +344,7 @@ exec_linux_aout_prep_qmagic(p, epp) if (epp->ep_vp->v_flag & VTEXT) panic("exec: a VTEXT vnode has writecount != 0\n"); #endif - return ETXTBSY; + return (ETXTBSY); } epp->ep_vp->v_flag |= VTEXT; @@ -362,15 +363,16 @@ exec_linux_aout_prep_qmagic(p, epp) epp->ep_daddr + execp->a_data, NULLVP, 0, VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); - return exec_setup_stack(p, epp); + return (exec_setup_stack(p, epp)); } int -linux_elf_probe(p, epp, itp, pos) +linux_elf_probe(p, epp, itp, pos, os) struct proc *p; struct exec_package *epp; char *itp; u_long *pos; + u_int8_t *os; { char *bp; int error; @@ -378,14 +380,15 @@ linux_elf_probe(p, epp, itp, pos) if (itp[0]) { if ((error = emul_find(p, NULL, linux_emul_path, itp, &bp, 0))) - return error; + return (error); if ((error = copystr(bp, itp, MAXPATHLEN, &len))) - return error; + return (error); free(bp, M_TEMP); } epp->ep_emul = &emul_linux_elf; *pos = ELF32_NO_ADDR; - return 0; + *os = OOS_LINUX; + return (0); } /* @@ -428,7 +431,7 @@ linux_sys_uselib(p, v, retval) NDINIT(&ni, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); if ((error = namei(&ni))) - return error; + return (error); vp = ni.ni_vp; @@ -436,16 +439,16 @@ linux_sys_uselib(p, v, retval) 0, UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, &rem, p))) { vrele(vp); - return error; + return (error); } if (rem != 0) { vrele(vp); - return ENOEXEC; + return (ENOEXEC); } if (LINUX_N_MACHTYPE(&hdr) != LINUX_MID_MACHINE) - return ENOEXEC; + return (ENOEXEC); magic = LINUX_N_MAGIC(&hdr); taddr = hdr.a_entry & (~(NBPG - 1)); @@ -455,18 +458,17 @@ linux_sys_uselib(p, v, retval) if ((hdr.a_text != 0 || hdr.a_data != 0) && vp->v_writecount != 0) { vrele(vp); - return ETXTBSY; + return (ETXTBSY); } vp->v_flag |= VTEXT; vcset.evs_cnt = 0; vcset.evs_used = 0; - NEW_VMCMD(&vcset, - magic == ZMAGIC ? vmcmd_map_readvn : vmcmd_map_pagedvn, - hdr.a_text + hdr.a_data, taddr, - vp, LINUX_N_TXTOFF(hdr, magic), - VM_PROT_READ|VM_PROT_EXECUTE|VM_PROT_WRITE); + NEW_VMCMD( + &vcset, magic == ZMAGIC ? vmcmd_map_readvn : vmcmd_map_pagedvn, + hdr.a_text + hdr.a_data, taddr, vp, LINUX_N_TXTOFF(hdr, magic), + VM_PROT_READ|VM_PROT_EXECUTE|VM_PROT_WRITE); baddr = roundup(daddr + hdr.a_data, NBPG); bsize = daddr + dsize - baddr; @@ -486,7 +488,7 @@ linux_sys_uselib(p, v, retval) vrele(vp); - return error; + return (error); } /* @@ -514,5 +516,5 @@ linux_sys_execve(p, v, retval) SCARG(&ap, argp) = SCARG(uap, argp); SCARG(&ap, envp) = SCARG(uap, envp); - return sys_execve(p, &ap, retval); + return (sys_execve(p, &ap, retval)); } diff --git a/sys/compat/linux/linux_exec.h b/sys/compat/linux/linux_exec.h index 082f18741a7..a5e20e8d282 100644 --- a/sys/compat/linux/linux_exec.h +++ b/sys/compat/linux/linux_exec.h @@ -1,4 +1,4 @@ -/* $OpenBSD: linux_exec.h,v 1.2 1996/04/17 05:23:47 mickey Exp $ */ +/* $OpenBSD: linux_exec.h,v 1.3 1998/02/22 01:07:57 niklas Exp $ */ /* $NetBSD: linux_exec.h,v 1.5 1995/10/07 06:27:01 mycroft Exp $ */ /* @@ -69,7 +69,7 @@ int exec_linux_aout_makecmds __P((struct proc *, struct exec_package *)); int exec_linux_elf_makecmds __P((struct proc *, struct exec_package *)); -int linux_elf_probe __P((struct proc *p, struct exec_package *epp, char *itp, - u_long *pos)); +int linux_elf_probe __P((struct proc *, struct exec_package *, char *, + u_long *, u_int8_t *)); #endif /* !_LINUX_EXEC_H */ diff --git a/sys/compat/svr4/svr4_exec.c b/sys/compat/svr4/svr4_exec.c index e42f6d8053c..74accff8529 100644 --- a/sys/compat/svr4/svr4_exec.c +++ b/sys/compat/svr4/svr4_exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: svr4_exec.c,v 1.5 1996/09/13 17:09:53 niklas Exp $ */ +/* $OpenBSD: svr4_exec.c,v 1.6 1998/02/22 01:07:58 niklas Exp $ */ /* $NetBSD: svr4_exec.c,v 1.16 1995/10/14 20:24:20 christos Exp $ */ /* @@ -36,6 +36,7 @@ #include <sys/namei.h> #include <sys/vnode.h> #include <sys/exec_elf.h> +#include <sys/exec_olf.h> #include <sys/mman.h> #include <vm/vm.h> @@ -85,8 +86,8 @@ svr4_copyargs(pack, arginfo, stack, argp) { AuxInfo *a; - if (!(a = (AuxInfo *) elf_copyargs(pack, arginfo, stack, argp))) - return NULL; + if (!(a = (AuxInfo *)elf_copyargs(pack, arginfo, stack, argp))) + return (NULL); #ifdef SVR4_COMPAT_SOLARIS2 if (pack->ep_emul_arg) { a->au_id = AUX_sun_uid; @@ -106,15 +107,16 @@ svr4_copyargs(pack, arginfo, stack, argp) a++; } #endif - return a; + return (a); } int -svr4_elf_probe(p, epp, itp, pos) +svr4_elf_probe(p, epp, itp, pos, os) struct proc *p; struct exec_package *epp; char *itp; u_long *pos; + u_int8_t *os; { char *bp; int error; @@ -122,12 +124,13 @@ svr4_elf_probe(p, epp, itp, pos) if (itp[0]) { if ((error = emul_find(p, NULL, svr4_emul_path, itp, &bp, 0))) - return error; + return (error); if ((error = copystr(bp, itp, MAXPATHLEN, &len))) - return error; + return (error); free(bp, M_TEMP); } epp->ep_emul = &emul_svr4; *pos = SVR4_INTERP_ADDR; - return 0; + *os = OOS_SVR4; + return (0); } diff --git a/sys/compat/svr4/svr4_exec.h b/sys/compat/svr4/svr4_exec.h index 5a7d4cab653..0ccfb6d2acd 100644 --- a/sys/compat/svr4/svr4_exec.h +++ b/sys/compat/svr4/svr4_exec.h @@ -1,4 +1,4 @@ -/* $OpenBSD: svr4_exec.h,v 1.2 1996/08/02 20:35:37 niklas Exp $ */ +/* $OpenBSD: svr4_exec.h,v 1.3 1998/02/22 01:07:59 niklas Exp $ */ /* $NetBSD: svr4_exec.h,v 1.7 1995/07/02 06:16:06 christos Exp $ */ /* @@ -62,7 +62,7 @@ # define SVR4_INTERP_ADDR 0 #endif -int svr4_elf_probe __P((struct proc *p, struct exec_package *, char *, - u_long *pos)); +int svr4_elf_probe __P((struct proc *, struct exec_package *, char *, u_long *, + u_int8_t *)); #endif /* !_SVR4_EXEC_H_ */ |