linux_signal.c (76166) | linux_signal.c (83221) |
---|---|
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 76166 2001-05-01 08:13:21Z markm $ | 28 * $FreeBSD: head/sys/compat/linux/linux_signal.c 83221 2001-09-08 19:07:04Z marcel $ |
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> 37#include <sys/sysproto.h> 38 39#include <machine/../linux/linux.h> 40#include <machine/../linux/linux_proto.h> 41#include <compat/linux/linux_signal.h> 42#include <compat/linux/linux_util.h> 43 44void | 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> 37#include <sys/sysproto.h> 38 39#include <machine/../linux/linux.h> 40#include <machine/../linux/linux_proto.h> 41#include <compat/linux/linux_signal.h> 42#include <compat/linux/linux_util.h> 43 44void |
45linux_to_bsd_sigset(linux_sigset_t *lss, sigset_t *bss) | 45linux_to_bsd_sigset(l_sigset_t *lss, sigset_t *bss) |
46{ 47 int b, l; 48 49 SIGEMPTYSET(*bss); 50 bss->__bits[0] = lss->__bits[0] & ~((1U << LINUX_SIGTBLSZ) - 1); 51 bss->__bits[1] = lss->__bits[1]; 52 for (l = 1; l <= LINUX_SIGTBLSZ; l++) { 53 if (LINUX_SIGISMEMBER(*lss, l)) { --- 4 unchanged lines hidden (view full) --- 58#endif 59 if (b) 60 SIGADDSET(*bss, b); 61 } 62 } 63} 64 65void | 46{ 47 int b, l; 48 49 SIGEMPTYSET(*bss); 50 bss->__bits[0] = lss->__bits[0] & ~((1U << LINUX_SIGTBLSZ) - 1); 51 bss->__bits[1] = lss->__bits[1]; 52 for (l = 1; l <= LINUX_SIGTBLSZ; l++) { 53 if (LINUX_SIGISMEMBER(*lss, l)) { --- 4 unchanged lines hidden (view full) --- 58#endif 59 if (b) 60 SIGADDSET(*bss, b); 61 } 62 } 63} 64 65void |
66bsd_to_linux_sigset(sigset_t *bss, linux_sigset_t *lss) | 66bsd_to_linux_sigset(sigset_t *bss, l_sigset_t *lss) |
67{ 68 int b, l; 69 70 LINUX_SIGEMPTYSET(*lss); 71 lss->__bits[0] = bss->__bits[0] & ~((1U << LINUX_SIGTBLSZ) - 1); 72 lss->__bits[1] = bss->__bits[1]; 73 for (b = 1; b <= LINUX_SIGTBLSZ; b++) { 74 if (SIGISMEMBER(*bss, b)) { --- 4 unchanged lines hidden (view full) --- 79#endif 80 if (l) 81 LINUX_SIGADDSET(*lss, l); 82 } 83 } 84} 85 86static void | 67{ 68 int b, l; 69 70 LINUX_SIGEMPTYSET(*lss); 71 lss->__bits[0] = bss->__bits[0] & ~((1U << LINUX_SIGTBLSZ) - 1); 72 lss->__bits[1] = bss->__bits[1]; 73 for (b = 1; b <= LINUX_SIGTBLSZ; b++) { 74 if (SIGISMEMBER(*bss, b)) { --- 4 unchanged lines hidden (view full) --- 79#endif 80 if (l) 81 LINUX_SIGADDSET(*lss, l); 82 } 83 } 84} 85 86static void |
87linux_to_bsd_sigaction(linux_sigaction_t *lsa, struct sigaction *bsa) | 87linux_to_bsd_sigaction(l_sigaction_t *lsa, struct sigaction *bsa) |
88{ 89 90 linux_to_bsd_sigset(&lsa->lsa_mask, &bsa->sa_mask); 91 bsa->sa_handler = lsa->lsa_handler; 92 bsa->sa_flags = 0; 93 if (lsa->lsa_flags & LINUX_SA_NOCLDSTOP) 94 bsa->sa_flags |= SA_NOCLDSTOP; 95 if (lsa->lsa_flags & LINUX_SA_NOCLDWAIT) --- 6 unchanged lines hidden (view full) --- 102 bsa->sa_flags |= SA_RESTART; 103 if (lsa->lsa_flags & LINUX_SA_ONESHOT) 104 bsa->sa_flags |= SA_RESETHAND; 105 if (lsa->lsa_flags & LINUX_SA_NOMASK) 106 bsa->sa_flags |= SA_NODEFER; 107} 108 109static void | 88{ 89 90 linux_to_bsd_sigset(&lsa->lsa_mask, &bsa->sa_mask); 91 bsa->sa_handler = lsa->lsa_handler; 92 bsa->sa_flags = 0; 93 if (lsa->lsa_flags & LINUX_SA_NOCLDSTOP) 94 bsa->sa_flags |= SA_NOCLDSTOP; 95 if (lsa->lsa_flags & LINUX_SA_NOCLDWAIT) --- 6 unchanged lines hidden (view full) --- 102 bsa->sa_flags |= SA_RESTART; 103 if (lsa->lsa_flags & LINUX_SA_ONESHOT) 104 bsa->sa_flags |= SA_RESETHAND; 105 if (lsa->lsa_flags & LINUX_SA_NOMASK) 106 bsa->sa_flags |= SA_NODEFER; 107} 108 109static void |
110bsd_to_linux_sigaction(struct sigaction *bsa, linux_sigaction_t *lsa) | 110bsd_to_linux_sigaction(struct sigaction *bsa, l_sigaction_t *lsa) |
111{ 112 113 bsd_to_linux_sigset(&bsa->sa_mask, &lsa->lsa_mask); 114 lsa->lsa_handler = bsa->sa_handler; 115 lsa->lsa_restorer = NULL; /* unsupported */ 116 lsa->lsa_flags = 0; 117 if (bsa->sa_flags & SA_NOCLDSTOP) 118 lsa->lsa_flags |= LINUX_SA_NOCLDSTOP; --- 7 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 | 111{ 112 113 bsd_to_linux_sigset(&bsa->sa_mask, &lsa->lsa_mask); 114 lsa->lsa_handler = bsa->sa_handler; 115 lsa->lsa_restorer = NULL; /* unsupported */ 116 lsa->lsa_flags = 0; 117 if (bsa->sa_flags & SA_NOCLDSTOP) 118 lsa->lsa_flags |= LINUX_SA_NOCLDSTOP; --- 7 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, linux_sigaction_t *linux_nsa, 135 linux_sigaction_t *linux_osa) | 134linux_do_sigaction(struct proc *p, 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) 143 return (EINVAL); --- 29 unchanged lines hidden (view full) --- 173 return (0); 174} 175 176 177#ifndef __alpha__ 178int 179linux_signal(struct proc *p, struct linux_signal_args *args) 180{ | 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) 143 return (EINVAL); --- 29 unchanged lines hidden (view full) --- 173 return (0); 174} 175 176 177#ifndef __alpha__ 178int 179linux_signal(struct proc *p, struct linux_signal_args *args) 180{ |
181 linux_sigaction_t nsa, osa; | 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 --- 6 unchanged lines hidden (view full) --- 196 197 return (error); 198} 199#endif /*!__alpha__*/ 200 201int 202linux_rt_sigaction(struct proc *p, struct linux_rt_sigaction_args *args) 203{ | 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 --- 6 unchanged lines hidden (view full) --- 196 197 return (error); 198} 199#endif /*!__alpha__*/ 200 201int 202linux_rt_sigaction(struct proc *p, struct linux_rt_sigaction_args *args) 203{ |
204 linux_sigaction_t nsa, osa; | 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, 211 (void *)args->oact, (long)args->sigsetsize); 212#endif 213 | 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, 211 (void *)args->oact, (long)args->sigsetsize); 212#endif 213 |
214 if (args->sigsetsize != sizeof(linux_sigset_t)) | 214 if (args->sigsetsize != sizeof(l_sigset_t)) |
215 return (EINVAL); 216 217 if (args->act != NULL) { | 215 return (EINVAL); 216 217 if (args->act != NULL) { |
218 error = copyin(args->act, &nsa, sizeof(linux_sigaction_t)); | 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, 224 args->act ? &nsa : NULL, 225 args->oact ? &osa : NULL); 226 227 if (args->oact != NULL && !error) { | 219 if (error) 220 return (error); 221 } 222 223 error = linux_do_sigaction(p, 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(linux_sigaction_t)); | 228 error = copyout(&osa, args->oact, sizeof(l_sigaction_t)); |
229 } 230 231 return (error); 232} 233 234static int | 229 } 230 231 return (error); 232} 233 234static int |
235linux_do_sigprocmask(struct proc *p, int how, linux_sigset_t *new, 236 linux_sigset_t *old) | 235linux_do_sigprocmask(struct proc *p, int how, l_sigset_t *new, 236 l_sigset_t *old) |
237{ 238 int error; 239 sigset_t mask; 240 241 error = 0; 242 p->p_retval[0] = 0; 243 244 PROC_LOCK(p); --- 24 unchanged lines hidden (view full) --- 269 270 return (error); 271} 272 273#ifndef __alpha__ 274int 275linux_sigprocmask(struct proc *p, struct linux_sigprocmask_args *args) 276{ | 237{ 238 int error; 239 sigset_t mask; 240 241 error = 0; 242 p->p_retval[0] = 0; 243 244 PROC_LOCK(p); --- 24 unchanged lines hidden (view full) --- 269 270 return (error); 271} 272 273#ifndef __alpha__ 274int 275linux_sigprocmask(struct proc *p, struct linux_sigprocmask_args *args) 276{ |
277 linux_osigset_t mask; 278 linux_sigset_t set, oset; | 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) { | 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(linux_osigset_t)); | 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 294 error = linux_do_sigprocmask(p, args->how, 295 args->mask ? &set : NULL, 296 args->omask ? &oset : NULL); 297 298 if (args->omask != NULL && !error) { 299 mask = oset.__bits[0]; | 288 if (error) 289 return (error); 290 LINUX_SIGEMPTYSET(set); 291 set.__bits[0] = mask; 292 } 293 294 error = linux_do_sigprocmask(p, 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(linux_osigset_t)); | 300 error = copyout(&mask, args->omask, sizeof(l_osigset_t)); |
301 } 302 303 return (error); 304} 305#endif /*!__alpha__*/ 306 307int 308linux_rt_sigprocmask(struct proc *p, struct linux_rt_sigprocmask_args *args) 309{ | 301 } 302 303 return (error); 304} 305#endif /*!__alpha__*/ 306 307int 308linux_rt_sigprocmask(struct proc *p, struct linux_rt_sigprocmask_args *args) 309{ |
310 linux_sigset_t set, oset; | 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, 317 (void *)args->omask, (long)args->sigsetsize); 318#endif 319 | 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, 317 (void *)args->omask, (long)args->sigsetsize); 318#endif 319 |
320 if (args->sigsetsize != sizeof(linux_sigset_t)) | 320 if (args->sigsetsize != sizeof(l_sigset_t)) |
321 return EINVAL; 322 323 if (args->mask != NULL) { | 321 return EINVAL; 322 323 if (args->mask != NULL) { |
324 error = copyin(args->mask, &set, sizeof(linux_sigset_t)); | 324 error = copyin(args->mask, &set, sizeof(l_sigset_t)); |
325 if (error) 326 return (error); 327 } 328 329 error = linux_do_sigprocmask(p, args->how, 330 args->mask ? &set : NULL, 331 args->omask ? &oset : NULL); 332 333 if (args->omask != NULL && !error) { | 325 if (error) 326 return (error); 327 } 328 329 error = linux_do_sigprocmask(p, 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(linux_sigset_t)); | 334 error = copyout(&oset, args->omask, sizeof(l_sigset_t)); |
335 } 336 337 return (error); 338} 339 340#ifndef __alpha__ 341int | 335 } 336 337 return (error); 338} 339 340#ifndef __alpha__ 341int |
342linux_siggetmask(struct proc *p, struct linux_siggetmask_args *args) | 342linux_sgetmask(struct proc *p, struct linux_sgetmask_args *args) |
343{ | 343{ |
344 linux_sigset_t mask; | 344 l_sigset_t mask; |
345 346#ifdef DEBUG | 345 346#ifdef DEBUG |
347 if (ldebug(siggetmask)) 348 printf(ARGS(siggetmask, "")); | 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); 354 p->p_retval[0] = mask.__bits[0]; 355 return (0); 356} 357 358int | 349#endif 350 351 PROC_LOCK(p); 352 bsd_to_linux_sigset(&p->p_sigmask, &mask); 353 PROC_UNLOCK(p); 354 p->p_retval[0] = mask.__bits[0]; 355 return (0); 356} 357 358int |
359linux_sigsetmask(struct proc *p, struct linux_sigsetmask_args *args) | 359linux_ssetmask(struct proc *p, struct linux_ssetmask_args *args) |
360{ | 360{ |
361 linux_sigset_t lset; | 361 l_sigset_t lset; |
362 sigset_t bset; 363 364#ifdef DEBUG | 362 sigset_t bset; 363 364#ifdef DEBUG |
365 if (ldebug(sigsetmask)) 366 printf(ARGS(sigsetmask, "%08lx"), (unsigned long)args->mask); | 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); 371 p->p_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 382linux_sigpending(struct proc *p, struct linux_sigpending_args *args) 383{ 384 sigset_t bset; | 367#endif 368 369 PROC_LOCK(p); 370 bsd_to_linux_sigset(&p->p_sigmask, &lset); 371 p->p_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 382linux_sigpending(struct proc *p, struct linux_sigpending_args *args) 383{ 384 sigset_t bset; |
385 linux_sigset_t lset; 386 linux_osigset_t mask; | 385 l_sigset_t lset; 386 l_osigset_t mask; |
387 388#ifdef DEBUG 389 if (ldebug(sigpending)) 390 printf(ARGS(sigpending, "*")); 391#endif 392 393 PROC_LOCK(p); 394 bset = p->p_siglist; --- 37 unchanged lines hidden --- | 387 388#ifdef DEBUG 389 if (ldebug(sigpending)) 390 printf(ARGS(sigpending, "*")); 391#endif 392 393 PROC_LOCK(p); 394 bset = p->p_siglist; --- 37 unchanged lines hidden --- |