Deleted Added
full compact
linux_signal.c (83221) linux_signal.c (83366)
1/*-
2 * Copyright (c) 1994-1995 S�ren Schmidt
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
1/*-
2 * Copyright (c) 1994-1995 S�ren Schmidt
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * $FreeBSD: head/sys/compat/linux/linux_signal.c 83221 2001-09-08 19:07:04Z marcel $
28 * $FreeBSD: head/sys/compat/linux/linux_signal.c 83366 2001-09-12 08:38:13Z julian $
29 */
30
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/lock.h>
34#include <sys/mutex.h>
35#include <sys/proc.h>
36#include <sys/signalvar.h>

--- 89 unchanged lines hidden (view full) ---

126 lsa->lsa_flags |= LINUX_SA_RESTART;
127 if (bsa->sa_flags & SA_RESETHAND)
128 lsa->lsa_flags |= LINUX_SA_ONESHOT;
129 if (bsa->sa_flags & SA_NODEFER)
130 lsa->lsa_flags |= LINUX_SA_NOMASK;
131}
132
133int
29 */
30
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/lock.h>
34#include <sys/mutex.h>
35#include <sys/proc.h>
36#include <sys/signalvar.h>

--- 89 unchanged lines hidden (view full) ---

126 lsa->lsa_flags |= LINUX_SA_RESTART;
127 if (bsa->sa_flags & SA_RESETHAND)
128 lsa->lsa_flags |= LINUX_SA_ONESHOT;
129 if (bsa->sa_flags & SA_NODEFER)
130 lsa->lsa_flags |= LINUX_SA_NOMASK;
131}
132
133int
134linux_do_sigaction(struct proc *p, int linux_sig, l_sigaction_t *linux_nsa,
134linux_do_sigaction(struct thread *td, int linux_sig, l_sigaction_t *linux_nsa,
135 l_sigaction_t *linux_osa)
136{
137 struct sigaction *nsa, *osa;
138 struct sigaction_args sa_args;
139 int error;
140 caddr_t sg = stackgap_init();
141
142 if (linux_sig <= 0 || linux_sig > LINUX_NSIG)

--- 15 unchanged lines hidden (view full) ---

158 if (linux_sig <= LINUX_SIGTBLSZ)
159 sa_args.sig = linux_to_bsd_signal[_SIG_IDX(linux_sig)];
160 else
161#endif
162 sa_args.sig = linux_sig;
163
164 sa_args.act = nsa;
165 sa_args.oact = osa;
135 l_sigaction_t *linux_osa)
136{
137 struct sigaction *nsa, *osa;
138 struct sigaction_args sa_args;
139 int error;
140 caddr_t sg = stackgap_init();
141
142 if (linux_sig <= 0 || linux_sig > LINUX_NSIG)

--- 15 unchanged lines hidden (view full) ---

158 if (linux_sig <= LINUX_SIGTBLSZ)
159 sa_args.sig = linux_to_bsd_signal[_SIG_IDX(linux_sig)];
160 else
161#endif
162 sa_args.sig = linux_sig;
163
164 sa_args.act = nsa;
165 sa_args.oact = osa;
166 error = sigaction(p, &sa_args);
166 error = sigaction(td, &sa_args);
167 if (error)
168 return (error);
169
170 if (linux_osa != NULL)
171 bsd_to_linux_sigaction(osa, linux_osa);
172
173 return (0);
174}
175
176
177#ifndef __alpha__
178int
167 if (error)
168 return (error);
169
170 if (linux_osa != NULL)
171 bsd_to_linux_sigaction(osa, linux_osa);
172
173 return (0);
174}
175
176
177#ifndef __alpha__
178int
179linux_signal(struct proc *p, struct linux_signal_args *args)
179linux_signal(struct thread *td, struct linux_signal_args *args)
180{
181 l_sigaction_t nsa, osa;
182 int error;
183
184#ifdef DEBUG
185 if (ldebug(signal))
186 printf(ARGS(signal, "%d, %p"),
187 args->sig, (void *)args->handler);
188#endif
189
190 nsa.lsa_handler = args->handler;
191 nsa.lsa_flags = LINUX_SA_ONESHOT | LINUX_SA_NOMASK;
192 LINUX_SIGEMPTYSET(nsa.lsa_mask);
193
180{
181 l_sigaction_t nsa, osa;
182 int error;
183
184#ifdef DEBUG
185 if (ldebug(signal))
186 printf(ARGS(signal, "%d, %p"),
187 args->sig, (void *)args->handler);
188#endif
189
190 nsa.lsa_handler = args->handler;
191 nsa.lsa_flags = LINUX_SA_ONESHOT | LINUX_SA_NOMASK;
192 LINUX_SIGEMPTYSET(nsa.lsa_mask);
193
194 error = linux_do_sigaction(p, args->sig, &nsa, &osa);
195 p->p_retval[0] = (int)osa.lsa_handler;
194 error = linux_do_sigaction(td, args->sig, &nsa, &osa);
195 td->td_retval[0] = (int)osa.lsa_handler;
196
197 return (error);
198}
199#endif /*!__alpha__*/
200
201int
196
197 return (error);
198}
199#endif /*!__alpha__*/
200
201int
202linux_rt_sigaction(struct proc *p, struct linux_rt_sigaction_args *args)
202linux_rt_sigaction(struct thread *td, struct linux_rt_sigaction_args *args)
203{
204 l_sigaction_t nsa, osa;
205 int error;
206
207#ifdef DEBUG
208 if (ldebug(rt_sigaction))
209 printf(ARGS(rt_sigaction, "%ld, %p, %p, %ld"),
210 (long)args->sig, (void *)args->act,

--- 4 unchanged lines hidden (view full) ---

215 return (EINVAL);
216
217 if (args->act != NULL) {
218 error = copyin(args->act, &nsa, sizeof(l_sigaction_t));
219 if (error)
220 return (error);
221 }
222
203{
204 l_sigaction_t nsa, osa;
205 int error;
206
207#ifdef DEBUG
208 if (ldebug(rt_sigaction))
209 printf(ARGS(rt_sigaction, "%ld, %p, %p, %ld"),
210 (long)args->sig, (void *)args->act,

--- 4 unchanged lines hidden (view full) ---

215 return (EINVAL);
216
217 if (args->act != NULL) {
218 error = copyin(args->act, &nsa, sizeof(l_sigaction_t));
219 if (error)
220 return (error);
221 }
222
223 error = linux_do_sigaction(p, args->sig,
223 error = linux_do_sigaction(td, args->sig,
224 args->act ? &nsa : NULL,
225 args->oact ? &osa : NULL);
226
227 if (args->oact != NULL && !error) {
228 error = copyout(&osa, args->oact, sizeof(l_sigaction_t));
229 }
230
231 return (error);
232}
233
234static int
224 args->act ? &nsa : NULL,
225 args->oact ? &osa : NULL);
226
227 if (args->oact != NULL && !error) {
228 error = copyout(&osa, args->oact, sizeof(l_sigaction_t));
229 }
230
231 return (error);
232}
233
234static int
235linux_do_sigprocmask(struct proc *p, int how, l_sigset_t *new,
235linux_do_sigprocmask(struct thread *td, int how, l_sigset_t *new,
236 l_sigset_t *old)
237{
238 int error;
239 sigset_t mask;
236 l_sigset_t *old)
237{
238 int error;
239 sigset_t mask;
240 struct proc *p = td->td_proc;
240
241 error = 0;
241
242 error = 0;
242 p->p_retval[0] = 0;
243 td->td_retval[0] = 0;
243
244 PROC_LOCK(p);
245 if (old != NULL)
246 bsd_to_linux_sigset(&p->p_sigmask, old);
247
248 if (new != NULL) {
249 linux_to_bsd_sigset(new, &mask);
250

--- 16 unchanged lines hidden (view full) ---

267 }
268 PROC_UNLOCK(p);
269
270 return (error);
271}
272
273#ifndef __alpha__
274int
244
245 PROC_LOCK(p);
246 if (old != NULL)
247 bsd_to_linux_sigset(&p->p_sigmask, old);
248
249 if (new != NULL) {
250 linux_to_bsd_sigset(new, &mask);
251

--- 16 unchanged lines hidden (view full) ---

268 }
269 PROC_UNLOCK(p);
270
271 return (error);
272}
273
274#ifndef __alpha__
275int
275linux_sigprocmask(struct proc *p, struct linux_sigprocmask_args *args)
276linux_sigprocmask(struct thread *td, struct linux_sigprocmask_args *args)
276{
277 l_osigset_t mask;
278 l_sigset_t set, oset;
279 int error;
280
281#ifdef DEBUG
282 if (ldebug(sigprocmask))
283 printf(ARGS(sigprocmask, "%d, *, *"), args->how);
284#endif
285
286 if (args->mask != NULL) {
287 error = copyin(args->mask, &mask, sizeof(l_osigset_t));
288 if (error)
289 return (error);
290 LINUX_SIGEMPTYSET(set);
291 set.__bits[0] = mask;
292 }
293
277{
278 l_osigset_t mask;
279 l_sigset_t set, oset;
280 int error;
281
282#ifdef DEBUG
283 if (ldebug(sigprocmask))
284 printf(ARGS(sigprocmask, "%d, *, *"), args->how);
285#endif
286
287 if (args->mask != NULL) {
288 error = copyin(args->mask, &mask, sizeof(l_osigset_t));
289 if (error)
290 return (error);
291 LINUX_SIGEMPTYSET(set);
292 set.__bits[0] = mask;
293 }
294
294 error = linux_do_sigprocmask(p, args->how,
295 error = linux_do_sigprocmask(td, args->how,
295 args->mask ? &set : NULL,
296 args->omask ? &oset : NULL);
297
298 if (args->omask != NULL && !error) {
299 mask = oset.__bits[0];
300 error = copyout(&mask, args->omask, sizeof(l_osigset_t));
301 }
302
303 return (error);
304}
305#endif /*!__alpha__*/
306
307int
296 args->mask ? &set : NULL,
297 args->omask ? &oset : NULL);
298
299 if (args->omask != NULL && !error) {
300 mask = oset.__bits[0];
301 error = copyout(&mask, args->omask, sizeof(l_osigset_t));
302 }
303
304 return (error);
305}
306#endif /*!__alpha__*/
307
308int
308linux_rt_sigprocmask(struct proc *p, struct linux_rt_sigprocmask_args *args)
309linux_rt_sigprocmask(struct thread *td, struct linux_rt_sigprocmask_args *args)
309{
310 l_sigset_t set, oset;
311 int error;
312
313#ifdef DEBUG
314 if (ldebug(rt_sigprocmask))
315 printf(ARGS(rt_sigprocmask, "%d, %p, %p, %ld"),
316 args->how, (void *)args->mask,

--- 4 unchanged lines hidden (view full) ---

321 return EINVAL;
322
323 if (args->mask != NULL) {
324 error = copyin(args->mask, &set, sizeof(l_sigset_t));
325 if (error)
326 return (error);
327 }
328
310{
311 l_sigset_t set, oset;
312 int error;
313
314#ifdef DEBUG
315 if (ldebug(rt_sigprocmask))
316 printf(ARGS(rt_sigprocmask, "%d, %p, %p, %ld"),
317 args->how, (void *)args->mask,

--- 4 unchanged lines hidden (view full) ---

322 return EINVAL;
323
324 if (args->mask != NULL) {
325 error = copyin(args->mask, &set, sizeof(l_sigset_t));
326 if (error)
327 return (error);
328 }
329
329 error = linux_do_sigprocmask(p, args->how,
330 error = linux_do_sigprocmask(td, args->how,
330 args->mask ? &set : NULL,
331 args->omask ? &oset : NULL);
332
333 if (args->omask != NULL && !error) {
334 error = copyout(&oset, args->omask, sizeof(l_sigset_t));
335 }
336
337 return (error);
338}
339
340#ifndef __alpha__
341int
331 args->mask ? &set : NULL,
332 args->omask ? &oset : NULL);
333
334 if (args->omask != NULL && !error) {
335 error = copyout(&oset, args->omask, sizeof(l_sigset_t));
336 }
337
338 return (error);
339}
340
341#ifndef __alpha__
342int
342linux_sgetmask(struct proc *p, struct linux_sgetmask_args *args)
343linux_sgetmask(struct thread *td, struct linux_sgetmask_args *args)
343{
344{
345 struct proc *p = td->td_proc;
344 l_sigset_t mask;
345
346#ifdef DEBUG
347 if (ldebug(sgetmask))
348 printf(ARGS(sgetmask, ""));
349#endif
350
351 PROC_LOCK(p);
352 bsd_to_linux_sigset(&p->p_sigmask, &mask);
353 PROC_UNLOCK(p);
346 l_sigset_t mask;
347
348#ifdef DEBUG
349 if (ldebug(sgetmask))
350 printf(ARGS(sgetmask, ""));
351#endif
352
353 PROC_LOCK(p);
354 bsd_to_linux_sigset(&p->p_sigmask, &mask);
355 PROC_UNLOCK(p);
354 p->p_retval[0] = mask.__bits[0];
356 td->td_retval[0] = mask.__bits[0];
355 return (0);
356}
357
358int
357 return (0);
358}
359
360int
359linux_ssetmask(struct proc *p, struct linux_ssetmask_args *args)
361linux_ssetmask(struct thread *td, struct linux_ssetmask_args *args)
360{
362{
363 struct proc *p = td->td_proc;
361 l_sigset_t lset;
362 sigset_t bset;
363
364#ifdef DEBUG
365 if (ldebug(ssetmask))
366 printf(ARGS(ssetmask, "%08lx"), (unsigned long)args->mask);
367#endif
368
369 PROC_LOCK(p);
370 bsd_to_linux_sigset(&p->p_sigmask, &lset);
364 l_sigset_t lset;
365 sigset_t bset;
366
367#ifdef DEBUG
368 if (ldebug(ssetmask))
369 printf(ARGS(ssetmask, "%08lx"), (unsigned long)args->mask);
370#endif
371
372 PROC_LOCK(p);
373 bsd_to_linux_sigset(&p->p_sigmask, &lset);
371 p->p_retval[0] = lset.__bits[0];
374 td->td_retval[0] = lset.__bits[0];
372 LINUX_SIGEMPTYSET(lset);
373 lset.__bits[0] = args->mask;
374 linux_to_bsd_sigset(&lset, &bset);
375 p->p_sigmask = bset;
376 SIG_CANTMASK(p->p_sigmask);
377 PROC_UNLOCK(p);
378 return (0);
379}
380
381int
375 LINUX_SIGEMPTYSET(lset);
376 lset.__bits[0] = args->mask;
377 linux_to_bsd_sigset(&lset, &bset);
378 p->p_sigmask = bset;
379 SIG_CANTMASK(p->p_sigmask);
380 PROC_UNLOCK(p);
381 return (0);
382}
383
384int
382linux_sigpending(struct proc *p, struct linux_sigpending_args *args)
385linux_sigpending(struct thread *td, struct linux_sigpending_args *args)
383{
386{
387 struct proc *p = td->td_proc;
384 sigset_t bset;
385 l_sigset_t lset;
386 l_osigset_t mask;
387
388#ifdef DEBUG
389 if (ldebug(sigpending))
390 printf(ARGS(sigpending, "*"));
391#endif

--- 4 unchanged lines hidden (view full) ---

396 bsd_to_linux_sigset(&bset, &lset);
397 PROC_UNLOCK(p);
398 mask = lset.__bits[0];
399 return (copyout(&mask, args->mask, sizeof(mask)));
400}
401#endif /*!__alpha__*/
402
403int
388 sigset_t bset;
389 l_sigset_t lset;
390 l_osigset_t mask;
391
392#ifdef DEBUG
393 if (ldebug(sigpending))
394 printf(ARGS(sigpending, "*"));
395#endif

--- 4 unchanged lines hidden (view full) ---

400 bsd_to_linux_sigset(&bset, &lset);
401 PROC_UNLOCK(p);
402 mask = lset.__bits[0];
403 return (copyout(&mask, args->mask, sizeof(mask)));
404}
405#endif /*!__alpha__*/
406
407int
404linux_kill(struct proc *p, struct linux_kill_args *args)
408linux_kill(struct thread *td, struct linux_kill_args *args)
405{
406 struct kill_args /* {
407 int pid;
408 int signum;
409 } */ tmp;
410
411#ifdef DEBUG
412 if (ldebug(kill))

--- 9 unchanged lines hidden (view full) ---

422#ifndef __alpha__
423 if (args->signum > 0 && args->signum <= LINUX_SIGTBLSZ)
424 tmp.signum = linux_to_bsd_signal[_SIG_IDX(args->signum)];
425 else
426#endif
427 tmp.signum = args->signum;
428
429 tmp.pid = args->pid;
409{
410 struct kill_args /* {
411 int pid;
412 int signum;
413 } */ tmp;
414
415#ifdef DEBUG
416 if (ldebug(kill))

--- 9 unchanged lines hidden (view full) ---

426#ifndef __alpha__
427 if (args->signum > 0 && args->signum <= LINUX_SIGTBLSZ)
428 tmp.signum = linux_to_bsd_signal[_SIG_IDX(args->signum)];
429 else
430#endif
431 tmp.signum = args->signum;
432
433 tmp.pid = args->pid;
430 return (kill(p, &tmp));
434 return (kill(td, &tmp));
431}
435}