2002-11-26 21:43:20 +03:00
|
|
|
/* $NetBSD: linux_signal.c,v 1.39 2002/11/26 18:43:21 christos Exp $ */
|
1998-10-04 04:02:23 +04:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
|
1995-03-01 02:24:35 +03:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
1998-10-04 04:02:23 +04:00
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Frank van der Linden and Eric Haszlakiewicz.
|
|
|
|
*
|
1995-03-01 02:24:35 +03:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
1998-10-04 04:02:23 +04:00
|
|
|
* This product includes software developed by the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
1995-03-01 02:24:35 +03:00
|
|
|
*
|
1998-10-04 04:02:23 +04:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
/*
|
1995-03-01 02:24:35 +03:00
|
|
|
* heavily from: svr4_signal.c,v 1.7 1995/01/09 01:04:21 christos Exp
|
|
|
|
*/
|
|
|
|
|
1998-10-01 06:27:33 +04:00
|
|
|
/*
|
|
|
|
* Functions in multiarch:
|
|
|
|
* linux_sys_signal : linux_sig_notalpha.c
|
|
|
|
* linux_sys_siggetmask : linux_sig_notalpha.c
|
|
|
|
* linux_sys_sigsetmask : linux_sig_notalpha.c
|
|
|
|
* linux_sys_pause : linux_sig_notalpha.c
|
|
|
|
* linux_sys_sigaction : linux_sigaction.c
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Unimplemented:
|
|
|
|
* linux_sys_rt_sigtimedwait : sigsuspend w/timeout.
|
|
|
|
*/
|
|
|
|
|
2001-11-13 05:07:52 +03:00
|
|
|
#include <sys/cdefs.h>
|
2002-11-26 21:43:20 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: linux_signal.c,v 1.39 2002/11/26 18:43:21 christos Exp $");
|
2001-11-13 05:07:52 +03:00
|
|
|
|
1998-12-19 19:27:09 +03:00
|
|
|
#define COMPAT_LINUX 1
|
|
|
|
|
1995-03-01 02:24:35 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/namei.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/filedesc.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/mount.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/signal.h>
|
|
|
|
#include <sys/signalvar.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
|
|
|
|
#include <sys/syscallargs.h>
|
|
|
|
|
1998-10-04 00:17:36 +04:00
|
|
|
#include <compat/linux/common/linux_types.h>
|
|
|
|
#include <compat/linux/common/linux_signal.h>
|
1998-10-08 02:12:48 +04:00
|
|
|
#include <compat/linux/common/linux_siginfo.h>
|
1998-10-04 00:17:36 +04:00
|
|
|
#include <compat/linux/common/linux_util.h>
|
|
|
|
|
1995-03-01 02:24:35 +03:00
|
|
|
#include <compat/linux/linux_syscallargs.h>
|
|
|
|
|
1998-10-01 06:27:33 +04:00
|
|
|
/* Locally used defines (in bsd<->linux conversion functions): */
|
1998-08-10 00:36:58 +04:00
|
|
|
#define linux_sigemptyset(s) memset((s), 0, sizeof(*(s)))
|
1998-12-15 22:31:30 +03:00
|
|
|
#define linux_sigismember(s, n) ((s)->sig[((n) - 1) / LINUX__NSIG_BPW] \
|
|
|
|
& (1 << ((n) - 1) % LINUX__NSIG_BPW))
|
|
|
|
#define linux_sigaddset(s, n) ((s)->sig[((n) - 1) / LINUX__NSIG_BPW] \
|
|
|
|
|= (1 << ((n) - 1) % LINUX__NSIG_BPW))
|
1995-08-14 02:55:28 +04:00
|
|
|
|
2002-03-22 20:14:18 +03:00
|
|
|
#ifdef DEBUG_LINUX
|
|
|
|
#define DPRINTF(a) uprintf a
|
|
|
|
#else
|
|
|
|
#define DPRINTF(a)
|
|
|
|
#endif
|
|
|
|
|
2002-04-01 02:22:43 +04:00
|
|
|
extern const int native_to_linux_signo[];
|
|
|
|
extern const int linux_to_native_signo[];
|
1995-08-14 02:55:28 +04:00
|
|
|
|
1998-10-01 06:27:33 +04:00
|
|
|
/*
|
1998-12-15 22:31:30 +03:00
|
|
|
* Convert between Linux and BSD signal sets.
|
1998-10-01 06:27:33 +04:00
|
|
|
*/
|
1998-12-15 22:31:30 +03:00
|
|
|
#if LINUX__NSIG_WORDS > 1
|
1995-08-14 02:55:28 +04:00
|
|
|
void
|
2002-02-15 19:47:58 +03:00
|
|
|
linux_old_extra_to_native_sigset(bss, lss, extra)
|
|
|
|
sigset_t *bss;
|
1998-10-01 06:27:33 +04:00
|
|
|
const linux_old_sigset_t *lss;
|
1998-12-15 22:31:30 +03:00
|
|
|
const unsigned long *extra;
|
|
|
|
{
|
|
|
|
linux_sigset_t lsnew;
|
|
|
|
|
|
|
|
/* convert old sigset to new sigset */
|
|
|
|
linux_sigemptyset(&lsnew);
|
|
|
|
lsnew.sig[0] = *lss;
|
|
|
|
if (extra)
|
2002-02-15 19:47:58 +03:00
|
|
|
memcpy(&lsnew.sig[1], extra,
|
|
|
|
sizeof(linux_sigset_t) - sizeof(linux_old_sigset_t));
|
1998-12-15 22:31:30 +03:00
|
|
|
|
2002-02-15 19:47:58 +03:00
|
|
|
linux_to_native_sigset(bss, &lsnew);
|
1998-12-15 22:31:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-02-15 19:47:58 +03:00
|
|
|
native_to_linux_old_extra_sigset(lss, extra, bss)
|
1998-12-15 22:31:30 +03:00
|
|
|
linux_old_sigset_t *lss;
|
|
|
|
unsigned long *extra;
|
2002-02-15 19:47:58 +03:00
|
|
|
const sigset_t *bss;
|
1998-12-15 22:31:30 +03:00
|
|
|
{
|
|
|
|
linux_sigset_t lsnew;
|
|
|
|
|
2002-02-15 19:47:58 +03:00
|
|
|
native_to_linux_sigset(&lsnew, bss);
|
1998-12-15 22:31:30 +03:00
|
|
|
|
|
|
|
/* convert new sigset to old sigset */
|
|
|
|
*lss = lsnew.sig[0];
|
|
|
|
if (extra)
|
2002-02-15 19:47:58 +03:00
|
|
|
memcpy(extra, &lsnew.sig[1],
|
|
|
|
sizeof(linux_sigset_t) - sizeof(linux_old_sigset_t));
|
1998-12-15 22:31:30 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void
|
2002-02-15 19:47:58 +03:00
|
|
|
linux_to_native_sigset(bss, lss)
|
1995-03-01 02:24:35 +03:00
|
|
|
sigset_t *bss;
|
2002-02-15 19:47:58 +03:00
|
|
|
const linux_sigset_t *lss;
|
1995-03-01 02:24:35 +03:00
|
|
|
{
|
|
|
|
int i, newsig;
|
|
|
|
|
1995-08-14 02:55:28 +04:00
|
|
|
sigemptyset(bss);
|
1998-12-15 22:31:30 +03:00
|
|
|
for (i = 1; i < LINUX__NSIG; i++) {
|
1995-08-14 02:55:28 +04:00
|
|
|
if (linux_sigismember(lss, i)) {
|
2002-04-01 02:22:43 +04:00
|
|
|
newsig = linux_to_native_signo[i];
|
1995-03-01 02:24:35 +03:00
|
|
|
if (newsig)
|
1995-08-14 02:55:28 +04:00
|
|
|
sigaddset(bss, newsig);
|
1995-03-01 02:24:35 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-02-15 19:47:58 +03:00
|
|
|
native_to_linux_sigset(lss, bss)
|
1998-12-15 22:31:30 +03:00
|
|
|
linux_sigset_t *lss;
|
2002-02-15 19:47:58 +03:00
|
|
|
const sigset_t *bss;
|
1995-03-01 02:24:35 +03:00
|
|
|
{
|
|
|
|
int i, newsig;
|
1998-12-15 22:31:30 +03:00
|
|
|
|
1995-08-14 02:55:28 +04:00
|
|
|
linux_sigemptyset(lss);
|
|
|
|
for (i = 1; i < NSIG; i++) {
|
|
|
|
if (sigismember(bss, i)) {
|
2002-04-01 02:22:43 +04:00
|
|
|
newsig = native_to_linux_signo[i];
|
1995-03-01 02:24:35 +03:00
|
|
|
if (newsig)
|
1995-08-14 02:55:28 +04:00
|
|
|
linux_sigaddset(lss, newsig);
|
1995-03-01 02:24:35 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-02-19 01:24:17 +03:00
|
|
|
unsigned int
|
|
|
|
native_to_linux_sigflags(bsf)
|
|
|
|
const int bsf;
|
2002-02-15 19:47:58 +03:00
|
|
|
{
|
2002-02-19 01:24:17 +03:00
|
|
|
unsigned int lsf = 0;
|
|
|
|
if ((bsf & SA_NOCLDSTOP) != 0)
|
|
|
|
lsf |= LINUX_SA_NOCLDSTOP;
|
|
|
|
if ((bsf & SA_NOCLDWAIT) != 0)
|
|
|
|
lsf |= LINUX_SA_NOCLDWAIT;
|
|
|
|
if ((bsf & SA_ONSTACK) != 0)
|
|
|
|
lsf |= LINUX_SA_ONSTACK;
|
|
|
|
if ((bsf & SA_RESTART) != 0)
|
|
|
|
lsf |= LINUX_SA_RESTART;
|
|
|
|
if ((bsf & SA_NODEFER) != 0)
|
|
|
|
lsf |= LINUX_SA_NOMASK;
|
|
|
|
if ((bsf & SA_RESETHAND) != 0)
|
|
|
|
lsf |= LINUX_SA_ONESHOT;
|
|
|
|
if ((bsf & SA_SIGINFO) != 0)
|
|
|
|
lsf |= LINUX_SA_SIGINFO;
|
|
|
|
return lsf;
|
2002-02-15 19:47:58 +03:00
|
|
|
}
|
|
|
|
|
2002-02-19 01:24:17 +03:00
|
|
|
int
|
|
|
|
linux_to_native_sigflags(lsf)
|
|
|
|
const unsigned long lsf;
|
2002-02-15 19:47:58 +03:00
|
|
|
{
|
2002-02-19 01:24:17 +03:00
|
|
|
int bsf = 0;
|
|
|
|
if ((lsf & LINUX_SA_NOCLDSTOP) != 0)
|
|
|
|
bsf |= SA_NOCLDSTOP;
|
|
|
|
if ((lsf & LINUX_SA_NOCLDWAIT) != 0)
|
|
|
|
bsf |= SA_NOCLDWAIT;
|
|
|
|
if ((lsf & LINUX_SA_ONSTACK) != 0)
|
|
|
|
bsf |= SA_ONSTACK;
|
|
|
|
if ((lsf & LINUX_SA_RESTART) != 0)
|
|
|
|
bsf |= SA_RESTART;
|
|
|
|
if ((lsf & LINUX_SA_ONESHOT) != 0)
|
|
|
|
bsf |= SA_RESETHAND;
|
|
|
|
if ((lsf & LINUX_SA_NOMASK) != 0)
|
|
|
|
bsf |= SA_NODEFER;
|
|
|
|
if ((lsf & LINUX_SA_SIGINFO) != 0)
|
|
|
|
bsf |= SA_SIGINFO;
|
|
|
|
if ((lsf & ~LINUX_SA_ALLBITS) != 0)
|
2002-03-22 20:14:18 +03:00
|
|
|
DPRINTF(("linux_old_to_native_sigflags: "
|
|
|
|
"%lx extra bits ignored\n", lsf));
|
2002-02-19 01:24:17 +03:00
|
|
|
return bsf;
|
2002-02-15 19:47:58 +03:00
|
|
|
}
|
|
|
|
|
1995-03-01 02:24:35 +03:00
|
|
|
/*
|
1998-10-01 06:27:33 +04:00
|
|
|
* Convert between Linux and BSD sigaction structures. Linux sometimes
|
|
|
|
* has one extra field (sa_restorer) which we don't support.
|
1995-03-01 02:24:35 +03:00
|
|
|
*/
|
|
|
|
void
|
2002-02-15 19:47:58 +03:00
|
|
|
linux_old_to_native_sigaction(bsa, lsa)
|
1998-10-01 06:27:33 +04:00
|
|
|
struct sigaction *bsa;
|
2002-02-15 19:47:58 +03:00
|
|
|
const struct linux_old_sigaction *lsa;
|
1998-10-01 06:27:33 +04:00
|
|
|
{
|
2002-11-26 21:43:20 +03:00
|
|
|
bsa->sa_handler = lsa->linux_sa_handler;
|
|
|
|
linux_old_to_native_sigset(&bsa->sa_mask, &lsa->linux_sa_mask);
|
|
|
|
bsa->sa_flags = linux_to_native_sigflags(lsa->linux_sa_flags);
|
2002-02-19 01:24:17 +03:00
|
|
|
#ifndef __alpha__
|
|
|
|
/*
|
|
|
|
* XXX: On the alpha sa_restorer is elsewhere.
|
|
|
|
*/
|
2002-11-26 21:43:20 +03:00
|
|
|
if (lsa->linux_sa_restorer != NULL)
|
2002-03-22 20:14:18 +03:00
|
|
|
DPRINTF(("linux_old_to_native_sigaction: "
|
|
|
|
"sa_restorer ignored\n"));
|
2002-02-19 01:24:17 +03:00
|
|
|
#endif
|
1998-10-01 06:27:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-02-15 19:47:58 +03:00
|
|
|
native_to_linux_old_sigaction(lsa, bsa)
|
1998-10-01 06:27:33 +04:00
|
|
|
struct linux_old_sigaction *lsa;
|
2002-02-15 19:47:58 +03:00
|
|
|
const struct sigaction *bsa;
|
1998-10-01 06:27:33 +04:00
|
|
|
{
|
2002-11-26 21:43:20 +03:00
|
|
|
lsa->linux_sa_handler = bsa->sa_handler;
|
|
|
|
native_to_linux_old_sigset(&lsa->linux_sa_mask, &bsa->sa_mask);
|
|
|
|
lsa->linux_sa_flags = native_to_linux_sigflags(bsa->sa_flags);
|
2002-02-19 01:24:17 +03:00
|
|
|
#ifndef __alpha__
|
2002-11-26 21:43:20 +03:00
|
|
|
lsa->linux_sa_restorer = NULL;
|
2002-02-19 01:24:17 +03:00
|
|
|
#endif
|
1998-10-01 06:27:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ...and the new sigaction conversion funcs. */
|
|
|
|
void
|
2002-02-15 19:47:58 +03:00
|
|
|
linux_to_native_sigaction(bsa, lsa)
|
1995-03-01 02:24:35 +03:00
|
|
|
struct sigaction *bsa;
|
2002-02-15 19:47:58 +03:00
|
|
|
const struct linux_sigaction *lsa;
|
1995-03-01 02:24:35 +03:00
|
|
|
{
|
2002-11-26 21:43:20 +03:00
|
|
|
bsa->sa_handler = lsa->linux_sa_handler;
|
|
|
|
linux_to_native_sigset(&bsa->sa_mask, &lsa->linux_sa_mask);
|
|
|
|
bsa->sa_flags = linux_to_native_sigflags(lsa->linux_sa_flags);
|
2002-02-19 01:24:17 +03:00
|
|
|
#ifndef __alpha__
|
2002-11-26 21:43:20 +03:00
|
|
|
if (lsa->linux_sa_restorer != 0)
|
2002-03-22 20:14:18 +03:00
|
|
|
DPRINTF(("linux_to_native_sigaction: sa_restorer ignored\n"));
|
2002-02-19 01:24:17 +03:00
|
|
|
#endif
|
1995-03-01 02:24:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-02-15 19:47:58 +03:00
|
|
|
native_to_linux_sigaction(lsa, bsa)
|
1995-03-01 02:24:35 +03:00
|
|
|
struct linux_sigaction *lsa;
|
2002-02-15 19:47:58 +03:00
|
|
|
const struct sigaction *bsa;
|
1995-03-01 02:24:35 +03:00
|
|
|
{
|
2002-11-26 21:43:20 +03:00
|
|
|
lsa->linux_sa_handler = bsa->sa_handler;
|
|
|
|
native_to_linux_sigset(&lsa->linux_sa_mask, &bsa->sa_mask);
|
|
|
|
lsa->linux_sa_flags = native_to_linux_sigflags(bsa->sa_flags);
|
2002-02-19 01:24:17 +03:00
|
|
|
#ifndef __alpha__
|
2002-11-26 21:43:20 +03:00
|
|
|
lsa->linux_sa_restorer = NULL;
|
2002-02-19 01:24:17 +03:00
|
|
|
#endif
|
1995-03-01 02:24:35 +03:00
|
|
|
}
|
|
|
|
|
1998-10-01 06:27:33 +04:00
|
|
|
/* ----------------------------------------------------------------------- */
|
1995-03-01 02:24:35 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The Linux sigaction() system call. Do the usual conversions,
|
|
|
|
* and just call sigaction(). Some flags and values are silently
|
|
|
|
* ignored (see above).
|
|
|
|
*/
|
|
|
|
int
|
1998-10-01 06:27:33 +04:00
|
|
|
linux_sys_rt_sigaction(p, v, retval)
|
2000-03-30 15:24:16 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:37:27 +04:00
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
1998-10-01 06:27:33 +04:00
|
|
|
struct linux_sys_rt_sigaction_args /* {
|
1995-03-01 02:24:35 +03:00
|
|
|
syscallarg(int) signum;
|
1998-09-11 16:50:05 +04:00
|
|
|
syscallarg(const struct linux_sigaction *) nsa;
|
1995-03-01 02:24:35 +03:00
|
|
|
syscallarg(struct linux_sigaction *) osa;
|
1998-10-01 06:27:33 +04:00
|
|
|
syscallarg(size_t) sigsetsize;
|
1995-09-20 02:37:27 +04:00
|
|
|
} */ *uap = v;
|
1998-09-11 16:50:05 +04:00
|
|
|
struct linux_sigaction nlsa, olsa;
|
|
|
|
struct sigaction nbsa, obsa;
|
1999-12-05 01:26:52 +03:00
|
|
|
int error, sig;
|
1995-03-01 02:24:35 +03:00
|
|
|
|
1998-10-01 06:27:33 +04:00
|
|
|
if (SCARG(uap, sigsetsize) != sizeof(linux_sigset_t))
|
|
|
|
return (EINVAL);
|
|
|
|
|
1998-09-11 16:50:05 +04:00
|
|
|
if (SCARG(uap, nsa)) {
|
|
|
|
error = copyin(SCARG(uap, nsa), &nlsa, sizeof(nlsa));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
2002-02-15 19:47:58 +03:00
|
|
|
linux_to_native_sigaction(&nbsa, &nlsa);
|
1995-03-01 02:24:35 +03:00
|
|
|
}
|
1999-12-05 01:26:52 +03:00
|
|
|
sig = SCARG(uap, signum);
|
|
|
|
if (sig < 0 || sig >= LINUX__NSIG)
|
|
|
|
return (EINVAL);
|
2002-04-01 02:22:43 +04:00
|
|
|
if (sig > 0 && !linux_to_native_signo[sig]) {
|
2000-08-10 00:20:49 +04:00
|
|
|
/* Pretend that we did something useful for unknown signals. */
|
|
|
|
obsa.sa_handler = SIG_IGN;
|
|
|
|
sigemptyset(&obsa.sa_mask);
|
|
|
|
obsa.sa_flags = 0;
|
|
|
|
} else {
|
2002-04-01 02:22:43 +04:00
|
|
|
error = sigaction1(p, linux_to_native_signo[sig],
|
2002-07-05 03:32:02 +04:00
|
|
|
SCARG(uap, nsa) ? &nbsa : NULL,
|
|
|
|
SCARG(uap, osa) ? &obsa : NULL,
|
|
|
|
NULL, 0);
|
2000-08-10 00:20:49 +04:00
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
}
|
1998-09-11 16:50:05 +04:00
|
|
|
if (SCARG(uap, osa)) {
|
2002-02-15 19:47:58 +03:00
|
|
|
native_to_linux_sigaction(&olsa, &obsa);
|
1998-09-11 16:50:05 +04:00
|
|
|
error = copyout(&olsa, SCARG(uap, osa), sizeof(olsa));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
return (0);
|
1995-03-01 02:24:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1998-10-08 02:12:48 +04:00
|
|
|
linux_sigprocmask1(p, how, set, oset)
|
2000-03-30 15:24:16 +04:00
|
|
|
struct proc *p;
|
1998-10-08 02:12:48 +04:00
|
|
|
int how;
|
|
|
|
const linux_old_sigset_t *set;
|
|
|
|
linux_old_sigset_t *oset;
|
1995-09-20 02:37:27 +04:00
|
|
|
{
|
1998-10-01 06:27:33 +04:00
|
|
|
linux_old_sigset_t nlss, olss;
|
1998-09-11 16:50:05 +04:00
|
|
|
sigset_t nbss, obss;
|
|
|
|
int error;
|
1995-03-01 02:24:35 +03:00
|
|
|
|
1998-10-08 02:12:48 +04:00
|
|
|
switch (how) {
|
1995-03-01 02:24:35 +03:00
|
|
|
case LINUX_SIG_BLOCK:
|
1998-09-11 16:50:05 +04:00
|
|
|
how = SIG_BLOCK;
|
1995-03-01 02:24:35 +03:00
|
|
|
break;
|
|
|
|
case LINUX_SIG_UNBLOCK:
|
1998-09-11 16:50:05 +04:00
|
|
|
how = SIG_UNBLOCK;
|
1995-03-01 02:24:35 +03:00
|
|
|
break;
|
|
|
|
case LINUX_SIG_SETMASK:
|
1998-09-11 16:50:05 +04:00
|
|
|
how = SIG_SETMASK;
|
1995-03-01 02:24:35 +03:00
|
|
|
break;
|
|
|
|
default:
|
1998-09-11 16:50:05 +04:00
|
|
|
return (EINVAL);
|
1995-03-01 02:24:35 +03:00
|
|
|
}
|
|
|
|
|
1998-10-08 02:12:48 +04:00
|
|
|
if (set) {
|
|
|
|
error = copyin(set, &nlss, sizeof(nlss));
|
1998-09-11 16:50:05 +04:00
|
|
|
if (error)
|
|
|
|
return (error);
|
2002-02-15 19:47:58 +03:00
|
|
|
linux_old_to_native_sigset(&nbss, &nlss);
|
1998-09-11 16:50:05 +04:00
|
|
|
}
|
|
|
|
error = sigprocmask1(p, how,
|
2000-07-29 01:38:44 +04:00
|
|
|
set ? &nbss : NULL, oset ? &obss : NULL);
|
1998-09-11 16:50:05 +04:00
|
|
|
if (error)
|
|
|
|
return (error);
|
1998-10-08 02:12:48 +04:00
|
|
|
if (oset) {
|
2002-02-15 19:47:58 +03:00
|
|
|
native_to_linux_old_sigset(&olss, &obss);
|
1998-10-08 02:12:48 +04:00
|
|
|
error = copyout(&olss, oset, sizeof(olss));
|
1998-09-11 16:50:05 +04:00
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
return (error);
|
1995-03-01 02:24:35 +03:00
|
|
|
}
|
|
|
|
|
1998-10-08 02:12:48 +04:00
|
|
|
int
|
|
|
|
linux_sys_rt_sigprocmask(p, v, retval)
|
2000-03-30 15:24:16 +04:00
|
|
|
struct proc *p;
|
1998-10-08 02:12:48 +04:00
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct linux_sys_rt_sigprocmask_args /* {
|
|
|
|
syscallarg(int) how;
|
|
|
|
syscallarg(const linux_sigset_t *) set;
|
|
|
|
syscallarg(linux_sigset_t *) oset;
|
|
|
|
syscallarg(size_t) sigsetsize;
|
|
|
|
} */ *uap = v;
|
|
|
|
|
1999-10-04 21:46:37 +04:00
|
|
|
linux_sigset_t nlss, olss, *oset;
|
|
|
|
const linux_sigset_t *set;
|
|
|
|
sigset_t nbss, obss;
|
|
|
|
int error, how;
|
|
|
|
|
|
|
|
if (SCARG(uap, sigsetsize) != sizeof(linux_sigset_t))
|
|
|
|
return (EINVAL);
|
|
|
|
|
|
|
|
switch (SCARG(uap, how)) {
|
|
|
|
case LINUX_SIG_BLOCK:
|
|
|
|
how = SIG_BLOCK;
|
|
|
|
break;
|
|
|
|
case LINUX_SIG_UNBLOCK:
|
|
|
|
how = SIG_UNBLOCK;
|
|
|
|
break;
|
|
|
|
case LINUX_SIG_SETMASK:
|
|
|
|
how = SIG_SETMASK;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return (EINVAL);
|
1998-10-08 02:12:48 +04:00
|
|
|
}
|
|
|
|
|
1999-10-04 21:46:37 +04:00
|
|
|
set = SCARG(uap, set);
|
|
|
|
oset = SCARG(uap, oset);
|
|
|
|
|
|
|
|
if (set) {
|
|
|
|
error = copyin(set, &nlss, sizeof(nlss));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
2002-02-15 19:47:58 +03:00
|
|
|
linux_to_native_sigset(&nbss, &nlss);
|
1999-10-04 21:46:37 +04:00
|
|
|
}
|
|
|
|
error = sigprocmask1(p, how,
|
2000-07-29 01:38:44 +04:00
|
|
|
set ? &nbss : NULL, oset ? &obss : NULL);
|
2000-07-29 01:49:09 +04:00
|
|
|
if (!error && oset) {
|
2002-02-15 19:47:58 +03:00
|
|
|
native_to_linux_sigset(&olss, &obss);
|
1999-10-04 21:46:37 +04:00
|
|
|
error = copyout(&olss, oset, sizeof(olss));
|
|
|
|
}
|
|
|
|
return (error);
|
1998-10-08 02:12:48 +04:00
|
|
|
}
|
|
|
|
|
1995-03-01 02:24:35 +03:00
|
|
|
int
|
1998-10-01 06:27:33 +04:00
|
|
|
linux_sys_rt_sigpending(p, v, retval)
|
2000-03-30 15:24:16 +04:00
|
|
|
struct proc *p;
|
1995-10-07 09:25:19 +03:00
|
|
|
void *v;
|
1995-03-01 02:24:35 +03:00
|
|
|
register_t *retval;
|
|
|
|
{
|
1998-10-01 06:27:33 +04:00
|
|
|
struct linux_sys_rt_sigpending_args /* {
|
|
|
|
syscallarg(linux_sigset_t *) set;
|
|
|
|
syscallarg(size_t) sigsetsize;
|
|
|
|
} */ *uap = v;
|
1998-09-11 16:50:05 +04:00
|
|
|
sigset_t bss;
|
|
|
|
linux_sigset_t lss;
|
1995-03-01 02:24:35 +03:00
|
|
|
|
1998-10-01 06:27:33 +04:00
|
|
|
if (SCARG(uap, sigsetsize) != sizeof(linux_sigset_t))
|
|
|
|
return (EINVAL);
|
1995-03-01 02:24:35 +03:00
|
|
|
|
1998-10-01 06:27:33 +04:00
|
|
|
sigpending1(p, &bss);
|
2002-02-15 19:47:58 +03:00
|
|
|
native_to_linux_sigset(&lss, &bss);
|
1998-10-01 06:27:33 +04:00
|
|
|
return copyout(&lss, SCARG(uap, set), sizeof(lss));
|
1995-03-01 02:24:35 +03:00
|
|
|
}
|
1999-10-04 21:46:37 +04:00
|
|
|
|
1995-03-01 02:24:35 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
linux_sys_sigpending(p, v, retval)
|
2000-03-30 15:24:16 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:37:27 +04:00
|
|
|
void *v;
|
1995-03-01 02:24:35 +03:00
|
|
|
register_t *retval;
|
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct linux_sys_sigpending_args /* {
|
1998-10-01 06:27:33 +04:00
|
|
|
syscallarg(linux_old_sigset_t *) mask;
|
1995-09-20 02:37:27 +04:00
|
|
|
} */ *uap = v;
|
1998-09-11 16:50:05 +04:00
|
|
|
sigset_t bss;
|
1998-10-01 06:27:33 +04:00
|
|
|
linux_old_sigset_t lss;
|
1995-03-01 02:24:35 +03:00
|
|
|
|
1998-09-11 16:50:05 +04:00
|
|
|
sigpending1(p, &bss);
|
2002-02-15 19:47:58 +03:00
|
|
|
native_to_linux_old_sigset(&lss, &bss);
|
1998-09-11 16:50:05 +04:00
|
|
|
return copyout(&lss, SCARG(uap, set), sizeof(lss));
|
1995-03-01 02:24:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
linux_sys_sigsuspend(p, v, retval)
|
2000-03-30 15:24:16 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:37:27 +04:00
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct linux_sys_sigsuspend_args /* {
|
1995-03-11 01:55:04 +03:00
|
|
|
syscallarg(caddr_t) restart;
|
|
|
|
syscallarg(int) oldmask;
|
1995-03-01 02:24:35 +03:00
|
|
|
syscallarg(int) mask;
|
1995-09-20 02:37:27 +04:00
|
|
|
} */ *uap = v;
|
1998-10-01 06:27:33 +04:00
|
|
|
linux_old_sigset_t lss;
|
1998-09-11 16:50:05 +04:00
|
|
|
sigset_t bss;
|
1998-10-01 06:27:33 +04:00
|
|
|
|
1998-09-11 16:50:05 +04:00
|
|
|
lss = SCARG(uap, mask);
|
2002-02-15 19:47:58 +03:00
|
|
|
linux_old_to_native_sigset(&bss, &lss);
|
1998-10-01 06:27:33 +04:00
|
|
|
return (sigsuspend1(p, &bss));
|
|
|
|
}
|
|
|
|
int
|
|
|
|
linux_sys_rt_sigsuspend(p, v, retval)
|
2000-03-30 15:24:16 +04:00
|
|
|
struct proc *p;
|
1998-10-01 06:27:33 +04:00
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct linux_sys_rt_sigsuspend_args /* {
|
|
|
|
syscallarg(linux_sigset_t *) unewset;
|
|
|
|
syscallarg(size_t) sigsetsize;
|
|
|
|
} */ *uap = v;
|
|
|
|
linux_sigset_t lss;
|
|
|
|
sigset_t bss;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
if (SCARG(uap, sigsetsize) != sizeof(linux_sigset_t))
|
|
|
|
return (EINVAL);
|
|
|
|
|
|
|
|
error = copyin(SCARG(uap, unewset), &lss, sizeof(linux_sigset_t));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
|
2002-02-15 19:47:58 +03:00
|
|
|
linux_to_native_sigset(&bss, &lss);
|
1998-10-01 06:27:33 +04:00
|
|
|
|
1998-09-11 16:50:05 +04:00
|
|
|
return (sigsuspend1(p, &bss));
|
1995-03-01 02:24:35 +03:00
|
|
|
}
|
|
|
|
|
1995-03-11 01:55:04 +03:00
|
|
|
/*
|
1998-10-01 06:27:33 +04:00
|
|
|
* Once more: only a signal conversion is needed.
|
|
|
|
* Note: also used as sys_rt_queueinfo. The info field is ignored.
|
1995-03-11 01:55:04 +03:00
|
|
|
*/
|
|
|
|
int
|
1998-10-01 06:27:33 +04:00
|
|
|
linux_sys_rt_queueinfo(p, v, retval)
|
2000-03-30 15:24:16 +04:00
|
|
|
struct proc *p;
|
1998-10-01 06:27:33 +04:00
|
|
|
void *v;
|
1995-03-11 01:55:04 +03:00
|
|
|
register_t *retval;
|
1998-10-01 06:27:33 +04:00
|
|
|
{
|
|
|
|
/* XXX XAX This isn't this really int, int, siginfo_t *, is it? */
|
|
|
|
#if 0
|
|
|
|
struct linux_sys_rt_queueinfo_args /* {
|
|
|
|
syscallarg(int) pid;
|
|
|
|
syscallarg(int) signum;
|
|
|
|
syscallarg(siginfo_t *) uinfo;
|
|
|
|
} */ *uap = v;
|
|
|
|
#endif
|
1995-03-11 01:55:04 +03:00
|
|
|
|
1998-10-01 06:27:33 +04:00
|
|
|
/* XXX To really implement this we need to */
|
|
|
|
/* XXX keep a list of queued signals somewhere. */
|
|
|
|
return (linux_sys_kill(p, v, retval));
|
1995-03-11 01:55:04 +03:00
|
|
|
}
|
|
|
|
|
1995-03-01 02:24:35 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
linux_sys_kill(p, v, retval)
|
2000-03-30 15:24:16 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:37:27 +04:00
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct linux_sys_kill_args /* {
|
1995-03-01 02:24:35 +03:00
|
|
|
syscallarg(int) pid;
|
|
|
|
syscallarg(int) signum;
|
1995-09-20 02:37:27 +04:00
|
|
|
} */ *uap = v;
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sys_kill_args ka;
|
1999-12-05 01:26:52 +03:00
|
|
|
int sig;
|
1995-08-14 02:55:28 +04:00
|
|
|
|
|
|
|
SCARG(&ka, pid) = SCARG(uap, pid);
|
1999-12-05 01:26:52 +03:00
|
|
|
sig = SCARG(uap, signum);
|
|
|
|
if (sig < 0 || sig >= LINUX__NSIG)
|
|
|
|
return (EINVAL);
|
2002-04-01 02:22:43 +04:00
|
|
|
SCARG(&ka, signum) = linux_to_native_signo[sig];
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_kill(p, &ka, retval);
|
1995-03-01 02:24:35 +03:00
|
|
|
}
|
2000-08-23 21:02:18 +04:00
|
|
|
|
|
|
|
#ifdef LINUX_SS_ONSTACK
|
|
|
|
static void linux_to_native_sigaltstack __P((struct sigaltstack *,
|
|
|
|
const struct linux_sigaltstack *));
|
|
|
|
static void native_to_linux_sigaltstack __P((struct linux_sigaltstack *,
|
|
|
|
const struct sigaltstack *));
|
|
|
|
|
|
|
|
static void
|
|
|
|
linux_to_native_sigaltstack(bss, lss)
|
|
|
|
struct sigaltstack *bss;
|
|
|
|
const struct linux_sigaltstack *lss;
|
|
|
|
{
|
|
|
|
bss->ss_sp = lss->ss_sp;
|
|
|
|
bss->ss_size = lss->ss_size;
|
|
|
|
if (lss->ss_flags & LINUX_SS_ONSTACK)
|
|
|
|
bss->ss_flags = SS_ONSTACK;
|
|
|
|
else if (lss->ss_flags & LINUX_SS_DISABLE)
|
|
|
|
bss->ss_flags = SS_DISABLE;
|
|
|
|
else
|
|
|
|
bss->ss_flags = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
native_to_linux_sigaltstack(lss, bss)
|
|
|
|
struct linux_sigaltstack *lss;
|
|
|
|
const struct sigaltstack *bss;
|
|
|
|
{
|
|
|
|
lss->ss_sp = bss->ss_sp;
|
|
|
|
lss->ss_size = bss->ss_size;
|
|
|
|
if (bss->ss_flags & SS_ONSTACK)
|
|
|
|
lss->ss_flags = LINUX_SS_ONSTACK;
|
|
|
|
else if (bss->ss_flags & SS_DISABLE)
|
|
|
|
lss->ss_flags = LINUX_SS_DISABLE;
|
|
|
|
else
|
|
|
|
lss->ss_flags = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
linux_sys_sigaltstack(p, v, retval)
|
|
|
|
struct proc *p;
|
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct linux_sys_sigaltstack_args /* {
|
|
|
|
syscallarg(const struct linux_sigaltstack *) ss;
|
|
|
|
syscallarg(struct linux_sigaltstack *) oss;
|
|
|
|
} */ *uap = v;
|
|
|
|
struct linux_sigaltstack ss;
|
|
|
|
struct sigaltstack nss, oss;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
if (SCARG(uap, ss) != NULL) {
|
|
|
|
if ((error = copyin(SCARG(uap, ss), &ss, sizeof(ss))) != 0)
|
|
|
|
return error;
|
|
|
|
linux_to_native_sigaltstack(&nss, &ss);
|
|
|
|
}
|
|
|
|
|
|
|
|
error = sigaltstack1(p,
|
|
|
|
SCARG(uap, ss) ? &nss : NULL, SCARG(uap, oss) ? &oss : NULL);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
|
|
|
|
if (SCARG(uap, oss) != NULL) {
|
|
|
|
native_to_linux_sigaltstack(&ss, &oss);
|
|
|
|
if ((error = copyout(&ss, SCARG(uap, oss), sizeof(ss))) != 0)
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|