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 9 * notice, this list of conditions and the following disclaimer 10 * in this position and unchanged. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. The name of the author may not be used to endorse or promote products 15 * derived from this software withough specific prior written permission 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 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 9 * notice, this list of conditions and the following disclaimer 10 * in this position and unchanged. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. The name of the author may not be used to endorse or promote products 15 * derived from this software withough specific prior written permission 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 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 69539 2000-12-03 01:30:31Z marcel $
| 28 * $FreeBSD: head/sys/compat/linux/linux_signal.c 70061 2000-12-15 19:41:27Z jhb $
|
29 */ 30 31#include <sys/param.h> 32#include <sys/systm.h> 33#include <sys/sysproto.h> 34#include <sys/proc.h> 35#include <sys/signalvar.h> 36 37#include <machine/../linux/linux.h> 38#include <machine/../linux/linux_proto.h> 39#include <compat/linux/linux_signal.h> 40#include <compat/linux/linux_util.h> 41 42void 43linux_to_bsd_sigset(linux_sigset_t *lss, sigset_t *bss) 44{ 45 int b, l; 46 47 SIGEMPTYSET(*bss); 48 bss->__bits[0] = lss->__bits[0] & ~((1U << LINUX_SIGTBLSZ) - 1); 49 bss->__bits[1] = lss->__bits[1]; 50 for (l = 1; l <= LINUX_SIGTBLSZ; l++) { 51 if (LINUX_SIGISMEMBER(*lss, l)) { 52#ifdef __alpha__ 53 b = _SIG_IDX(l); 54#else 55 b = linux_to_bsd_signal[_SIG_IDX(l)]; 56#endif 57 if (b) 58 SIGADDSET(*bss, b); 59 } 60 } 61} 62 63void 64bsd_to_linux_sigset(sigset_t *bss, linux_sigset_t *lss) 65{ 66 int b, l; 67 68 LINUX_SIGEMPTYSET(*lss); 69 lss->__bits[0] = bss->__bits[0] & ~((1U << LINUX_SIGTBLSZ) - 1); 70 lss->__bits[1] = bss->__bits[1]; 71 for (b = 1; b <= LINUX_SIGTBLSZ; b++) { 72 if (SIGISMEMBER(*bss, b)) { 73#if __alpha__ 74 l = _SIG_IDX(b); 75#else 76 l = bsd_to_linux_signal[_SIG_IDX(b)]; 77#endif 78 if (l) 79 LINUX_SIGADDSET(*lss, l); 80 } 81 } 82} 83 84static void 85linux_to_bsd_sigaction(linux_sigaction_t *lsa, struct sigaction *bsa) 86{ 87 88 linux_to_bsd_sigset(&lsa->lsa_mask, &bsa->sa_mask); 89 bsa->sa_handler = lsa->lsa_handler; 90 bsa->sa_flags = 0; 91 if (lsa->lsa_flags & LINUX_SA_NOCLDSTOP) 92 bsa->sa_flags |= SA_NOCLDSTOP; 93 if (lsa->lsa_flags & LINUX_SA_NOCLDWAIT) 94 bsa->sa_flags |= SA_NOCLDWAIT; 95 if (lsa->lsa_flags & LINUX_SA_SIGINFO) 96 bsa->sa_flags |= SA_SIGINFO; 97 if (lsa->lsa_flags & LINUX_SA_ONSTACK) 98 bsa->sa_flags |= SA_ONSTACK; 99 if (lsa->lsa_flags & LINUX_SA_RESTART) 100 bsa->sa_flags |= SA_RESTART; 101 if (lsa->lsa_flags & LINUX_SA_ONESHOT) 102 bsa->sa_flags |= SA_RESETHAND; 103 if (lsa->lsa_flags & LINUX_SA_NOMASK) 104 bsa->sa_flags |= SA_NODEFER; 105} 106 107static void 108bsd_to_linux_sigaction(struct sigaction *bsa, linux_sigaction_t *lsa) 109{ 110 111 bsd_to_linux_sigset(&bsa->sa_mask, &lsa->lsa_mask); 112 lsa->lsa_handler = bsa->sa_handler; 113 lsa->lsa_restorer = NULL; /* unsupported */ 114 lsa->lsa_flags = 0; 115 if (bsa->sa_flags & SA_NOCLDSTOP) 116 lsa->lsa_flags |= LINUX_SA_NOCLDSTOP; 117 if (bsa->sa_flags & SA_NOCLDWAIT) 118 lsa->lsa_flags |= LINUX_SA_NOCLDWAIT; 119 if (bsa->sa_flags & SA_SIGINFO) 120 lsa->lsa_flags |= LINUX_SA_SIGINFO; 121 if (bsa->sa_flags & SA_ONSTACK) 122 lsa->lsa_flags |= LINUX_SA_ONSTACK; 123 if (bsa->sa_flags & SA_RESTART) 124 lsa->lsa_flags |= LINUX_SA_RESTART; 125 if (bsa->sa_flags & SA_RESETHAND) 126 lsa->lsa_flags |= LINUX_SA_ONESHOT; 127 if (bsa->sa_flags & SA_NODEFER) 128 lsa->lsa_flags |= LINUX_SA_NOMASK; 129} 130 131int 132linux_do_sigaction(struct proc *p, int linux_sig, linux_sigaction_t *linux_nsa, 133 linux_sigaction_t *linux_osa) 134{ 135 struct sigaction *nsa, *osa; 136 struct sigaction_args sa_args; 137 int error; 138 caddr_t sg = stackgap_init(); 139 140 if (linux_sig <= 0 || linux_sig > LINUX_NSIG) 141 return (EINVAL); 142 143 if (linux_osa != NULL) 144 osa = stackgap_alloc(&sg, sizeof(struct sigaction)); 145 else 146 osa = NULL; 147 148 if (linux_nsa != NULL) { 149 nsa = stackgap_alloc(&sg, sizeof(struct sigaction)); 150 linux_to_bsd_sigaction(linux_nsa, nsa); 151 } 152 else 153 nsa = NULL; 154 155#ifndef __alpha__ 156 if (linux_sig <= LINUX_SIGTBLSZ) 157 sa_args.sig = linux_to_bsd_signal[_SIG_IDX(linux_sig)]; 158 else 159#endif 160 sa_args.sig = linux_sig; 161 162 sa_args.act = nsa; 163 sa_args.oact = osa; 164 error = sigaction(p, &sa_args); 165 if (error) 166 return (error); 167 168 if (linux_osa != NULL) 169 bsd_to_linux_sigaction(osa, linux_osa); 170 171 return (0); 172} 173 174 175#ifndef __alpha__ 176int 177linux_signal(struct proc *p, struct linux_signal_args *args) 178{ 179 linux_sigaction_t nsa, osa; 180 int error; 181 182#ifdef DEBUG 183 printf("Linux-emul(%ld): signal(%d, %p)\n", 184 (long)p->p_pid, args->sig, (void *)args->handler); 185#endif 186 187 nsa.lsa_handler = args->handler; 188 nsa.lsa_flags = LINUX_SA_ONESHOT | LINUX_SA_NOMASK; 189 LINUX_SIGEMPTYSET(nsa.lsa_mask); 190 191 error = linux_do_sigaction(p, args->sig, &nsa, &osa); 192 p->p_retval[0] = (int)osa.lsa_handler; 193 194 return (error); 195} 196#endif /*!__alpha__*/ 197 198int 199linux_rt_sigaction(struct proc *p, struct linux_rt_sigaction_args *args) 200{ 201 linux_sigaction_t nsa, osa; 202 int error; 203 204#ifdef DEBUG 205 printf("Linux-emul(%ld): rt_sigaction(%ld, %p, %p, %ld)\n", 206 (long)p->p_pid, (long)args->sig, (void *)args->act, 207 (void *)args->oact, (long)args->sigsetsize); 208#endif 209 210 if (args->sigsetsize != sizeof(linux_sigset_t)) 211 return (EINVAL); 212 213 if (args->act != NULL) { 214 error = copyin(args->act, &nsa, sizeof(linux_sigaction_t)); 215 if (error) 216 return (error); 217 } 218 219 error = linux_do_sigaction(p, args->sig, 220 args->act ? &nsa : NULL, 221 args->oact ? &osa : NULL); 222 223 if (args->oact != NULL && !error) { 224 error = copyout(&osa, args->oact, sizeof(linux_sigaction_t)); 225 } 226 227 return (error); 228} 229 230static int 231linux_do_sigprocmask(struct proc *p, int how, linux_sigset_t *new, 232 linux_sigset_t *old) 233{
| 29 */ 30 31#include <sys/param.h> 32#include <sys/systm.h> 33#include <sys/sysproto.h> 34#include <sys/proc.h> 35#include <sys/signalvar.h> 36 37#include <machine/../linux/linux.h> 38#include <machine/../linux/linux_proto.h> 39#include <compat/linux/linux_signal.h> 40#include <compat/linux/linux_util.h> 41 42void 43linux_to_bsd_sigset(linux_sigset_t *lss, sigset_t *bss) 44{ 45 int b, l; 46 47 SIGEMPTYSET(*bss); 48 bss->__bits[0] = lss->__bits[0] & ~((1U << LINUX_SIGTBLSZ) - 1); 49 bss->__bits[1] = lss->__bits[1]; 50 for (l = 1; l <= LINUX_SIGTBLSZ; l++) { 51 if (LINUX_SIGISMEMBER(*lss, l)) { 52#ifdef __alpha__ 53 b = _SIG_IDX(l); 54#else 55 b = linux_to_bsd_signal[_SIG_IDX(l)]; 56#endif 57 if (b) 58 SIGADDSET(*bss, b); 59 } 60 } 61} 62 63void 64bsd_to_linux_sigset(sigset_t *bss, linux_sigset_t *lss) 65{ 66 int b, l; 67 68 LINUX_SIGEMPTYSET(*lss); 69 lss->__bits[0] = bss->__bits[0] & ~((1U << LINUX_SIGTBLSZ) - 1); 70 lss->__bits[1] = bss->__bits[1]; 71 for (b = 1; b <= LINUX_SIGTBLSZ; b++) { 72 if (SIGISMEMBER(*bss, b)) { 73#if __alpha__ 74 l = _SIG_IDX(b); 75#else 76 l = bsd_to_linux_signal[_SIG_IDX(b)]; 77#endif 78 if (l) 79 LINUX_SIGADDSET(*lss, l); 80 } 81 } 82} 83 84static void 85linux_to_bsd_sigaction(linux_sigaction_t *lsa, struct sigaction *bsa) 86{ 87 88 linux_to_bsd_sigset(&lsa->lsa_mask, &bsa->sa_mask); 89 bsa->sa_handler = lsa->lsa_handler; 90 bsa->sa_flags = 0; 91 if (lsa->lsa_flags & LINUX_SA_NOCLDSTOP) 92 bsa->sa_flags |= SA_NOCLDSTOP; 93 if (lsa->lsa_flags & LINUX_SA_NOCLDWAIT) 94 bsa->sa_flags |= SA_NOCLDWAIT; 95 if (lsa->lsa_flags & LINUX_SA_SIGINFO) 96 bsa->sa_flags |= SA_SIGINFO; 97 if (lsa->lsa_flags & LINUX_SA_ONSTACK) 98 bsa->sa_flags |= SA_ONSTACK; 99 if (lsa->lsa_flags & LINUX_SA_RESTART) 100 bsa->sa_flags |= SA_RESTART; 101 if (lsa->lsa_flags & LINUX_SA_ONESHOT) 102 bsa->sa_flags |= SA_RESETHAND; 103 if (lsa->lsa_flags & LINUX_SA_NOMASK) 104 bsa->sa_flags |= SA_NODEFER; 105} 106 107static void 108bsd_to_linux_sigaction(struct sigaction *bsa, linux_sigaction_t *lsa) 109{ 110 111 bsd_to_linux_sigset(&bsa->sa_mask, &lsa->lsa_mask); 112 lsa->lsa_handler = bsa->sa_handler; 113 lsa->lsa_restorer = NULL; /* unsupported */ 114 lsa->lsa_flags = 0; 115 if (bsa->sa_flags & SA_NOCLDSTOP) 116 lsa->lsa_flags |= LINUX_SA_NOCLDSTOP; 117 if (bsa->sa_flags & SA_NOCLDWAIT) 118 lsa->lsa_flags |= LINUX_SA_NOCLDWAIT; 119 if (bsa->sa_flags & SA_SIGINFO) 120 lsa->lsa_flags |= LINUX_SA_SIGINFO; 121 if (bsa->sa_flags & SA_ONSTACK) 122 lsa->lsa_flags |= LINUX_SA_ONSTACK; 123 if (bsa->sa_flags & SA_RESTART) 124 lsa->lsa_flags |= LINUX_SA_RESTART; 125 if (bsa->sa_flags & SA_RESETHAND) 126 lsa->lsa_flags |= LINUX_SA_ONESHOT; 127 if (bsa->sa_flags & SA_NODEFER) 128 lsa->lsa_flags |= LINUX_SA_NOMASK; 129} 130 131int 132linux_do_sigaction(struct proc *p, int linux_sig, linux_sigaction_t *linux_nsa, 133 linux_sigaction_t *linux_osa) 134{ 135 struct sigaction *nsa, *osa; 136 struct sigaction_args sa_args; 137 int error; 138 caddr_t sg = stackgap_init(); 139 140 if (linux_sig <= 0 || linux_sig > LINUX_NSIG) 141 return (EINVAL); 142 143 if (linux_osa != NULL) 144 osa = stackgap_alloc(&sg, sizeof(struct sigaction)); 145 else 146 osa = NULL; 147 148 if (linux_nsa != NULL) { 149 nsa = stackgap_alloc(&sg, sizeof(struct sigaction)); 150 linux_to_bsd_sigaction(linux_nsa, nsa); 151 } 152 else 153 nsa = NULL; 154 155#ifndef __alpha__ 156 if (linux_sig <= LINUX_SIGTBLSZ) 157 sa_args.sig = linux_to_bsd_signal[_SIG_IDX(linux_sig)]; 158 else 159#endif 160 sa_args.sig = linux_sig; 161 162 sa_args.act = nsa; 163 sa_args.oact = osa; 164 error = sigaction(p, &sa_args); 165 if (error) 166 return (error); 167 168 if (linux_osa != NULL) 169 bsd_to_linux_sigaction(osa, linux_osa); 170 171 return (0); 172} 173 174 175#ifndef __alpha__ 176int 177linux_signal(struct proc *p, struct linux_signal_args *args) 178{ 179 linux_sigaction_t nsa, osa; 180 int error; 181 182#ifdef DEBUG 183 printf("Linux-emul(%ld): signal(%d, %p)\n", 184 (long)p->p_pid, args->sig, (void *)args->handler); 185#endif 186 187 nsa.lsa_handler = args->handler; 188 nsa.lsa_flags = LINUX_SA_ONESHOT | LINUX_SA_NOMASK; 189 LINUX_SIGEMPTYSET(nsa.lsa_mask); 190 191 error = linux_do_sigaction(p, args->sig, &nsa, &osa); 192 p->p_retval[0] = (int)osa.lsa_handler; 193 194 return (error); 195} 196#endif /*!__alpha__*/ 197 198int 199linux_rt_sigaction(struct proc *p, struct linux_rt_sigaction_args *args) 200{ 201 linux_sigaction_t nsa, osa; 202 int error; 203 204#ifdef DEBUG 205 printf("Linux-emul(%ld): rt_sigaction(%ld, %p, %p, %ld)\n", 206 (long)p->p_pid, (long)args->sig, (void *)args->act, 207 (void *)args->oact, (long)args->sigsetsize); 208#endif 209 210 if (args->sigsetsize != sizeof(linux_sigset_t)) 211 return (EINVAL); 212 213 if (args->act != NULL) { 214 error = copyin(args->act, &nsa, sizeof(linux_sigaction_t)); 215 if (error) 216 return (error); 217 } 218 219 error = linux_do_sigaction(p, args->sig, 220 args->act ? &nsa : NULL, 221 args->oact ? &osa : NULL); 222 223 if (args->oact != NULL && !error) { 224 error = copyout(&osa, args->oact, sizeof(linux_sigaction_t)); 225 } 226 227 return (error); 228} 229 230static int 231linux_do_sigprocmask(struct proc *p, int how, linux_sigset_t *new, 232 linux_sigset_t *old) 233{
|
234 int error, s;
| 234 int error;
|
235 sigset_t mask; 236 237 error = 0; 238 p->p_retval[0] = 0; 239
| 235 sigset_t mask; 236 237 error = 0; 238 p->p_retval[0] = 0; 239
|
| 240 PROC_LOCK(p);
|
240 if (old != NULL) 241 bsd_to_linux_sigset(&p->p_sigmask, old); 242 243 if (new != NULL) { 244 linux_to_bsd_sigset(new, &mask); 245
| 241 if (old != NULL) 242 bsd_to_linux_sigset(&p->p_sigmask, old); 243 244 if (new != NULL) { 245 linux_to_bsd_sigset(new, &mask); 246
|
246 s = splhigh(); 247
| |
248 switch (how) { 249 case LINUX_SIG_BLOCK: 250 SIGSETOR(p->p_sigmask, mask); 251 SIG_CANTMASK(p->p_sigmask); 252 break; 253 case LINUX_SIG_UNBLOCK: 254 SIGSETNAND(p->p_sigmask, mask); 255 break; 256 case LINUX_SIG_SETMASK: 257 p->p_sigmask = mask; 258 SIG_CANTMASK(p->p_sigmask); 259 break; 260 default: 261 error = EINVAL; 262 break; 263 }
| 247 switch (how) { 248 case LINUX_SIG_BLOCK: 249 SIGSETOR(p->p_sigmask, mask); 250 SIG_CANTMASK(p->p_sigmask); 251 break; 252 case LINUX_SIG_UNBLOCK: 253 SIGSETNAND(p->p_sigmask, mask); 254 break; 255 case LINUX_SIG_SETMASK: 256 p->p_sigmask = mask; 257 SIG_CANTMASK(p->p_sigmask); 258 break; 259 default: 260 error = EINVAL; 261 break; 262 }
|
264 265 splx(s);
| |
266 }
| 263 }
|
| 264 PROC_UNLOCK(p);
|
267 268 return (error); 269} 270 271#ifndef __alpha__ 272int 273linux_sigprocmask(struct proc *p, struct linux_sigprocmask_args *args) 274{ 275 linux_osigset_t mask; 276 linux_sigset_t set, oset; 277 int error; 278 279#ifdef DEBUG 280 printf("Linux-emul(%d): sigprocmask(%d, *, *)\n", p->p_pid, args->how); 281#endif 282 283 if (args->mask != NULL) { 284 error = copyin(args->mask, &mask, sizeof(linux_osigset_t)); 285 if (error) 286 return (error); 287 LINUX_SIGEMPTYSET(set); 288 set.__bits[0] = mask; 289 } 290 291 error = linux_do_sigprocmask(p, args->how, 292 args->mask ? &set : NULL, 293 args->omask ? &oset : NULL); 294 295 if (args->omask != NULL && !error) { 296 mask = oset.__bits[0]; 297 error = copyout(&mask, args->omask, sizeof(linux_osigset_t)); 298 } 299 300 return (error); 301} 302#endif /*!__alpha__*/ 303 304int 305linux_rt_sigprocmask(struct proc *p, struct linux_rt_sigprocmask_args *args) 306{ 307 linux_sigset_t set, oset; 308 int error; 309 310#ifdef DEBUG 311 printf("Linux-emul(%ld): rt_sigprocmask(%d, %p, %p, %ld)\n", 312 (long)p->p_pid, args->how, (void *)args->mask, 313 (void *)args->omask, (long)args->sigsetsize); 314#endif 315 316 if (args->sigsetsize != sizeof(linux_sigset_t)) 317 return EINVAL; 318 319 if (args->mask != NULL) { 320 error = copyin(args->mask, &set, sizeof(linux_sigset_t)); 321 if (error) 322 return (error); 323 } 324 325 error = linux_do_sigprocmask(p, args->how, 326 args->mask ? &set : NULL, 327 args->omask ? &oset : NULL); 328 329 if (args->omask != NULL && !error) { 330 error = copyout(&oset, args->omask, sizeof(linux_sigset_t)); 331 } 332 333 return (error); 334} 335 336#ifndef __alpha__ 337int 338linux_siggetmask(struct proc *p, struct linux_siggetmask_args *args) 339{ 340 linux_sigset_t mask; 341 342#ifdef DEBUG 343 printf("Linux-emul(%d): siggetmask()\n", p->p_pid); 344#endif 345
| 265 266 return (error); 267} 268 269#ifndef __alpha__ 270int 271linux_sigprocmask(struct proc *p, struct linux_sigprocmask_args *args) 272{ 273 linux_osigset_t mask; 274 linux_sigset_t set, oset; 275 int error; 276 277#ifdef DEBUG 278 printf("Linux-emul(%d): sigprocmask(%d, *, *)\n", p->p_pid, args->how); 279#endif 280 281 if (args->mask != NULL) { 282 error = copyin(args->mask, &mask, sizeof(linux_osigset_t)); 283 if (error) 284 return (error); 285 LINUX_SIGEMPTYSET(set); 286 set.__bits[0] = mask; 287 } 288 289 error = linux_do_sigprocmask(p, args->how, 290 args->mask ? &set : NULL, 291 args->omask ? &oset : NULL); 292 293 if (args->omask != NULL && !error) { 294 mask = oset.__bits[0]; 295 error = copyout(&mask, args->omask, sizeof(linux_osigset_t)); 296 } 297 298 return (error); 299} 300#endif /*!__alpha__*/ 301 302int 303linux_rt_sigprocmask(struct proc *p, struct linux_rt_sigprocmask_args *args) 304{ 305 linux_sigset_t set, oset; 306 int error; 307 308#ifdef DEBUG 309 printf("Linux-emul(%ld): rt_sigprocmask(%d, %p, %p, %ld)\n", 310 (long)p->p_pid, args->how, (void *)args->mask, 311 (void *)args->omask, (long)args->sigsetsize); 312#endif 313 314 if (args->sigsetsize != sizeof(linux_sigset_t)) 315 return EINVAL; 316 317 if (args->mask != NULL) { 318 error = copyin(args->mask, &set, sizeof(linux_sigset_t)); 319 if (error) 320 return (error); 321 } 322 323 error = linux_do_sigprocmask(p, args->how, 324 args->mask ? &set : NULL, 325 args->omask ? &oset : NULL); 326 327 if (args->omask != NULL && !error) { 328 error = copyout(&oset, args->omask, sizeof(linux_sigset_t)); 329 } 330 331 return (error); 332} 333 334#ifndef __alpha__ 335int 336linux_siggetmask(struct proc *p, struct linux_siggetmask_args *args) 337{ 338 linux_sigset_t mask; 339 340#ifdef DEBUG 341 printf("Linux-emul(%d): siggetmask()\n", p->p_pid); 342#endif 343
|
| 344 PROC_LOCK(p);
|
346 bsd_to_linux_sigset(&p->p_sigmask, &mask);
| 345 bsd_to_linux_sigset(&p->p_sigmask, &mask);
|
| 346 PROC_UNLOCK(p);
|
347 p->p_retval[0] = mask.__bits[0]; 348 return (0); 349} 350 351int 352linux_sigsetmask(struct proc *p, struct linux_sigsetmask_args *args) 353{ 354 linux_sigset_t lset; 355 sigset_t bset;
| 347 p->p_retval[0] = mask.__bits[0]; 348 return (0); 349} 350 351int 352linux_sigsetmask(struct proc *p, struct linux_sigsetmask_args *args) 353{ 354 linux_sigset_t lset; 355 sigset_t bset;
|
356 int s;
| |
357 358#ifdef DEBUG 359 printf("Linux-emul(%ld): sigsetmask(%08lx)\n", 360 (long)p->p_pid, (unsigned long)args->mask); 361#endif 362
| 356 357#ifdef DEBUG 358 printf("Linux-emul(%ld): sigsetmask(%08lx)\n", 359 (long)p->p_pid, (unsigned long)args->mask); 360#endif 361
|
| 362 PROC_LOCK(p);
|
363 bsd_to_linux_sigset(&p->p_sigmask, &lset); 364 p->p_retval[0] = lset.__bits[0]; 365 LINUX_SIGEMPTYSET(lset); 366 lset.__bits[0] = args->mask; 367 linux_to_bsd_sigset(&lset, &bset);
| 363 bsd_to_linux_sigset(&p->p_sigmask, &lset); 364 p->p_retval[0] = lset.__bits[0]; 365 LINUX_SIGEMPTYSET(lset); 366 lset.__bits[0] = args->mask; 367 linux_to_bsd_sigset(&lset, &bset);
|
368 s = splhigh();
| |
369 p->p_sigmask = bset; 370 SIG_CANTMASK(p->p_sigmask);
| 368 p->p_sigmask = bset; 369 SIG_CANTMASK(p->p_sigmask);
|
371 splx(s);
| 370 PROC_UNLOCK(p);
|
372 return (0); 373} 374 375int 376linux_sigpending(struct proc *p, struct linux_sigpending_args *args) 377{ 378 sigset_t bset; 379 linux_sigset_t lset; 380 linux_osigset_t mask; 381 382#ifdef DEBUG 383 printf("Linux-emul(%d): sigpending(*)\n", p->p_pid); 384#endif 385
| 371 return (0); 372} 373 374int 375linux_sigpending(struct proc *p, struct linux_sigpending_args *args) 376{ 377 sigset_t bset; 378 linux_sigset_t lset; 379 linux_osigset_t mask; 380 381#ifdef DEBUG 382 printf("Linux-emul(%d): sigpending(*)\n", p->p_pid); 383#endif 384
|
| 385 PROC_LOCK(p);
|
386 bset = p->p_siglist; 387 SIGSETAND(bset, p->p_sigmask); 388 bsd_to_linux_sigset(&bset, &lset);
| 386 bset = p->p_siglist; 387 SIGSETAND(bset, p->p_sigmask); 388 bsd_to_linux_sigset(&bset, &lset);
|
| 389 PROC_UNLOCK(p);
|
389 mask = lset.__bits[0]; 390 return (copyout(&mask, args->mask, sizeof(mask))); 391} 392#endif /*!__alpha__*/ 393 394int 395linux_kill(struct proc *p, struct linux_kill_args *args) 396{ 397 struct kill_args /* { 398 int pid; 399 int signum; 400 } */ tmp; 401 402#ifdef DEBUG 403 printf("Linux-emul(%d): kill(%d, %d)\n", 404 p->p_pid, args->pid, args->signum); 405#endif 406 407 /* 408 * Allow signal 0 as a means to check for privileges 409 */ 410 if (args->signum < 0 || args->signum > LINUX_NSIG) 411 return EINVAL; 412 413#ifndef __alpha__ 414 if (args->signum > 0 && args->signum <= LINUX_SIGTBLSZ) 415 tmp.signum = linux_to_bsd_signal[_SIG_IDX(args->signum)]; 416 else 417#endif 418 tmp.signum = args->signum; 419 420 tmp.pid = args->pid; 421 return (kill(p, &tmp)); 422}
| 390 mask = lset.__bits[0]; 391 return (copyout(&mask, args->mask, sizeof(mask))); 392} 393#endif /*!__alpha__*/ 394 395int 396linux_kill(struct proc *p, struct linux_kill_args *args) 397{ 398 struct kill_args /* { 399 int pid; 400 int signum; 401 } */ tmp; 402 403#ifdef DEBUG 404 printf("Linux-emul(%d): kill(%d, %d)\n", 405 p->p_pid, args->pid, args->signum); 406#endif 407 408 /* 409 * Allow signal 0 as a means to check for privileges 410 */ 411 if (args->signum < 0 || args->signum > LINUX_NSIG) 412 return EINVAL; 413 414#ifndef __alpha__ 415 if (args->signum > 0 && args->signum <= LINUX_SIGTBLSZ) 416 tmp.signum = linux_to_bsd_signal[_SIG_IDX(args->signum)]; 417 else 418#endif 419 tmp.signum = args->signum; 420 421 tmp.pid = args->pid; 422 return (kill(p, &tmp)); 423}
|