[BACK]Return to svr4_exec.c CVS log [TXT][DIR] Up to [local] / sys / compat / svr4

Annotation of sys/compat/svr4/svr4_exec.c, Revision 1.1

1.1     ! nbrk        1: /*     $OpenBSD: svr4_exec.c,v 1.15 2006/01/19 17:54:56 mickey Exp $    */
        !             2: /*     $NetBSD: svr4_exec.c,v 1.16 1995/10/14 20:24:20 christos Exp $   */
        !             3:
        !             4: /*
        !             5:  * Copyright (c) 1994 Christos Zoulas
        !             6:  * All rights reserved.
        !             7:  *
        !             8:  * Redistribution and use in source and binary forms, with or without
        !             9:  * modification, are permitted provided that the following conditions
        !            10:  * are met:
        !            11:  * 1. Redistributions of source code must retain the above copyright
        !            12:  *    notice, this list of conditions and the following disclaimer.
        !            13:  * 2. Redistributions in binary form must reproduce the above copyright
        !            14:  *    notice, this list of conditions and the following disclaimer in the
        !            15:  *    documentation and/or other materials provided with the distribution.
        !            16:  * 3. The name of the author may not be used to endorse or promote products
        !            17:  *    derived from this software without specific prior written permission
        !            18:  *
        !            19:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
        !            20:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
        !            21:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
        !            22:  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
        !            23:  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
        !            24:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
        !            25:  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
        !            26:  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
        !            27:  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
        !            28:  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        !            29:  */
        !            30:
        !            31: #include <sys/param.h>
        !            32: #include <sys/systm.h>
        !            33: #include <sys/kernel.h>
        !            34: #include <sys/proc.h>
        !            35: #include <sys/malloc.h>
        !            36: #include <sys/namei.h>
        !            37: #include <sys/vnode.h>
        !            38: #include <sys/exec.h>
        !            39: #include <sys/exec_elf.h>
        !            40: #include <sys/exec_olf.h>
        !            41:
        !            42: #include <sys/mman.h>
        !            43: #include <uvm/uvm_extern.h>
        !            44:
        !            45: #include <machine/cpu.h>
        !            46: #include <machine/reg.h>
        !            47: #include <machine/svr4_machdep.h>
        !            48:
        !            49: #include <compat/svr4/svr4_util.h>
        !            50: #include <compat/svr4/svr4_syscall.h>
        !            51: #include <compat/svr4/svr4_exec.h>
        !            52: #include <compat/svr4/svr4_errno.h>
        !            53:
        !            54: static void *svr4_copyargs(struct exec_package *, struct ps_strings *,
        !            55:                               void *, void *);
        !            56:
        !            57: const char svr4_emul_path[] = "/emul/svr4";
        !            58: extern char svr4_sigcode[], svr4_esigcode[];
        !            59: extern struct sysent svr4_sysent[];
        !            60: #ifdef SYSCALL_DEBUG
        !            61: extern char *svr4_syscallnames[];
        !            62: #endif
        !            63:
        !            64: struct emul emul_svr4 = {
        !            65:        "svr4",
        !            66:        native_to_svr4_errno,
        !            67:        svr4_sendsig,
        !            68:        SVR4_SYS_syscall,
        !            69:        SVR4_SYS_MAXSYSCALL,
        !            70:        svr4_sysent,
        !            71: #ifdef SYSCALL_DEBUG
        !            72:        svr4_syscallnames,
        !            73: #else
        !            74:        NULL,
        !            75: #endif
        !            76:        SVR4_AUX_ARGSIZ,
        !            77:        svr4_copyargs,
        !            78:        setregs,
        !            79:        exec_elf32_fixup,
        !            80:        svr4_sigcode,
        !            81:        svr4_esigcode,
        !            82: };
        !            83:
        !            84: static void *
        !            85: svr4_copyargs(pack, arginfo, stack, argp)
        !            86:        struct exec_package *pack;
        !            87:        struct ps_strings *arginfo;
        !            88:        void *stack;
        !            89:        void *argp;
        !            90: {
        !            91:        AuxInfo *a;
        !            92:
        !            93:        if (!(a = (AuxInfo *)elf32_copyargs(pack, arginfo, stack, argp)))
        !            94:                return (NULL);
        !            95: #ifdef SVR4_COMPAT_SOLARIS2
        !            96:        if (pack->ep_emul_arg) {
        !            97:                a->au_id = AUX_sun_uid;
        !            98:                a->au_v = p->p_ucred->cr_uid;
        !            99:                a++;
        !           100:
        !           101:                a->au_id = AUX_sun_ruid;
        !           102:                a->au_v = p->p_cred->ruid;
        !           103:                a++;
        !           104:
        !           105:                a->au_id = AUX_sun_gid;
        !           106:                a->au_v = p->p_ucred->cr_gid;
        !           107:                a++;
        !           108:
        !           109:                a->au_id = AUX_sun_rgid;
        !           110:                a->au_v = p->p_cred->rgid;
        !           111:                a++;
        !           112:        }
        !           113: #endif
        !           114:        return (a);
        !           115: }
        !           116:
        !           117: int
        !           118: svr4_elf_probe(p, epp, itp, pos, os)
        !           119:        struct proc *p;
        !           120:        struct exec_package *epp;
        !           121:        char *itp;
        !           122:        u_long *pos;
        !           123:        u_int8_t *os;
        !           124: {
        !           125:        char *bp;
        !           126:        int error;
        !           127:        size_t len;
        !           128:
        !           129:        if (itp) {
        !           130:                if ((error = emul_find(p, NULL, svr4_emul_path, itp, &bp, 0)))
        !           131:                        return (error);
        !           132:                if ((error = copystr(bp, itp, MAXPATHLEN, &len)))
        !           133:                        return (error);
        !           134:                free(bp, M_TEMP);
        !           135:        }
        !           136:        epp->ep_emul = &emul_svr4;
        !           137:        *pos = SVR4_INTERP_ADDR;
        !           138:        if (*os == OOS_NULL)
        !           139:                *os = OOS_SVR4;
        !           140:        return (0);
        !           141: }

CVSweb