Annotation of src/sys/compat/linux32/common/linux32_signal.c, Revision 1.13.12.1
1.13.12.1! yamt 1: /* $NetBSD: linux32_signal.c,v 1.13 2009/06/08 13:34:23 njoly Exp $ */
1.1 manu 2:
3: /*-
4: * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
5: *
6: * Redistribution and use in source and binary forms, with or without
7: * modification, are permitted provided that the following conditions
8: * are met:
9: * 1. Redistributions of source code must retain the above copyright
10: * notice, this list of conditions and the following disclaimer.
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. All advertising materials mentioning features or use of this software
15: * must display the following acknowledgement:
16: * This product includes software developed by Emmanuel Dreyfus
17: * 4. The name of the author may not be used to endorse or promote
18: * products derived from this software without specific prior written
19: * permission.
20: *
21: * THIS SOFTWARE IS PROVIDED BY THE THE AUTHOR AND CONTRIBUTORS ``AS IS''
22: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23: * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
25: * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31: * POSSIBILITY OF SUCH DAMAGE.
32: */
1.6 lukem 33:
34: #include <sys/cdefs.h>
1.13.12.1! yamt 35: __KERNEL_RCSID(0, "$NetBSD: linux32_signal.c,v 1.13 2009/06/08 13:34:23 njoly Exp $");
1.6 lukem 36:
1.1 manu 37: #include <sys/param.h>
38: #include <sys/ucred.h>
39: #include <sys/signalvar.h>
40: #include <sys/lwp.h>
41: #include <sys/time.h>
1.2 ad 42: #include <sys/proc.h>
1.13.12.1! yamt 43: #include <sys/wait.h>
1.1 manu 44:
45: #include <compat/netbsd32/netbsd32.h>
46:
1.13.12.1! yamt 47: #include <compat/linux/common/linux_signal.h>
1.1 manu 48: #include <compat/linux32/common/linux32_types.h>
49: #include <compat/linux32/common/linux32_signal.h>
1.13.12.1! yamt 50: #include <compat/linux32/common/linux32_siginfo.h>
1.1 manu 51: #include <compat/linux32/linux32_syscallargs.h>
1.13.12.1! yamt 52: #include <compat/linux32/common/linux32_errno.h>
! 53: #include <compat/linux32/common/linux32_sched.h>
1.1 manu 54:
55: #define linux32_sigemptyset(s) memset((s), 0, sizeof(*(s)))
56: #define linux32_sigismember(s, n) ((s)->sig[((n) - 1) / LINUX32__NSIG_BPW] \
57: & (1 << ((n) - 1) % LINUX32__NSIG_BPW))
58: #define linux32_sigaddset(s, n) ((s)->sig[((n) - 1) / LINUX32__NSIG_BPW] \
59: |= (1 << ((n) - 1) % LINUX32__NSIG_BPW))
60:
61: extern const int native_to_linux32_signo[];
62: extern const int linux32_to_native_signo[];
63:
1.10 christos 64: #ifdef DEBUG_LINUX
65: #define DPRINTF(a) uprintf a
66: #else
67: #define DPRINTF(a)
68: #endif
69:
1.1 manu 70: void
1.5 dsl 71: linux32_to_native_sigset(sigset_t *bss, const linux32_sigset_t *lss)
1.1 manu 72: {
73: int i, newsig;
74:
75: sigemptyset(bss);
76: for (i = 1; i < LINUX32__NSIG; i++) {
77: if (linux32_sigismember(lss, i)) {
78: newsig = linux32_to_native_signo[i];
79: if (newsig)
80: sigaddset(bss, newsig);
81: }
82: }
83: }
84:
85: void
1.5 dsl 86: native_to_linux32_sigset(linux32_sigset_t *lss, const sigset_t *bss)
1.1 manu 87: {
88: int i, newsig;
89:
90: linux32_sigemptyset(lss);
91: for (i = 1; i < NSIG; i++) {
92: if (sigismember(bss, i)) {
93: newsig = native_to_linux32_signo[i];
94: if (newsig)
95: linux32_sigaddset(lss, newsig);
96: }
97: }
98: }
99:
1.13.12.1! yamt 100: void
! 101: native_to_linux32_siginfo(linux32_siginfo_t *lsi, const struct _ksiginfo *ksi)
! 102: {
! 103: memset(lsi, 0, sizeof(*lsi));
! 104:
! 105: lsi->lsi_signo = native_to_linux32_signo[ksi->_signo];
! 106: lsi->lsi_errno = native_to_linux32_errno[ksi->_errno];
! 107: lsi->lsi_code = native_to_linux32_si_code(ksi->_code);
! 108:
! 109: switch (ksi->_code) {
! 110: case SI_NOINFO:
! 111: break;
! 112:
! 113: case SI_USER:
! 114: lsi->lsi_pid = ksi->_reason._rt._pid;
! 115: lsi->lsi_uid = ksi->_reason._rt._uid;
! 116: if (lsi->lsi_signo == LINUX_SIGALRM ||
! 117: lsi->lsi_signo >= LINUX_SIGRTMIN)
! 118: NETBSD32PTR32(lsi->lsi_value.sival_ptr,
! 119: ksi->_reason._rt._value.sival_ptr);
! 120: break;
! 121:
! 122: case SI_TIMER:
! 123: case SI_QUEUE:
! 124: lsi->lsi_uid = ksi->_reason._rt._uid;
! 125: lsi->lsi_uid = ksi->_reason._rt._uid;
! 126: NETBSD32PTR32(lsi->lsi_value.sival_ptr,
! 127: ksi->_reason._rt._value.sival_ptr);
! 128: break;
! 129:
! 130: case SI_ASYNCIO:
! 131: case SI_MESGQ:
! 132: NETBSD32PTR32(lsi->lsi_value.sival_ptr,
! 133: ksi->_reason._rt._value.sival_ptr);
! 134: break;
! 135:
! 136: default:
! 137: switch (ksi->_signo) {
! 138: case SIGCHLD:
! 139: lsi->lsi_uid = ksi->_reason._child._uid;
! 140: lsi->lsi_pid = ksi->_reason._child._pid;
! 141: lsi->lsi_status = native_to_linux32_si_status(
! 142: ksi->_code, ksi->_reason._child._status);
! 143: lsi->lsi_utime = ksi->_reason._child._utime;
! 144: lsi->lsi_stime = ksi->_reason._child._stime;
! 145: break;
! 146:
! 147: case SIGILL:
! 148: case SIGFPE:
! 149: case SIGSEGV:
! 150: case SIGBUS:
! 151: case SIGTRAP:
! 152: NETBSD32PTR32(lsi->lsi_addr, ksi->_reason._fault._addr);
! 153: break;
! 154:
! 155: case SIGIO:
! 156: lsi->lsi_fd = ksi->_reason._poll._fd;
! 157: lsi->lsi_band = ksi->_reason._poll._band;
! 158: break;
! 159: default:
! 160: break;
! 161: }
! 162: }
! 163: }
! 164:
1.1 manu 165: unsigned int
1.5 dsl 166: native_to_linux32_sigflags(const int bsf)
1.1 manu 167: {
168: unsigned int lsf = 0;
169: if ((bsf & SA_NOCLDSTOP) != 0)
170: lsf |= LINUX32_SA_NOCLDSTOP;
171: if ((bsf & SA_NOCLDWAIT) != 0)
172: lsf |= LINUX32_SA_NOCLDWAIT;
173: if ((bsf & SA_ONSTACK) != 0)
174: lsf |= LINUX32_SA_ONSTACK;
175: if ((bsf & SA_RESTART) != 0)
176: lsf |= LINUX32_SA_RESTART;
177: if ((bsf & SA_NODEFER) != 0)
178: lsf |= LINUX32_SA_NOMASK;
179: if ((bsf & SA_RESETHAND) != 0)
180: lsf |= LINUX32_SA_ONESHOT;
181: if ((bsf & SA_SIGINFO) != 0)
182: lsf |= LINUX32_SA_SIGINFO;
183: return lsf;
184: }
185:
186: int
1.5 dsl 187: linux32_to_native_sigflags(const unsigned long lsf)
1.1 manu 188: {
189: int bsf = 0;
190: if ((lsf & LINUX32_SA_NOCLDSTOP) != 0)
191: bsf |= SA_NOCLDSTOP;
192: if ((lsf & LINUX32_SA_NOCLDWAIT) != 0)
193: bsf |= SA_NOCLDWAIT;
194: if ((lsf & LINUX32_SA_ONSTACK) != 0)
195: bsf |= SA_ONSTACK;
196: if ((lsf & LINUX32_SA_RESTART) != 0)
197: bsf |= SA_RESTART;
198: if ((lsf & LINUX32_SA_ONESHOT) != 0)
199: bsf |= SA_RESETHAND;
200: if ((lsf & LINUX32_SA_NOMASK) != 0)
201: bsf |= SA_NODEFER;
202: if ((lsf & LINUX32_SA_SIGINFO) != 0)
203: bsf |= SA_SIGINFO;
204: if ((lsf & ~LINUX32_SA_ALLBITS) != 0) {
205: #ifdef DEBUG_LINUX
206: printf("linux32_old_to_native_sigflags: "
207: "%lx extra bits ignored\n", lsf);
208: #endif
209: }
210: return bsf;
211: }
212:
213: void
1.5 dsl 214: linux32_to_native_sigaction(struct sigaction *bsa, const struct linux32_sigaction *lsa)
1.1 manu 215: {
216: bsa->sa_handler = NETBSD32PTR64(lsa->linux_sa_handler);
217: linux32_to_native_sigset(&bsa->sa_mask, &lsa->linux_sa_mask);
218: bsa->sa_flags = linux32_to_native_sigflags(lsa->linux_sa_flags);
219: }
220:
221: void
1.5 dsl 222: native_to_linux32_sigaction(struct linux32_sigaction *lsa, const struct sigaction *bsa)
1.1 manu 223: {
1.3 dsl 224: NETBSD32PTR32(lsa->linux_sa_handler, bsa->sa_handler);
1.1 manu 225: native_to_linux32_sigset(&lsa->linux_sa_mask, &bsa->sa_mask);
226: lsa->linux_sa_flags = native_to_linux32_sigflags(bsa->sa_flags);
1.3 dsl 227: NETBSD32PTR32(lsa->linux_sa_restorer, NULL);
1.1 manu 228: }
229:
230: void
1.5 dsl 231: native_to_linux32_sigaltstack(struct linux32_sigaltstack *lss, const struct sigaltstack *bss)
1.1 manu 232: {
1.3 dsl 233: NETBSD32PTR32(lss->ss_sp, bss->ss_sp);
1.1 manu 234: lss->ss_size = bss->ss_size;
235: if (bss->ss_flags & SS_ONSTACK)
236: lss->ss_flags = LINUX32_SS_ONSTACK;
237: else if (bss->ss_flags & SS_DISABLE)
238: lss->ss_flags = LINUX32_SS_DISABLE;
239: else
240: lss->ss_flags = 0;
241: }
242:
243:
244: void
1.5 dsl 245: native_to_linux32_old_sigset(linux32_old_sigset_t *lss, const sigset_t *bss)
1.1 manu 246: {
247: linux32_sigset_t lsnew;
248:
249: native_to_linux32_sigset(&lsnew, bss);
250:
251: /* convert new sigset to old sigset */
252: *lss = lsnew.sig[0];
253: }
254:
255: void
1.5 dsl 256: linux32_old_to_native_sigset(sigset_t *bss, const linux32_old_sigset_t *lss)
1.1 manu 257: {
258: linux32_sigset_t ls;
259:
1.11 cegger 260: memset(&ls, 0, sizeof(ls));
1.1 manu 261: ls.sig[0] = *lss;
262:
263: linux32_to_native_sigset(bss, &ls);
264: }
265:
266: int
1.7 dsl 267: linux32_sys_rt_sigaction(struct lwp *l, const struct linux32_sys_rt_sigaction_args *uap, register_t *retval)
1.1 manu 268: {
1.7 dsl 269: /* {
1.1 manu 270: syscallarg(int) signum;
271: syscallarg(const linux32_sigactionp_t) nsa;
272: syscallarg(linux32_sigactionp_t) osa;
273: syscallarg(netbsd32_size_t) sigsetsize;
1.7 dsl 274: } */
1.1 manu 275: struct linux32_sigaction nls32;
276: struct linux32_sigaction ols32;
277: struct sigaction ns;
278: struct sigaction os;
279: int error;
280: int sig;
281: int vers = 0;
282: void *tramp = NULL;
283:
1.10 christos 284: if (SCARG(uap, sigsetsize) != sizeof(linux32_sigset_t)) {
285: DPRINTF(("rt_sigaction: Inconsistent sigsetsize %u %zu\n",
286: SCARG(uap, sigsetsize), sizeof(linux32_sigset_t)));
1.1 manu 287: return EINVAL;
1.10 christos 288: }
1.1 manu 289:
1.4 dsl 290: if (SCARG_P32(uap, nsa) != NULL) {
291: if ((error = copyin(SCARG_P32(uap, nsa),
1.10 christos 292: &nls32, sizeof(nls32))) != 0) {
293: DPRINTF(("rt_sigaction: Copyin %d\n", error));
1.1 manu 294: return error;
1.10 christos 295: }
1.1 manu 296: linux32_to_native_sigaction(&ns, &nls32);
297: }
298:
299: sig = SCARG(uap, signum);
1.10 christos 300: if (sig < 0 || sig >= LINUX32__NSIG) {
301: DPRINTF(("rt_sigaction: Bad signal number %d %d\n",
302: sig, LINUX32__NSIG));
1.1 manu 303: return EINVAL;
1.10 christos 304: }
1.1 manu 305: if (sig > 0 && !linux32_to_native_signo[sig]) {
306: /* unknown signal... */
307: os.sa_handler = SIG_IGN;
308: sigemptyset(&os.sa_mask);
309: os.sa_flags = 0;
310: } else {
1.2 ad 311: if ((error = sigaction1(l,
1.1 manu 312: linux32_to_native_signo[sig],
1.4 dsl 313: SCARG_P32(uap, nsa) ? &ns : NULL,
314: SCARG_P32(uap, osa) ? &os : NULL,
1.10 christos 315: tramp, vers)) != 0) {
316: DPRINTF(("rt_sigaction: sigaction %d\n", error));
1.1 manu 317: return error;
1.10 christos 318: }
1.1 manu 319: }
320:
1.4 dsl 321: if (SCARG_P32(uap, osa) != NULL) {
1.1 manu 322: native_to_linux32_sigaction(&ols32, &os);
323:
1.4 dsl 324: if ((error = copyout(&ols32, SCARG_P32(uap, osa),
1.10 christos 325: sizeof(ols32))) != 0) {
326: DPRINTF(("rt_sigaction: Copyout %d\n", error));
1.1 manu 327: return error;
1.10 christos 328: }
1.1 manu 329: }
330:
331: return 0;
332: }
333:
334: int
1.7 dsl 335: linux32_sys_rt_sigprocmask(struct lwp *l, const struct linux32_sys_rt_sigprocmask_args *uap, register_t *retval)
1.1 manu 336: {
1.7 dsl 337: /* {
1.1 manu 338: syscallarg(int) how;
339: syscallarg(const linux32_sigsetp_t) set;
340: syscallarg(linux32_sigsetp_t) oset;
341: syscallarg(netbsd32_size_t) sigsetsize;
1.7 dsl 342: } */
1.1 manu 343: struct proc *p = l->l_proc;
344: linux32_sigset_t nls32, ols32;
345: sigset_t ns, os;
346: int error;
347: int how;
348:
349: if (SCARG(uap, sigsetsize) != sizeof(linux32_sigset_t))
350: return EINVAL;
351:
352: switch (SCARG(uap, how)) {
353: case LINUX32_SIG_BLOCK:
354: how = SIG_BLOCK;
355: break;
356: case LINUX32_SIG_UNBLOCK:
357: how = SIG_UNBLOCK;
358: break;
359: case LINUX32_SIG_SETMASK:
360: how = SIG_SETMASK;
361: break;
362: default:
363: return EINVAL;
364: break;
365: }
366:
1.4 dsl 367: if (SCARG_P32(uap, set) != NULL) {
368: if ((error = copyin(SCARG_P32(uap, set),
1.1 manu 369: &nls32, sizeof(nls32))) != 0)
370: return error;
371: linux32_to_native_sigset(&ns, &nls32);
372: }
373:
1.8 ad 374: mutex_enter(p->p_lock);
1.2 ad 375: error = sigprocmask1(l, how,
1.4 dsl 376: SCARG_P32(uap, set) ? &ns : NULL,
377: SCARG_P32(uap, oset) ? &os : NULL);
1.8 ad 378: mutex_exit(p->p_lock);
1.2 ad 379:
380: if (error != 0)
1.1 manu 381: return error;
382:
1.4 dsl 383: if (SCARG_P32(uap, oset) != NULL) {
1.1 manu 384: native_to_linux32_sigset(&ols32, &os);
385: if ((error = copyout(&ols32,
1.4 dsl 386: SCARG_P32(uap, oset), sizeof(ols32))) != 0)
1.1 manu 387: return error;
388: }
389:
390: return 0;
391: }
392:
393: int
1.7 dsl 394: linux32_sys_kill(struct lwp *l, const struct linux32_sys_kill_args *uap, register_t *retval)
395: {
396: /* {
1.1 manu 397: syscallarg(int) pid;
398: syscallarg(int) signum;
1.7 dsl 399: } */
1.1 manu 400:
401: struct sys_kill_args ka;
402: int sig;
403:
404: SCARG(&ka, pid) = SCARG(uap, pid);
405: sig = SCARG(uap, signum);
406: if (sig < 0 || sig >= LINUX32__NSIG)
407: return (EINVAL);
408: SCARG(&ka, signum) = linux32_to_native_signo[sig];
409: return sys_kill(l, &ka, retval);
410: }
411:
412: int
1.7 dsl 413: linux32_sys_rt_sigsuspend(struct lwp *l, const struct linux32_sys_rt_sigsuspend_args *uap, register_t *retval)
414: {
415: /* {
1.1 manu 416: syscallarg(linux32_sigsetp_t) unewset;
417: syscallarg(netbsd32_size_t) sigsetsize;
1.7 dsl 418: } */
1.1 manu 419: linux32_sigset_t lss;
420: sigset_t bss;
421: int error;
422:
423: if (SCARG(uap, sigsetsize) != sizeof(linux32_sigset_t))
424: return EINVAL;
425:
1.4 dsl 426: if ((error = copyin(SCARG_P32(uap, unewset),
1.1 manu 427: &lss, sizeof(linux32_sigset_t))) != 0)
428: return error;
429:
430: linux32_to_native_sigset(&bss, &lss);
431:
1.2 ad 432: return sigsuspend1(l, &bss);
1.1 manu 433: }
434:
1.13.12.1! yamt 435: static int
! 436: fetchss(const void *u, void *s, size_t len)
! 437: {
! 438: int error;
! 439: linux32_sigset_t lss;
! 440:
! 441: if ((error = copyin(u, &lss, sizeof(lss))) != 0)
! 442: return error;
! 443:
! 444: linux32_to_native_sigset(s, &lss);
! 445: return 0;
! 446: }
! 447:
! 448: static int
! 449: fetchts(const void *u, void *s, size_t len)
! 450: {
! 451: int error;
! 452: struct linux32_timespec lts;
! 453:
! 454: if ((error = copyin(u, <s, sizeof(lts))) != 0)
! 455: return error;
! 456:
! 457: linux32_to_native_timespec(s, <s);
! 458: return 0;
! 459: }
! 460:
! 461: static int
! 462: fakestorets(const void *u, void *s, size_t len)
! 463: {
! 464: /* Do nothing, sigtimedwait does not alter timeout like ours */
! 465: return 0;
! 466: }
! 467:
! 468: static int
! 469: storeinfo(const void *s, void *u, size_t len)
! 470: {
! 471: linux32_siginfo_t lsi;
! 472:
! 473:
! 474: native_to_linux32_siginfo(&lsi, &((const siginfo_t *)s)->_info);
! 475: return copyout(&lsi, u, sizeof(lsi));
! 476: }
! 477:
! 478: int
! 479: linux32_sys_rt_sigtimedwait(struct lwp *l,
! 480: const struct linux32_sys_rt_sigtimedwait_args *uap, register_t *retval)
! 481: {
! 482: /* {
! 483: syscallarg(const linux32_sigset_t *) set;
! 484: syscallarg(linux32_siginfo_t *) info);
! 485: syscallarg(const struct linux32_timespec *) timeout;
! 486: } */
! 487:
! 488: return sigtimedwait1(l, (const struct sys_____sigtimedwait50_args *)uap,
! 489: retval, fetchss, storeinfo, fetchts, fakestorets);
! 490: }
! 491:
1.1 manu 492: int
1.7 dsl 493: linux32_sys_signal(struct lwp *l, const struct linux32_sys_signal_args *uap, register_t *retval)
1.1 manu 494: {
1.7 dsl 495: /* {
1.1 manu 496: syscallarg(int) signum;
497: syscallarg(linux32_handler_t) handler;
1.7 dsl 498: } */
1.1 manu 499: struct sigaction nbsa, obsa;
500: int error, sig;
501:
502: *retval = -1;
503:
504: sig = SCARG(uap, signum);
505: if (sig < 0 || sig >= LINUX32__NSIG)
506: return EINVAL;
507:
1.4 dsl 508: nbsa.sa_handler = SCARG_P32(uap, handler);
1.1 manu 509: sigemptyset(&nbsa.sa_mask);
510: nbsa.sa_flags = SA_RESETHAND | SA_NODEFER;
511:
1.2 ad 512: if ((error = sigaction1(l, linux32_to_native_signo[sig],
1.1 manu 513: &nbsa, &obsa, NULL, 0)) != 0)
514: return error;
515:
516: *retval = (int)(long)obsa.sa_handler;
517: return 0;
518: }
1.9 njoly 519:
520: int
521: linux32_sys_rt_sigpending(struct lwp *l, const struct linux32_sys_rt_sigpending_args *uap, register_t *retval)
522: {
523: /* {
524: syscallarg(linux32_sigsetp_t) set;
525: syscallarg(netbsd32_size_t) sigsetsize;
526: } */
527: sigset_t bss;
528: linux32_sigset_t lss;
529:
530: if (SCARG(uap, sigsetsize) != sizeof(linux32_sigset_t))
531: return EINVAL;
532:
533: sigpending1(l, &bss);
534: native_to_linux32_sigset(&lss, &bss);
535: return copyout(&lss, SCARG_P32(uap, set), sizeof(lss));
536: }
1.12 njoly 537:
538: int
539: linux32_sys_siggetmask(struct lwp *l, const void *v, register_t *retval)
540: {
541: struct proc *p = l->l_proc;
542: sigset_t bss;
543: linux32_old_sigset_t lss;
544: int error;
545:
546: mutex_enter(p->p_lock);
547: error = sigprocmask1(l, SIG_SETMASK, 0, &bss);
548: mutex_exit(p->p_lock);
549: if (error)
550: return error;
551: native_to_linux32_old_sigset(&lss, &bss);
552: *retval = lss;
553: return 0;
554: }
555:
556: int
557: linux32_sys_sigsetmask(struct lwp *l, const struct linux32_sys_sigsetmask_args *uap, register_t *retval)
558: {
559: /* {
560: syscallarg(linux32_old_sigset_t) mask;
561: } */
562: sigset_t nbss, obss;
563: linux32_old_sigset_t nlss, olss;
564: struct proc *p = l->l_proc;
565: int error;
566:
567: nlss = SCARG(uap, mask);
568: linux32_old_to_native_sigset(&nbss, &nlss);
569: mutex_enter(p->p_lock);
570: error = sigprocmask1(l, SIG_SETMASK, &nbss, &obss);
571: mutex_exit(p->p_lock);
572: if (error)
573: return error;
574: native_to_linux32_old_sigset(&olss, &obss);
575: *retval = olss;
576: return 0;
577: }
1.13 njoly 578:
579: int
580: linux32_sys_rt_queueinfo(struct lwp *l, const struct linux32_sys_rt_queueinfo_args *uap, register_t *retval)
581: {
582: /*
583: syscallarg(int) pid;
584: syscallarg(int) sig;
585: syscallarg(linux32_siginfop_t) uinfo;
586: */
587: int error;
588: linux32_siginfo_t info;
589:
590: error = copyin(SCARG_P32(uap, uinfo), &info, sizeof(info));
591: if (error)
592: return error;
593: if (info.lsi_code >= 0)
594: return EPERM;
595:
596: /* XXX To really implement this we need to */
597: /* XXX keep a list of queued signals somewhere. */
598: return linux32_sys_kill(l, (const void *)uap, retval);
599: }
1.13.12.1! yamt 600:
! 601: int
! 602: native_to_linux32_si_code(int code)
! 603: {
! 604: int si_codes[] = {
! 605: LINUX32_SI_USER, LINUX32_SI_QUEUE, LINUX32_SI_TIMER,
! 606: LINUX32_SI_ASYNCIO, LINUX32_SI_MESGQ, LINUX32_SI_TKILL /* SI_LWP */
! 607: };
! 608:
! 609: if (code <= 0 && -code < __arraycount(si_codes))
! 610: return si_codes[-code];
! 611:
! 612: return code;
! 613: }
! 614:
! 615: int
! 616: native_to_linux32_si_status(int code, int status)
! 617: {
! 618: int sts;
! 619:
! 620: switch (code) {
! 621: case CLD_CONTINUED:
! 622: sts = LINUX_SIGCONT;
! 623: break;
! 624: case CLD_EXITED:
! 625: sts = WEXITSTATUS(status);
! 626: break;
! 627: case CLD_STOPPED:
! 628: case CLD_TRAPPED:
! 629: case CLD_DUMPED:
! 630: case CLD_KILLED:
! 631: default:
! 632: sts = native_to_linux32_signo[WTERMSIG(status)];
! 633: break;
! 634: }
! 635:
! 636: return sts;
! 637: }
CVSweb <webmaster@jp.NetBSD.org>