summaryrefslogtreecommitdiff
path: root/sys/compat/linux
diff options
context:
space:
mode:
authorNiklas Hallqvist <niklas@cvs.openbsd.org>2000-06-07 14:11:39 +0000
committerNiklas Hallqvist <niklas@cvs.openbsd.org>2000-06-07 14:11:39 +0000
commit086e0427153c0ddd6c79e36cc632417333bcf47a (patch)
tree613359f561ae653e4b1d3c1dc5004d2bcfe7ca8a /sys/compat/linux
parent7a6a4e3d9794f4655870368a1bdaaf1245a72aa5 (diff)
Implement sigaltstack
Diffstat (limited to 'sys/compat/linux')
-rw-r--r--sys/compat/linux/linux_signal.c115
-rw-r--r--sys/compat/linux/linux_signal.h10
-rw-r--r--sys/compat/linux/syscalls.master6
3 files changed, 94 insertions, 37 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));
}
diff --git a/sys/compat/linux/linux_signal.h b/sys/compat/linux/linux_signal.h
index d9e9bd28928..bfa67cd2ee6 100644
--- a/sys/compat/linux/linux_signal.h
+++ b/sys/compat/linux/linux_signal.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: linux_signal.h,v 1.4 2000/03/08 03:35:29 jasoni Exp $ */
+/* $OpenBSD: linux_signal.h,v 1.5 2000/06/07 14:11:38 niklas Exp $ */
/* $NetBSD: linux_signal.h,v 1.4 1995/08/27 20:51:51 fvdl Exp $ */
/*
@@ -66,6 +66,7 @@
#define LINUX_SIGWINCH 28
#define LINUX_SIGIO 29
#define LINUX_SIGPWR 30
+#define LINUX_SIGUNUSED 31
#define LINUX_NSIG 32
#define LINUX__NSIG 64
@@ -89,6 +90,7 @@ struct linux_old_sigaction {
u_long sa_flags;
void (*sa_restorer) __P((void));
};
+
struct linux_sigaction {
linux_handler_t sa__handler;
u_long sa_flags;
@@ -106,6 +108,12 @@ struct linux_sigaction {
#define LINUX_SA_ONESHOT 0x80000000
#define LINUX_SA_ALLBITS 0xf8000001
+struct linux_sigaltstack {
+ void *ss_sp;
+ int ss_flags;
+ size_t ss_size;
+};
+
extern int bsd_to_linux_sig[];
extern int linux_to_bsd_sig[];
diff --git a/sys/compat/linux/syscalls.master b/sys/compat/linux/syscalls.master
index abeefc2287a..abfeca5e091 100644
--- a/sys/compat/linux/syscalls.master
+++ b/sys/compat/linux/syscalls.master
@@ -1,4 +1,4 @@
- $OpenBSD: syscalls.master,v 1.23 2000/06/07 13:35:02 niklas Exp $
+ $OpenBSD: syscalls.master,v 1.24 2000/06/07 14:11:38 niklas Exp $
; $NetBSD: syscalls.master,v 1.15 1995/12/18 14:35:10 fvdl Exp $
; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
@@ -296,7 +296,9 @@
183 STD { int linux_sys_getcwd(char *bufp, size_t length); }
184 UNIMPL capget
185 UNIMPL capset
-186 UNIMPL sigaltstack
+186 STD { int linux_sys_sigaltstack( \
+ const struct linux_sigaltstack *nss, \
+ struct linux_sigaltstack *oss); }
187 UNIMPL sendfile
188 UNIMPL getpmsg
189 UNIMPL putpmsg