The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/compat/osf1/osf1_signal.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

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

Cache object: b3d0597b248537525771864f09fe7526


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.