netbsd32_signal.c revision 1.1.2.2 1 1.1.2.2 bouyer /* $NetBSD: netbsd32_signal.c,v 1.1.2.2 2001/02/11 19:14:16 bouyer Exp $ */
2 1.1.2.2 bouyer
3 1.1.2.2 bouyer /*
4 1.1.2.2 bouyer * Copyright (c) 1998, 2001 Matthew R. Green
5 1.1.2.2 bouyer * All rights reserved.
6 1.1.2.2 bouyer *
7 1.1.2.2 bouyer * Redistribution and use in source and binary forms, with or without
8 1.1.2.2 bouyer * modification, are permitted provided that the following conditions
9 1.1.2.2 bouyer * are met:
10 1.1.2.2 bouyer * 1. Redistributions of source code must retain the above copyright
11 1.1.2.2 bouyer * notice, this list of conditions and the following disclaimer.
12 1.1.2.2 bouyer * 2. Redistributions in binary form must reproduce the above copyright
13 1.1.2.2 bouyer * notice, this list of conditions and the following disclaimer in the
14 1.1.2.2 bouyer * documentation and/or other materials provided with the distribution.
15 1.1.2.2 bouyer * 3. The name of the author may not be used to endorse or promote products
16 1.1.2.2 bouyer * derived from this software without specific prior written permission.
17 1.1.2.2 bouyer *
18 1.1.2.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 1.1.2.2 bouyer * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 1.1.2.2 bouyer * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 1.1.2.2 bouyer * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 1.1.2.2 bouyer * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 1.1.2.2 bouyer * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 1.1.2.2 bouyer * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25 1.1.2.2 bouyer * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 1.1.2.2 bouyer * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 1.1.2.2 bouyer * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 1.1.2.2 bouyer * SUCH DAMAGE.
29 1.1.2.2 bouyer */
30 1.1.2.2 bouyer
31 1.1.2.2 bouyer #include <sys/param.h>
32 1.1.2.2 bouyer #include <sys/systm.h>
33 1.1.2.2 bouyer #include <sys/malloc.h>
34 1.1.2.2 bouyer #include <sys/mount.h>
35 1.1.2.2 bouyer #include <sys/stat.h>
36 1.1.2.2 bouyer #include <sys/time.h>
37 1.1.2.2 bouyer #include <sys/signalvar.h>
38 1.1.2.2 bouyer #include <sys/proc.h>
39 1.1.2.2 bouyer
40 1.1.2.2 bouyer #include <compat/netbsd32/netbsd32.h>
41 1.1.2.2 bouyer #include <compat/netbsd32/netbsd32_syscallargs.h>
42 1.1.2.2 bouyer
43 1.1.2.2 bouyer int
44 1.1.2.2 bouyer netbsd32_sigaction(p, v, retval)
45 1.1.2.2 bouyer struct proc *p;
46 1.1.2.2 bouyer void *v;
47 1.1.2.2 bouyer register_t *retval;
48 1.1.2.2 bouyer {
49 1.1.2.2 bouyer struct netbsd32_sigaction_args /* {
50 1.1.2.2 bouyer syscallarg(int) signum;
51 1.1.2.2 bouyer syscallarg(const netbsd32_sigactionp_t) nsa;
52 1.1.2.2 bouyer syscallarg(netbsd32_sigactionp_t) osa;
53 1.1.2.2 bouyer } */ *uap = v;
54 1.1.2.2 bouyer struct sigaction nsa, osa;
55 1.1.2.2 bouyer struct netbsd32_sigaction *sa32p, sa32;
56 1.1.2.2 bouyer int error;
57 1.1.2.2 bouyer
58 1.1.2.2 bouyer if (SCARG(uap, nsa)) {
59 1.1.2.2 bouyer sa32p = (struct netbsd32_sigaction *)(u_long)SCARG(uap, nsa);
60 1.1.2.2 bouyer if (copyin(sa32p, &sa32, sizeof(sa32)))
61 1.1.2.2 bouyer return EFAULT;
62 1.1.2.2 bouyer nsa.sa_handler = (void *)(u_long)sa32.sa_handler;
63 1.1.2.2 bouyer nsa.sa_mask = sa32.sa_mask;
64 1.1.2.2 bouyer nsa.sa_flags = sa32.sa_flags;
65 1.1.2.2 bouyer }
66 1.1.2.2 bouyer error = sigaction1(p, SCARG(uap, signum),
67 1.1.2.2 bouyer SCARG(uap, nsa) ? &nsa : 0,
68 1.1.2.2 bouyer SCARG(uap, osa) ? &osa : 0);
69 1.1.2.2 bouyer
70 1.1.2.2 bouyer if (error)
71 1.1.2.2 bouyer return (error);
72 1.1.2.2 bouyer
73 1.1.2.2 bouyer if (SCARG(uap, osa)) {
74 1.1.2.2 bouyer sa32.sa_handler = (netbsd32_sigactionp_t)(u_long)osa.sa_handler;
75 1.1.2.2 bouyer sa32.sa_mask = osa.sa_mask;
76 1.1.2.2 bouyer sa32.sa_flags = osa.sa_flags;
77 1.1.2.2 bouyer sa32p = (struct netbsd32_sigaction *)(u_long)SCARG(uap, osa);
78 1.1.2.2 bouyer if (copyout(&sa32, sa32p, sizeof(sa32)))
79 1.1.2.2 bouyer return EFAULT;
80 1.1.2.2 bouyer }
81 1.1.2.2 bouyer
82 1.1.2.2 bouyer return (0);
83 1.1.2.2 bouyer }
84 1.1.2.2 bouyer
85 1.1.2.2 bouyer int
86 1.1.2.2 bouyer netbsd32___sigaltstack14(p, v, retval)
87 1.1.2.2 bouyer struct proc *p;
88 1.1.2.2 bouyer void *v;
89 1.1.2.2 bouyer register_t *retval;
90 1.1.2.2 bouyer {
91 1.1.2.2 bouyer struct netbsd32___sigaltstack14_args /* {
92 1.1.2.2 bouyer syscallarg(const netbsd32_sigaltstackp_t) nss;
93 1.1.2.2 bouyer syscallarg(netbsd32_sigaltstackp_t) oss;
94 1.1.2.2 bouyer } */ *uap = v;
95 1.1.2.2 bouyer struct netbsd32_sigaltstack s32;
96 1.1.2.2 bouyer struct sigaltstack nss, oss;
97 1.1.2.2 bouyer int error;
98 1.1.2.2 bouyer
99 1.1.2.2 bouyer if (SCARG(uap, nss)) {
100 1.1.2.2 bouyer error = copyin((caddr_t)(u_long)SCARG(uap, nss), &s32, sizeof(s32));
101 1.1.2.2 bouyer if (error)
102 1.1.2.2 bouyer return (error);
103 1.1.2.2 bouyer nss.ss_sp = (void *)(u_long)s32.ss_sp;
104 1.1.2.2 bouyer nss.ss_size = (size_t)s32.ss_size;
105 1.1.2.2 bouyer nss.ss_flags = s32.ss_flags;
106 1.1.2.2 bouyer }
107 1.1.2.2 bouyer error = sigaltstack1(p,
108 1.1.2.2 bouyer SCARG(uap, nss) ? &nss : 0, SCARG(uap, oss) ? &oss : 0);
109 1.1.2.2 bouyer if (error)
110 1.1.2.2 bouyer return (error);
111 1.1.2.2 bouyer if (SCARG(uap, oss)) {
112 1.1.2.2 bouyer s32.ss_sp = (netbsd32_voidp)(u_long)oss.ss_sp;
113 1.1.2.2 bouyer s32.ss_size = (netbsd32_size_t)oss.ss_size;
114 1.1.2.2 bouyer s32.ss_flags = oss.ss_flags;
115 1.1.2.2 bouyer error = copyout(&s32, (caddr_t)(u_long)SCARG(uap, oss), sizeof(s32));
116 1.1.2.2 bouyer if (error)
117 1.1.2.2 bouyer return (error);
118 1.1.2.2 bouyer }
119 1.1.2.2 bouyer return (0);
120 1.1.2.2 bouyer }
121 1.1.2.2 bouyer
122 1.1.2.2 bouyer /* ARGSUSED */
123 1.1.2.2 bouyer int
124 1.1.2.2 bouyer netbsd32___sigaction14(p, v, retval)
125 1.1.2.2 bouyer struct proc *p;
126 1.1.2.2 bouyer void *v;
127 1.1.2.2 bouyer register_t *retval;
128 1.1.2.2 bouyer {
129 1.1.2.2 bouyer struct netbsd32___sigaction14_args /* {
130 1.1.2.2 bouyer syscallarg(int) signum;
131 1.1.2.2 bouyer syscallarg(const struct sigaction *) nsa;
132 1.1.2.2 bouyer syscallarg(struct sigaction *) osa;
133 1.1.2.2 bouyer } */ *uap = v;
134 1.1.2.2 bouyer struct netbsd32_sigaction sa32;
135 1.1.2.2 bouyer struct sigaction nsa, osa;
136 1.1.2.2 bouyer int error;
137 1.1.2.2 bouyer
138 1.1.2.2 bouyer if (SCARG(uap, nsa)) {
139 1.1.2.2 bouyer error = copyin((caddr_t)(u_long)SCARG(uap, nsa),
140 1.1.2.2 bouyer &sa32, sizeof(sa32));
141 1.1.2.2 bouyer if (error)
142 1.1.2.2 bouyer return (error);
143 1.1.2.2 bouyer nsa.sa_handler = (void *)(u_long)sa32.sa_handler;
144 1.1.2.2 bouyer nsa.sa_mask = sa32.sa_mask;
145 1.1.2.2 bouyer nsa.sa_flags = sa32.sa_flags;
146 1.1.2.2 bouyer }
147 1.1.2.2 bouyer error = sigaction1(p, SCARG(uap, signum),
148 1.1.2.2 bouyer SCARG(uap, nsa) ? &nsa : 0, SCARG(uap, osa) ? &osa : 0);
149 1.1.2.2 bouyer if (error)
150 1.1.2.2 bouyer return (error);
151 1.1.2.2 bouyer if (SCARG(uap, osa)) {
152 1.1.2.2 bouyer sa32.sa_handler = (netbsd32_voidp)(u_long)osa.sa_handler;
153 1.1.2.2 bouyer sa32.sa_mask = osa.sa_mask;
154 1.1.2.2 bouyer sa32.sa_flags = osa.sa_flags;
155 1.1.2.2 bouyer error = copyout(&sa32, (caddr_t)(u_long)SCARG(uap, osa), sizeof(sa32));
156 1.1.2.2 bouyer if (error)
157 1.1.2.2 bouyer return (error);
158 1.1.2.2 bouyer }
159 1.1.2.2 bouyer return (0);
160 1.1.2.2 bouyer }
161