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

Annotation of sys/compat/osf1/osf1_signal.c, Revision 1.1

1.1     ! nbrk        1: /*     $OpenBSD: osf1_signal.c,v 1.9 2000/08/04 15:47:55 ericj Exp $   */
        !             2: /*     $NetBSD: osf1_signal.c,v 1.15 1999/05/05 00:57:43 cgd Exp $     */
        !             3:
        !             4: /*
        !             5:  * Copyright (c) 1999 Christopher G. Demetriou.  All rights reserved.
        !             6:  *
        !             7:  * Redistribution and use in source and binary forms, with or without
        !             8:  * modification, are permitted provided that the following conditions
        !             9:  * are met:
        !            10:  * 1. Redistributions of source code must retain the above copyright
        !            11:  *    notice, this list of conditions and the following disclaimer.
        !            12:  * 2. Redistributions in binary form must reproduce the above copyright
        !            13:  *    notice, this list of conditions and the following disclaimer in the
        !            14:  *    documentation and/or other materials provided with the distribution.
        !            15:  * 3. All advertising materials mentioning features or use of this software
        !            16:  *    must display the following acknowledgement:
        !            17:  *      This product includes software developed by Christopher G. Demetriou
        !            18:  *     for the NetBSD Project.
        !            19:  * 4. The name of the author may not be used to endorse or promote products
        !            20:  *    derived from this software without specific prior written permission
        !            21:  *
        !            22:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
        !            23:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
        !            24:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
        !            25:  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
        !            26:  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
        !            27:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
        !            28:  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
        !            29:  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
        !            30:  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
        !            31:  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        !            32:  */
        !            33:
        !            34: #include <sys/param.h>
        !            35: #include <sys/systm.h>
        !            36: #include <sys/namei.h>
        !            37: #include <sys/proc.h>
        !            38: #include <sys/filedesc.h>
        !            39: #include <sys/ioctl.h>
        !            40: #include <sys/mount.h>
        !            41: #include <sys/kernel.h>
        !            42: #include <sys/signal.h>
        !            43: #include <sys/signalvar.h>
        !            44: #include <sys/malloc.h>
        !            45:
        !            46: #include <sys/syscallargs.h>
        !            47:
        !            48: #include <compat/osf1/osf1.h>
        !            49: #include <compat/osf1/osf1_signal.h>
        !            50: #include <compat/osf1/osf1_syscallargs.h>
        !            51: #include <compat/osf1/osf1_util.h>
        !            52: #include <compat/osf1/osf1_cvt.h>
        !            53:
        !            54: #if 0
        !            55: int
        !            56: osf1_sys_kill(p, v, retval)
        !            57:        struct proc *p;
        !            58:        void *v;
        !            59:        register_t *retval;
        !            60: {
        !            61:        struct osf1_sys_kill_args *uap = v;
        !            62:        struct sys_kill_args ka;
        !            63:
        !            64:        SCARG(&ka, pid) = SCARG(uap, pid);
        !            65:        SCARG(&ka, signum) = osf1_signal_xlist[SCARG(uap, signum)];
        !            66:        return sys_kill(p, &ka, retval);
        !            67: }
        !            68: #endif
        !            69:
        !            70: int
        !            71: osf1_sys_sigaction(p, v, retval)
        !            72:        struct proc *p;
        !            73:        void *v;
        !            74:        register_t *retval;
        !            75: {
        !            76:        struct osf1_sys_sigaction_args *uap = v;
        !            77:        struct osf1_sigaction *nosa, *oosa, tmposa;
        !            78:        struct sigaction *nbsa, *obsa, tmpbsa;
        !            79:        struct sys_sigaction_args sa;
        !            80:        caddr_t sg;
        !            81:        int error;
        !            82:
        !            83:        sg = stackgap_init(p->p_emul);
        !            84:        nosa = SCARG(uap, nsa);
        !            85:        oosa = SCARG(uap, osa);
        !            86:
        !            87:        if (oosa != NULL)
        !            88:                obsa = stackgap_alloc(&sg, sizeof(struct sigaction));
        !            89:        else
        !            90:                obsa = NULL;
        !            91:
        !            92:        if (nosa != NULL) {
        !            93:                nbsa = stackgap_alloc(&sg, sizeof(struct sigaction));
        !            94:                if ((error = copyin(nosa, &tmposa, sizeof(tmposa))) != 0)
        !            95:                        return error;
        !            96:                osf1_cvt_sigaction_to_native(&tmposa, &tmpbsa);
        !            97:                if ((error = copyout(&tmpbsa, nbsa, sizeof(tmpbsa))) != 0)
        !            98:                        return error;
        !            99:        } else
        !           100:                nbsa = NULL;
        !           101:
        !           102:        SCARG(&sa, signum) = osf1_signal_xlist[SCARG(uap, signum)];
        !           103:        SCARG(&sa, nsa) = nbsa;
        !           104:        SCARG(&sa, osa) = obsa;
        !           105:
        !           106:        /* XXX */
        !           107:        if ((error = sys_sigaction(p, &sa, retval)) != 0)
        !           108:                return error;
        !           109:
        !           110:        if (oosa != NULL) {
        !           111:                if ((error = copyin(obsa, &tmpbsa, sizeof(tmpbsa))) != 0)
        !           112:                        return error;
        !           113:                osf1_cvt_sigaction_from_native(&tmpbsa, &tmposa);
        !           114:                if ((error = copyout(&tmposa, oosa, sizeof(tmposa))) != 0)
        !           115:                        return error;
        !           116:        }
        !           117:
        !           118:        return 0;
        !           119: }
        !           120:
        !           121: int
        !           122: osf1_sys_sigaltstack(p, v, retval)
        !           123:        struct proc *p;
        !           124:        void *v;
        !           125:        register_t *retval;
        !           126: {
        !           127:        struct osf1_sys_sigaltstack_args *uap = v;
        !           128:        struct osf1_sigaltstack *noss, *ooss, tmposs;
        !           129:        struct sigaltstack *nbss, *obss, tmpbss;
        !           130:        struct sys_sigaltstack_args sa;
        !           131:        caddr_t sg;
        !           132:        int error;
        !           133:
        !           134:        sg = stackgap_init(p->p_emul);
        !           135:        noss = SCARG(uap, nss);
        !           136:        ooss = SCARG(uap, oss);
        !           137:
        !           138:        if (ooss != NULL)
        !           139:                obss = stackgap_alloc(&sg, sizeof(struct sigaltstack));
        !           140:        else
        !           141:                obss = NULL;
        !           142:
        !           143:        if (noss != NULL) {
        !           144:                nbss = stackgap_alloc(&sg, sizeof(struct sigaltstack));
        !           145:                if ((error = copyin(noss, &tmposs, sizeof(tmposs))) != 0)
        !           146:                        return error;
        !           147:                if ((error = osf1_cvt_sigaltstack_to_native(&tmposs, &tmpbss)) != 0)
        !           148:                        return error;
        !           149:                if ((error = copyout(&tmpbss, nbss, sizeof(tmpbss))) != 0)
        !           150:                        return error;
        !           151:        } else
        !           152:                nbss = NULL;
        !           153:
        !           154:        SCARG(&sa, nss) = nbss;
        !           155:        SCARG(&sa, oss) = obss;
        !           156:
        !           157:        /* XXX */
        !           158:        if ((error = sys_sigaltstack(p, &sa, retval)) != 0)
        !           159:                return error;
        !           160:
        !           161:        if (obss != NULL) {
        !           162:                if ((error = copyin(obss, &tmpbss, sizeof(tmpbss))) != 0)
        !           163:                        return error;
        !           164:                osf1_cvt_sigaltstack_from_native(&tmpbss, &tmposs);
        !           165:                if ((error = copyout(&tmposs, ooss, sizeof(tmposs))) != 0)
        !           166:                        return error;
        !           167:        }
        !           168:
        !           169:        return 0;
        !           170: }
        !           171:
        !           172: #if 0
        !           173: int
        !           174: osf1_sys_signal(p, v, retval)
        !           175:        struct proc *p;
        !           176:        void *v;
        !           177:        register_t *retval;
        !           178: {
        !           179:        struct osf1_sys_signal_args *uap = v;
        !           180:        int signum = osf1_signal_xlist[OSF1_SIGNO(SCARG(uap, signum))];
        !           181:        int error;
        !           182:        caddr_t sg = stackgap_init(p->p_emul);
        !           183:
        !           184:        if (signum <= 0 || signum >= OSF1_NSIG) {
        !           185:                if (OSF1_SIGCALL(SCARG(uap, signum)) == OSF1_SIGNAL_MASK ||
        !           186:                    OSF1_SIGCALL(SCARG(uap, signum)) == OSF1_SIGDEFER_MASK)
        !           187:                        *retval = (int)OSF1_SIG_ERR;
        !           188:                return EINVAL;
        !           189:        }
        !           190:
        !           191:        switch (OSF1_SIGCALL(SCARG(uap, signum))) {
        !           192:        case OSF1_SIGDEFER_MASK:
        !           193:                /*
        !           194:                 * sigset is identical to signal() except
        !           195:                 * that SIG_HOLD is allowed as
        !           196:                 * an action.
        !           197:                 */
        !           198:                if (SCARG(uap, handler) == OSF1_SIG_HOLD) {
        !           199:                        struct sys_sigprocmask_args sa;
        !           200:
        !           201:                        SCARG(&sa, how) = SIG_BLOCK;
        !           202:                        SCARG(&sa, mask) = sigmask(signum);
        !           203:                        return sys_sigprocmask(p, &sa, retval);
        !           204:                }
        !           205:                /* FALLTHROUGH */
        !           206:
        !           207:        case OSF1_SIGNAL_MASK:
        !           208:                {
        !           209:                        struct sys_sigaction_args sa_args;
        !           210:                        struct sigaction *nbsa, *obsa, sa;
        !           211:
        !           212:                        nbsa = stackgap_alloc(&sg, sizeof(struct sigaction));
        !           213:                        obsa = stackgap_alloc(&sg, sizeof(struct sigaction));
        !           214:                        SCARG(&sa_args, signum) = signum;
        !           215:                        SCARG(&sa_args, nsa) = nbsa;
        !           216:                        SCARG(&sa_args, osa) = obsa;
        !           217:
        !           218:                        sa.sa_handler = SCARG(uap, handler);
        !           219:                        sigemptyset(&sa.sa_mask);
        !           220:                        sa.sa_flags = 0;
        !           221: #if 0
        !           222:                        if (signum != SIGALRM)
        !           223:                                sa.sa_flags = SA_RESTART;
        !           224: #endif
        !           225:                        if ((error = copyout(&sa, nbsa, sizeof(sa))) != 0)
        !           226:                                return error;
        !           227:                        if ((error = sys_sigaction(p, &sa_args, retval)) != 0) {
        !           228:                                DPRINTF(("signal: sigaction failed: %d\n",
        !           229:                                         error));
        !           230:                                *retval = (int)OSF1_SIG_ERR;
        !           231:                                return error;
        !           232:                        }
        !           233:                        if ((error = copyin(obsa, &sa, sizeof(sa))) != 0)
        !           234:                                return error;
        !           235:                        *retval = (int)sa.sa_handler;
        !           236:                        return 0;
        !           237:                }
        !           238:
        !           239:        case OSF1_SIGHOLD_MASK:
        !           240:                {
        !           241:                        struct sys_sigprocmask_args sa;
        !           242:
        !           243:                        SCARG(&sa, how) = SIG_BLOCK;
        !           244:                        SCARG(&sa, mask) = sigmask(signum);
        !           245:                        return sys_sigprocmask(p, &sa, retval);
        !           246:                }
        !           247:
        !           248:        case OSF1_SIGRELSE_MASK:
        !           249:                {
        !           250:                        struct sys_sigprocmask_args sa;
        !           251:
        !           252:                        SCARG(&sa, how) = SIG_UNBLOCK;
        !           253:                        SCARG(&sa, mask) = sigmask(signum);
        !           254:                        return sys_sigprocmask(p, &sa, retval);
        !           255:                }
        !           256:
        !           257:        case OSF1_SIGIGNORE_MASK:
        !           258:                {
        !           259:                        struct sys_sigaction_args sa_args;
        !           260:                        struct sigaction *bsa, sa;
        !           261:
        !           262:                        bsa = stackgap_alloc(&sg, sizeof(struct sigaction));
        !           263:                        SCARG(&sa_args, signum) = signum;
        !           264:                        SCARG(&sa_args, nsa) = bsa;
        !           265:                        SCARG(&sa_args, osa) = NULL;
        !           266:
        !           267:                        sa.sa_handler = SIG_IGN;
        !           268:                        sigemptyset(&sa.sa_mask);
        !           269:                        sa.sa_flags = 0;
        !           270:                        if ((error = copyout(&sa, bsa, sizeof(sa))) != 0)
        !           271:                                return error;
        !           272:                        if ((error = sys_sigaction(p, &sa_args, retval)) != 0) {
        !           273:                                DPRINTF(("sigignore: sigaction failed\n"));
        !           274:                                return error;
        !           275:                        }
        !           276:                        return 0;
        !           277:                }
        !           278:
        !           279:        case OSF1_SIGPAUSE_MASK:
        !           280:                {
        !           281:                        struct sys_sigsuspend_args sa;
        !           282:
        !           283:                        SCARG(&sa, mask) = p->p_sigmask & ~sigmask(signum);
        !           284:                        return sys_sigsuspend(p, &sa, retval);
        !           285:                }
        !           286:
        !           287:        default:
        !           288:                return ENOSYS;
        !           289:        }
        !           290: }
        !           291:
        !           292: int
        !           293: osf1_sys_sigpending(p, v, retval)
        !           294:        struct proc *p;
        !           295:        void *v;
        !           296:        register_t *retval;
        !           297: {
        !           298:        struct osf1_sys_sigpending_args *uap = v;
        !           299:        sigset_t bss;
        !           300:        osf1_sigset_t oss;
        !           301:
        !           302:        bss = p->p_siglist & p->p_sigmask;
        !           303:        osf1_cvt_sigset_from_native(&bss, &oss);
        !           304:
        !           305:        return copyout(&oss, SCARG(uap, mask), sizeof(oss));
        !           306: }
        !           307:
        !           308: int
        !           309: osf1_sys_sigprocmask(p, v, retval)
        !           310:        struct proc *p;
        !           311:        void *v;
        !           312:        register_t *retval;
        !           313: {
        !           314:        struct osf1_sys_sigprocmask_args *uap = v;
        !           315:        osf1_sigset_t oss;
        !           316:        sigset_t bss;
        !           317:        int error = 0;
        !           318:
        !           319:        if (SCARG(uap, oset) != NULL) {
        !           320:                /* Fix the return value first if needed */
        !           321:                osf1_cvt_sigset_from_native(&p->p_sigmask, &oss);
        !           322:                if ((error = copyout(&oss, SCARG(uap, oset), sizeof(oss))) != 0)
        !           323:                        return error;
        !           324:        }
        !           325:
        !           326:        if (SCARG(uap, set) == NULL)
        !           327:                /* Just examine */
        !           328:                return 0;
        !           329:
        !           330:        if ((error = copyin(SCARG(uap, set), &oss, sizeof(oss))) != 0)
        !           331:                return error;
        !           332:
        !           333:        osf1_cvt_sigset_to_native(&oss, &bss);
        !           334:
        !           335:        (void) splhigh();
        !           336:
        !           337:        switch (SCARG(uap, how)) {
        !           338:        case OSF1_SIG_BLOCK:
        !           339:                p->p_sigmask |= bss & ~sigcantmask;
        !           340:                break;
        !           341:
        !           342:        case OSF1_SIG_UNBLOCK:
        !           343:                p->p_sigmask &= ~bss;
        !           344:                break;
        !           345:
        !           346:        case OSF1_SIG_SETMASK:
        !           347:                p->p_sigmask = bss & ~sigcantmask;
        !           348:                break;
        !           349:
        !           350:        default:
        !           351:                error = EINVAL;
        !           352:                break;
        !           353:        }
        !           354:
        !           355:        (void) spl0();
        !           356:
        !           357:        return error;
        !           358: }
        !           359:
        !           360: int
        !           361: osf1_sys_sigsuspend(p, v, retval)
        !           362:        struct proc *p;
        !           363:        void *v;
        !           364:        register_t *retval;
        !           365: {
        !           366:        struct osf1_sys_sigsuspend_args *uap = v;
        !           367:        osf1_sigset_t oss;
        !           368:        sigset_t bss;
        !           369:        struct sys_sigsuspend_args sa;
        !           370:        int error;
        !           371:
        !           372:        if ((error = copyin(SCARG(uap, ss), &oss, sizeof(oss))) != 0)
        !           373:                return error;
        !           374:
        !           375:        osf1_cvt_sigset_to_native(&oss, &bss);
        !           376:
        !           377:        SCARG(&sa, mask) = bss;
        !           378:        return sys_sigsuspend(p, &sa, retval);
        !           379: }
        !           380: #endif

CVSweb