diff options
Diffstat (limited to 'sys/compat/linux/linux_signal.c')
-rw-r--r-- | sys/compat/linux/linux_signal.c | 115 |
1 files changed, 81 insertions, 34 deletions
diff --git a/sys/compat/linux/linux_signal.c b/sys/compat/linux/linux_signal.c index ee9c499fc34..6b1e78fb400 100644 --- a/sys/compat/linux/linux_signal.c +++ b/sys/compat/linux/linux_signal.c @@ -1,4 +1,4 @@ -/* $OpenBSD: linux_signal.c,v 1.6 2000/03/13 08:18:30 jasoni Exp $ */ +/* $OpenBSD: linux_signal.c,v 1.7 2000/06/07 14:11:38 niklas Exp $ */ /* $NetBSD: linux_signal.c,v 1.10 1996/04/04 23:51:36 christos Exp $ */ /* @@ -388,10 +388,10 @@ linux_sys_sigaction(p, v, retval) if (nlsa != NULL) { nbsa = stackgap_alloc(&sg, sizeof(struct sigaction)); if ((error = copyin(nlsa, &tmplsa, sizeof(tmplsa))) != 0) - return error; + return (error); linux_old_to_bsd_sigaction(&tmplsa, &tmpbsa); if ((error = copyout(&tmpbsa, nbsa, sizeof(tmpbsa))) != 0) - return error; + return (error); } else nbsa = NULL; @@ -400,17 +400,17 @@ linux_sys_sigaction(p, v, retval) SCARG(&sa, osa) = obsa; if ((error = sys_sigaction(p, &sa, retval)) != 0) - return error; + return (error); if (olsa != NULL) { if ((error = copyin(obsa, &tmpbsa, sizeof(tmpbsa))) != 0) - return error; + return (error); bsd_to_linux_old_sigaction(&tmpbsa, &tmplsa); if ((error = copyout(&tmplsa, olsa, sizeof(tmplsa))) != 0) - return error; + return (error); } - return 0; + return (0); } int @@ -449,10 +449,10 @@ linux_sys_rt_sigaction(p, v, retval) if (nlsa != NULL) { nbsa = stackgap_alloc(&sg, sizeof(struct sigaction)); if ((error = copyin(nlsa, &tmplsa, sizeof(tmplsa))) != 0) - return error; + return (error); linux_to_bsd_sigaction(&tmplsa, &tmpbsa); if ((error = copyout(&tmpbsa, nbsa, sizeof(tmpbsa))) != 0) - return error; + return (error); } else nbsa = NULL; @@ -462,17 +462,17 @@ linux_sys_rt_sigaction(p, v, retval) SCARG(&sa, osa) = obsa; if ((error = sys_sigaction(p, &sa, retval)) != 0) - return error; + return (error); if (olsa != NULL) { if ((error = copyin(obsa, &tmpbsa, sizeof(tmpbsa))) != 0) - return error; + return (error); bsd_to_linux_sigaction(&tmpbsa, &tmplsa); if ((error = copyout(&tmplsa, olsa, sizeof(tmplsa))) != 0) - return error; + return (error); } - return 0; + return (0); } /* @@ -507,19 +507,19 @@ linux_sys_signal(p, v, retval) tmpsa.sa_mask = (sigset_t) 0; tmpsa.sa_flags = SA_RESETHAND | SA_NODEFER; if ((error = copyout(&tmpsa, nsa, sizeof tmpsa))) - return error; + return (error); SCARG(&sa_args, signum) = linux_to_bsd_sig[SCARG(uap, sig)]; SCARG(&sa_args, osa) = osa; SCARG(&sa_args, nsa) = nsa; if ((error = sys_sigaction(p, &sa_args, retval))) - return error; + return (error); if ((error = copyin(osa, &tmpsa, sizeof *osa))) - return error; + return (error); retval[0] = (register_t) tmpsa.sa_handler; - return 0; + return (0); } /* @@ -546,15 +546,15 @@ linux_sys_sigprocmask(p, v, retval) /* Fix the return value first if needed */ bsd_to_linux_old_sigset(&p->p_sigmask, &ss); if ((error = copyout(&ss, SCARG(uap, oset), sizeof(ss))) != 0) - return error; + return (error); } if (SCARG(uap, set) == NULL) /* Just examine */ - return 0; + return (0); if ((error = copyin(SCARG(uap, set), &ss, sizeof(ss))) != 0) - return error; + return (error); linux_old_to_bsd_sigset(&ss, &bs); @@ -580,7 +580,7 @@ linux_sys_sigprocmask(p, v, retval) (void) spl0(); - return error; + return (error); } int @@ -608,15 +608,15 @@ linux_sys_rt_sigprocmask(p, v, retval) /* Fix the return value first if needed */ bsd_to_linux_sigset(&p->p_sigmask, &ls); if ((error = copyout(&ls, SCARG(uap, oset), sizeof(ls))) != 0) - return error; + return (error); } if (SCARG(uap, set) == NULL) /* Just examine */ - return 0; + return (0); if ((error = copyin(SCARG(uap, set), &ls, sizeof(ls))) != 0) - return error; + return (error); linux_to_bsd_sigset(&ls, &bs); @@ -642,7 +642,7 @@ linux_sys_rt_sigprocmask(p, v, retval) (void) spl0(); - return error; + return (error); } /* @@ -660,7 +660,7 @@ linux_sys_siggetmask(p, v, retval) { bsd_to_linux_old_sigset(&p->p_sigmask, (linux_old_sigset_t *)retval); - return 0; + return (0); } /* @@ -690,7 +690,7 @@ linux_sys_sigsetmask(p, v, retval) p->p_sigmask = bsdsig & ~sigcantmask; spl0(); - return 0; + return (0); } int @@ -708,7 +708,7 @@ linux_sys_sigpending(p, v, retval) bs = p->p_siglist & p->p_sigmask; bsd_to_linux_old_sigset(&bs, &ls); - return copyout(&ls, SCARG(uap, mask), sizeof(ls)); + return (copyout(&ls, SCARG(uap, mask), sizeof ls)); } int @@ -730,7 +730,7 @@ linux_sys_rt_sigpending(p, v, retval) bs = p->p_siglist & p->p_sigmask; bsd_to_linux_sigset(&bs, &ls); - return copyout(&ls, SCARG(uap, set), sizeof(ls)); + return (copyout(&ls, SCARG(uap, set), sizeof ls)); } int @@ -748,7 +748,7 @@ linux_sys_sigsuspend(p, v, retval) linux_old_sigset_t mask = SCARG(uap, mask); linux_old_to_bsd_sigset(&mask, &SCARG(&sa, mask)); - return sys_sigsuspend(p, &sa, retval); + return (sys_sigsuspend(p, &sa, retval)); } int @@ -768,12 +768,59 @@ linux_sys_rt_sigsuspend(p, v, retval) if (SCARG(uap, sigsetsize) != sizeof(linux_sigset_t)) return (EINVAL); - error = copyin(SCARG(uap, unewset), &mask, sizeof(linux_sigset_t)); + error = copyin(SCARG(uap, unewset), &mask, sizeof mask); if (error) return (error); linux_to_bsd_sigset(&mask, &SCARG(&sa, mask)); - return sys_sigsuspend(p, &sa, retval); + return (sys_sigsuspend(p, &sa, retval)); +} + +/* + * Linux' sigaltstack structure is just of a different order than BSD's + * so just shuffle the fields around and call our version. + */ +int +linux_sys_sigaltstack(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct linux_sys_sigaltstack_args /* { + syscallarg(const struct linux_sigaltstack *) nss; + syscallarg(struct linux_sigaltstack *) oss; + } */ *uap = v; + struct linux_sigaltstack linux_ss; + struct sigaltstack *bsd_nss, *bsd_oss; + struct sys_sigaltstack_args sa; + int error; + caddr_t sg; + + sg = stackgap_init(p->p_emul); + bsd_nss = stackgap_alloc(&sg, sizeof *bsd_nss); + + error = copyin(SCARG(uap, nss), &linux_ss, sizeof linux_ss); + if (error) + return (error); + + bsd_nss->ss_sp = linux_ss.ss_sp; + bsd_nss->ss_size = linux_ss.ss_size; + bsd_nss->ss_flags = linux_ss.ss_flags; + SCARG(&sa, nss) = bsd_nss; + if (SCARG(uap, oss) == NULL) { + SCARG(&sa, oss) = NULL; + return (sys_sigaltstack(p, &sa, retval)); + } + SCARG(&sa, oss) = bsd_oss = stackgap_alloc(&sg, sizeof *bsd_oss); + + error = sys_sigaltstack(p, &sa, retval); + if (error) + return (error); + + linux_ss.ss_sp = bsd_oss->ss_sp; + linux_ss.ss_size = bsd_oss->ss_size; + linux_ss.ss_flags = bsd_oss->ss_flags; + return (copyout(&linux_ss, SCARG(uap, oss), sizeof linux_ss)); } /* @@ -789,7 +836,7 @@ linux_sys_pause(p, v, retval) struct sys_sigsuspend_args bsa; SCARG(&bsa, mask) = p->p_sigmask; - return sys_sigsuspend(p, &bsa, retval); + return (sys_sigsuspend(p, &bsa, retval)); } /* @@ -811,5 +858,5 @@ linux_sys_kill(p, v, retval) if (SCARG(uap, signum) < 0 || SCARG(uap, signum) >= LINUX_NSIG) return (EINVAL); SCARG(&ka, signum) = linux_to_bsd_sig[SCARG(uap, signum)]; - return sys_kill(p, &ka, retval); + return (sys_kill(p, &ka, retval)); } |