Deleted Added
full compact
linux_machdep.c (78962) linux_machdep.c (83221)
1/*-
2 * Copyright (c) 2000 Marcel Moolenaar
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) 2000 Marcel Moolenaar
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/i386/linux/linux_machdep.c 78962 2001-06-29 11:10:41Z jhb $
28 * $FreeBSD: head/sys/i386/linux/linux_machdep.c 83221 2001-09-08 19:07:04Z marcel $
29 */
30
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/mman.h>
34#include <sys/mutex.h>
35#include <sys/proc.h>
36#include <sys/resource.h>

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

49#include <vm/vm_map.h>
50
51#include <i386/linux/linux.h>
52#include <i386/linux/linux_proto.h>
53#include <compat/linux/linux_ipc.h>
54#include <compat/linux/linux_signal.h>
55#include <compat/linux/linux_util.h>
56
29 */
30
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/mman.h>
34#include <sys/mutex.h>
35#include <sys/proc.h>
36#include <sys/resource.h>

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

49#include <vm/vm_map.h>
50
51#include <i386/linux/linux.h>
52#include <i386/linux/linux_proto.h>
53#include <compat/linux/linux_ipc.h>
54#include <compat/linux/linux_signal.h>
55#include <compat/linux/linux_util.h>
56
57struct linux_descriptor {
58 unsigned int entry_number;
59 unsigned long base_addr;
60 unsigned int limit;
61 unsigned int seg_32bit:1;
62 unsigned int contents:2;
63 unsigned int read_exec_only:1;
64 unsigned int limit_in_pages:1;
65 unsigned int seg_not_present:1;
66 unsigned int useable:1;
57struct l_descriptor {
58 l_uint entry_number;
59 l_ulong base_addr;
60 l_uint limit;
61 l_uint seg_32bit:1;
62 l_uint contents:2;
63 l_uint read_exec_only:1;
64 l_uint limit_in_pages:1;
65 l_uint seg_not_present:1;
66 l_uint useable:1;
67};
68
67};
68
69struct linux_select_argv {
70 int nfds;
71 fd_set *readfds;
72 fd_set *writefds;
73 fd_set *exceptfds;
74 struct timeval *timeout;
69struct l_old_select_argv {
70 l_int nfds;
71 l_fd_set *readfds;
72 l_fd_set *writefds;
73 l_fd_set *exceptfds;
74 struct l_timeval *timeout;
75};
76
77int
78linux_to_bsd_sigaltstack(int lsa)
79{
80 int bsa = 0;
81
82 if (lsa & LINUX_SS_DISABLE)

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

113#endif
114
115 bsd.fname = args->path;
116 bsd.argv = args->argp;
117 bsd.envv = args->envp;
118 return (execve(p, &bsd));
119}
120
75};
76
77int
78linux_to_bsd_sigaltstack(int lsa)
79{
80 int bsa = 0;
81
82 if (lsa & LINUX_SS_DISABLE)

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

113#endif
114
115 bsd.fname = args->path;
116 bsd.argv = args->argp;
117 bsd.envv = args->envp;
118 return (execve(p, &bsd));
119}
120
121struct l_ipc_kludge {
122 struct l_msgbuf *msgp;
123 l_long msgtyp;
124};
125
121int
122linux_ipc(struct proc *p, struct linux_ipc_args *args)
123{
126int
127linux_ipc(struct proc *p, struct linux_ipc_args *args)
128{
124 switch (args->what) {
125 case LINUX_SEMOP:
126 return (linux_semop(p, args));
127 case LINUX_SEMGET:
128 return (linux_semget(p, args));
129 case LINUX_SEMCTL:
130 return (linux_semctl(p, args));
131 case LINUX_MSGSND:
132 return (linux_msgsnd(p, args));
133 case LINUX_MSGRCV:
134 return (linux_msgrcv(p, args));
135 case LINUX_MSGGET:
136 return (linux_msgget(p, args));
137 case LINUX_MSGCTL:
138 return (linux_msgctl(p, args));
139 case LINUX_SHMAT:
140 return (linux_shmat(p, args));
141 case LINUX_SHMDT:
142 return (linux_shmdt(p, args));
143 case LINUX_SHMGET:
144 return (linux_shmget(p, args));
145 case LINUX_SHMCTL:
146 return (linux_shmctl(p, args));
129
130 switch (args->what & 0xFFFF) {
131 case LINUX_SEMOP: {
132 struct linux_semop_args a;
133
134 a.semid = args->arg1;
135 a.tsops = args->ptr;
136 a.nsops = args->arg2;
137 return (linux_semop(p, &a));
147 }
138 }
139 case LINUX_SEMGET: {
140 struct linux_semget_args a;
148
141
149 uprintf("LINUX: 'ipc' typ=%d not implemented\n", args->what);
150 return (ENOSYS);
142 a.key = args->arg1;
143 a.nsems = args->arg2;
144 a.semflg = args->arg3;
145 return (linux_semget(p, &a));
146 }
147 case LINUX_SEMCTL: {
148 struct linux_semctl_args a;
149 int error;
150
151 a.semid = args->arg1;
152 a.semnum = args->arg2;
153 a.cmd = args->arg3;
154 error = copyin((caddr_t)args->ptr, &a.arg, sizeof(a.arg));
155 if (error)
156 return (error);
157 return (linux_semctl(p, &a));
158 }
159 case LINUX_MSGSND: {
160 struct linux_msgsnd_args a;
161
162 a.msqid = args->arg1;
163 a.msgp = args->ptr;
164 a.msgsz = args->arg2;
165 a.msgflg = args->arg3;
166 return (linux_msgsnd(p, &a));
167 }
168 case LINUX_MSGRCV: {
169 struct linux_msgrcv_args a;
170
171 a.msqid = args->arg1;
172 a.msgsz = args->arg2;
173 a.msgflg = args->arg3;
174 if ((args->what >> 16) == 0) {
175 struct l_ipc_kludge tmp;
176 int error;
177
178 if (args->ptr == NULL)
179 return (EINVAL);
180 error = copyin((caddr_t)args->ptr, &tmp, sizeof(tmp));
181 if (error)
182 return (error);
183 a.msgp = tmp.msgp;
184 a.msgtyp = tmp.msgtyp;
185 } else {
186 a.msgp = args->ptr;
187 a.msgtyp = args->arg5;
188 }
189 return (linux_msgrcv(p, &a));
190 }
191 case LINUX_MSGGET: {
192 struct linux_msgget_args a;
193
194 a.key = args->arg1;
195 a.msgflg = args->arg2;
196 return (linux_msgget(p, &a));
197 }
198 case LINUX_MSGCTL: {
199 struct linux_msgctl_args a;
200
201 a.msqid = args->arg1;
202 a.cmd = args->arg2;
203 a.buf = args->ptr;
204 return (linux_msgctl(p, &a));
205 }
206 case LINUX_SHMAT: {
207 struct linux_shmat_args a;
208
209 a.shmid = args->arg1;
210 a.shmaddr = args->ptr;
211 a.shmflg = args->arg2;
212 a.raddr = (l_ulong *)args->arg3;
213 return (linux_shmat(p, &a));
214 }
215 case LINUX_SHMDT: {
216 struct linux_shmdt_args a;
217
218 a.shmaddr = args->ptr;
219 return (linux_shmdt(p, &a));
220 }
221 case LINUX_SHMGET: {
222 struct linux_shmget_args a;
223
224 a.key = args->arg1;
225 a.size = args->arg2;
226 a.shmflg = args->arg3;
227 return (linux_shmget(p, &a));
228 }
229 case LINUX_SHMCTL: {
230 struct linux_shmctl_args a;
231
232 a.shmid = args->arg1;
233 a.cmd = args->arg2;
234 a.buf = args->ptr;
235 return (linux_shmctl(p, &a));
236 }
237 default:
238 break;
239 }
240
241 return (EINVAL);
151}
152
153int
242}
243
244int
154linux_select(struct proc *p, struct linux_select_args *args)
245linux_old_select(struct proc *p, struct linux_old_select_args *args)
155{
246{
156 struct linux_select_argv linux_args;
157 struct linux_newselect_args newsel;
247 struct l_old_select_argv linux_args;
248 struct linux_select_args newsel;
158 int error;
159
249 int error;
250
160#ifdef SELECT_DEBUG
161 if (ldebug(select))
162 printf(ARGS(select, "%x"), args->ptr);
251#ifdef DEBUG
252 if (ldebug(old_select))
253 printf(ARGS(old_select, "%x"), args->ptr);
163#endif
164
254#endif
255
165 error = copyin(args->ptr, &linux_args, sizeof(linux_args));
256 error = copyin((caddr_t)args->ptr, &linux_args, sizeof(linux_args));
166 if (error)
167 return (error);
168
169 newsel.nfds = linux_args.nfds;
170 newsel.readfds = linux_args.readfds;
171 newsel.writefds = linux_args.writefds;
172 newsel.exceptfds = linux_args.exceptfds;
173 newsel.timeout = linux_args.timeout;
257 if (error)
258 return (error);
259
260 newsel.nfds = linux_args.nfds;
261 newsel.readfds = linux_args.readfds;
262 newsel.writefds = linux_args.writefds;
263 newsel.exceptfds = linux_args.exceptfds;
264 newsel.timeout = linux_args.timeout;
174 return (linux_newselect(p, &newsel));
265 return (linux_select(p, &newsel));
175}
176
177int
178linux_fork(struct proc *p, struct linux_fork_args *args)
179{
180 int error;
181
182#ifdef DEBUG

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

217#define CLONE_PID 0x1000
218
219int
220linux_clone(struct proc *p, struct linux_clone_args *args)
221{
222 int error, ff = RFPROC | RFSTOPPED;
223 struct proc *p2;
224 int exit_signal;
266}
267
268int
269linux_fork(struct proc *p, struct linux_fork_args *args)
270{
271 int error;
272
273#ifdef DEBUG

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

308#define CLONE_PID 0x1000
309
310int
311linux_clone(struct proc *p, struct linux_clone_args *args)
312{
313 int error, ff = RFPROC | RFSTOPPED;
314 struct proc *p2;
315 int exit_signal;
225 vm_offset_t start;
226
227#ifdef DEBUG
228 if (ldebug(clone)) {
229 printf(ARGS(clone, "flags %x, stack %x"),
230 (unsigned int)args->flags, (unsigned int)args->stack);
231 if (args->flags & CLONE_PID)
232 printf(LMSG("CLONE_PID not yet supported"));
233 }

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

238
239 exit_signal = args->flags & 0x000000ff;
240 if (exit_signal >= LINUX_NSIG)
241 return (EINVAL);
242
243 if (exit_signal <= LINUX_SIGTBLSZ)
244 exit_signal = linux_to_bsd_signal[_SIG_IDX(exit_signal)];
245
316
317#ifdef DEBUG
318 if (ldebug(clone)) {
319 printf(ARGS(clone, "flags %x, stack %x"),
320 (unsigned int)args->flags, (unsigned int)args->stack);
321 if (args->flags & CLONE_PID)
322 printf(LMSG("CLONE_PID not yet supported"));
323 }

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

328
329 exit_signal = args->flags & 0x000000ff;
330 if (exit_signal >= LINUX_NSIG)
331 return (EINVAL);
332
333 if (exit_signal <= LINUX_SIGTBLSZ)
334 exit_signal = linux_to_bsd_signal[_SIG_IDX(exit_signal)];
335
246 /* RFTHREAD probably not necessary here, but it shouldn't hurt */
247 ff |= RFTHREAD;
248
249 if (args->flags & CLONE_VM)
250 ff |= RFMEM;
251 if (args->flags & CLONE_SIGHAND)
252 ff |= RFSIGSHARE;
253 if (!(args->flags & CLONE_FILES))
254 ff |= RFFDG;
255
336 if (args->flags & CLONE_VM)
337 ff |= RFMEM;
338 if (args->flags & CLONE_SIGHAND)
339 ff |= RFSIGSHARE;
340 if (!(args->flags & CLONE_FILES))
341 ff |= RFFDG;
342
256 error = 0;
257 start = 0;
343 mtx_lock(&Giant);
344 error = fork1(p, ff, &p2);
345 if (error == 0) {
346 p->p_retval[0] = p2->p_pid;
347 p->p_retval[1] = 0;
258
348
259 if ((error = fork1(p, ff, &p2)) != 0)
260 return (error);
349 PROC_LOCK(p2);
350 p2->p_sigparent = exit_signal;
351 p2->p_frame->tf_esp = (unsigned int)args->stack;
261
352
262 PROC_LOCK(p2);
263 p2->p_sigparent = exit_signal;
264 PROC_UNLOCK(p2);
265 p2->p_frame->tf_esp = (unsigned int)args->stack;
266
267#ifdef DEBUG
353#ifdef DEBUG
268 if (ldebug(clone))
269 printf(LMSG("clone: successful rfork to %ld"),
270 (long)p2->p_pid);
354 if (ldebug(clone))
355 printf(LMSG("clone: successful rfork to %ld"),
356 (long)p2->p_pid);
271#endif
272
357#endif
358
273 /*
274 * Make this runnable after we are finished with it.
275 */
276 mtx_lock_spin(&sched_lock);
277 p2->p_stat = SRUN;
278 setrunqueue(p2);
279 mtx_unlock_spin(&sched_lock);
359 /*
360 * Make this runnable after we are finished with it.
361 */
362 mtx_lock_spin(&sched_lock);
363 p2->p_stat = SRUN;
364 setrunqueue(p2);
365 mtx_unlock_spin(&sched_lock);
366 PROC_UNLOCK(p2);
367 }
368 mtx_unlock(&Giant);
280
369
281 p->p_retval[0] = p2->p_pid;
282 p->p_retval[1] = 0;
283 return (0);
370 return (error);
284}
285
286/* XXX move */
371}
372
373/* XXX move */
287struct linux_mmap_argv {
288 linux_caddr_t addr;
289 int len;
290 int prot;
291 int flags;
292 int fd;
293 int pos;
374struct l_mmap_argv {
375 l_caddr_t addr;
376 l_int len;
377 l_int prot;
378 l_int flags;
379 l_int fd;
380 l_int pos;
294};
295
296#define STACK_SIZE (2 * 1024 * 1024)
297#define GUARD_SIZE (4 * PAGE_SIZE)
298
299int
300linux_mmap(struct proc *p, struct linux_mmap_args *args)
301{
302 struct mmap_args /* {
303 caddr_t addr;
304 size_t len;
305 int prot;
306 int flags;
307 int fd;
308 long pad;
309 off_t pos;
310 } */ bsd_args;
311 int error;
381};
382
383#define STACK_SIZE (2 * 1024 * 1024)
384#define GUARD_SIZE (4 * PAGE_SIZE)
385
386int
387linux_mmap(struct proc *p, struct linux_mmap_args *args)
388{
389 struct mmap_args /* {
390 caddr_t addr;
391 size_t len;
392 int prot;
393 int flags;
394 int fd;
395 long pad;
396 off_t pos;
397 } */ bsd_args;
398 int error;
312 struct linux_mmap_argv linux_args;
399 struct l_mmap_argv linux_args;
313
400
314 error = copyin(args->ptr, &linux_args, sizeof(linux_args));
401 error = copyin((caddr_t)args->ptr, &linux_args, sizeof(linux_args));
315 if (error)
316 return (error);
317
318#ifdef DEBUG
319 if (ldebug(mmap))
320 printf(ARGS(mmap, "%p, %d, %d, 0x%08x, %d, %d"),
321 (void *)linux_args.addr, linux_args.len, linux_args.prot,
322 linux_args.flags, linux_args.fd, linux_args.pos);

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

483linux_modify_ldt(p, uap)
484 struct proc *p;
485 struct linux_modify_ldt_args *uap;
486{
487 int error;
488 caddr_t sg;
489 struct sysarch_args args;
490 struct i386_ldt_args *ldt;
402 if (error)
403 return (error);
404
405#ifdef DEBUG
406 if (ldebug(mmap))
407 printf(ARGS(mmap, "%p, %d, %d, 0x%08x, %d, %d"),
408 (void *)linux_args.addr, linux_args.len, linux_args.prot,
409 linux_args.flags, linux_args.fd, linux_args.pos);

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

570linux_modify_ldt(p, uap)
571 struct proc *p;
572 struct linux_modify_ldt_args *uap;
573{
574 int error;
575 caddr_t sg;
576 struct sysarch_args args;
577 struct i386_ldt_args *ldt;
491 struct linux_descriptor ld;
578 struct l_descriptor ld;
492 union descriptor *desc;
493
494 sg = stackgap_init();
495
496 if (uap->ptr == NULL)
497 return (EINVAL);
498
499 switch (uap->func) {

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

547 }
548
549 return (error);
550}
551
552int
553linux_sigaction(struct proc *p, struct linux_sigaction_args *args)
554{
579 union descriptor *desc;
580
581 sg = stackgap_init();
582
583 if (uap->ptr == NULL)
584 return (EINVAL);
585
586 switch (uap->func) {

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

634 }
635
636 return (error);
637}
638
639int
640linux_sigaction(struct proc *p, struct linux_sigaction_args *args)
641{
555 linux_osigaction_t osa;
556 linux_sigaction_t act, oact;
642 l_osigaction_t osa;
643 l_sigaction_t act, oact;
557 int error;
558
559#ifdef DEBUG
560 if (ldebug(sigaction))
561 printf(ARGS(sigaction, "%d, %p, %p"),
562 args->sig, (void *)args->nsa, (void *)args->osa);
563#endif
564
565 if (args->nsa != NULL) {
644 int error;
645
646#ifdef DEBUG
647 if (ldebug(sigaction))
648 printf(ARGS(sigaction, "%d, %p, %p"),
649 args->sig, (void *)args->nsa, (void *)args->osa);
650#endif
651
652 if (args->nsa != NULL) {
566 error = copyin(args->nsa, &osa, sizeof(linux_osigaction_t));
653 error = copyin((caddr_t)args->nsa, &osa,
654 sizeof(l_osigaction_t));
567 if (error)
568 return (error);
569 act.lsa_handler = osa.lsa_handler;
570 act.lsa_flags = osa.lsa_flags;
571 act.lsa_restorer = osa.lsa_restorer;
572 LINUX_SIGEMPTYSET(act.lsa_mask);
573 act.lsa_mask.__bits[0] = osa.lsa_mask;
574 }
575
576 error = linux_do_sigaction(p, args->sig, args->nsa ? &act : NULL,
577 args->osa ? &oact : NULL);
578
579 if (args->osa != NULL && !error) {
580 osa.lsa_handler = oact.lsa_handler;
581 osa.lsa_flags = oact.lsa_flags;
582 osa.lsa_restorer = oact.lsa_restorer;
583 osa.lsa_mask = oact.lsa_mask.__bits[0];
655 if (error)
656 return (error);
657 act.lsa_handler = osa.lsa_handler;
658 act.lsa_flags = osa.lsa_flags;
659 act.lsa_restorer = osa.lsa_restorer;
660 LINUX_SIGEMPTYSET(act.lsa_mask);
661 act.lsa_mask.__bits[0] = osa.lsa_mask;
662 }
663
664 error = linux_do_sigaction(p, args->sig, args->nsa ? &act : NULL,
665 args->osa ? &oact : NULL);
666
667 if (args->osa != NULL && !error) {
668 osa.lsa_handler = oact.lsa_handler;
669 osa.lsa_flags = oact.lsa_flags;
670 osa.lsa_restorer = oact.lsa_restorer;
671 osa.lsa_mask = oact.lsa_mask.__bits[0];
584 error = copyout(&osa, args->osa, sizeof(linux_osigaction_t));
672 error = copyout(&osa, (caddr_t)args->osa,
673 sizeof(l_osigaction_t));
585 }
586
587 return (error);
588}
589
590/*
591 * Linux has two extra args, restart and oldmask. We dont use these,
592 * but it seems that "restart" is actually a context pointer that
593 * enables the signal to happen with a different register set.
594 */
595int
596linux_sigsuspend(struct proc *p, struct linux_sigsuspend_args *args)
597{
598 struct sigsuspend_args bsd;
599 sigset_t *sigmask;
674 }
675
676 return (error);
677}
678
679/*
680 * Linux has two extra args, restart and oldmask. We dont use these,
681 * but it seems that "restart" is actually a context pointer that
682 * enables the signal to happen with a different register set.
683 */
684int
685linux_sigsuspend(struct proc *p, struct linux_sigsuspend_args *args)
686{
687 struct sigsuspend_args bsd;
688 sigset_t *sigmask;
600 linux_sigset_t mask;
689 l_sigset_t mask;
601 caddr_t sg = stackgap_init();
602
603#ifdef DEBUG
604 if (ldebug(sigsuspend))
605 printf(ARGS(sigsuspend, "%08lx"), (unsigned long)args->mask);
606#endif
607
608 sigmask = stackgap_alloc(&sg, sizeof(sigset_t));

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

613 return (sigsuspend(p, &bsd));
614}
615
616int
617linux_rt_sigsuspend(p, uap)
618 struct proc *p;
619 struct linux_rt_sigsuspend_args *uap;
620{
690 caddr_t sg = stackgap_init();
691
692#ifdef DEBUG
693 if (ldebug(sigsuspend))
694 printf(ARGS(sigsuspend, "%08lx"), (unsigned long)args->mask);
695#endif
696
697 sigmask = stackgap_alloc(&sg, sizeof(sigset_t));

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

702 return (sigsuspend(p, &bsd));
703}
704
705int
706linux_rt_sigsuspend(p, uap)
707 struct proc *p;
708 struct linux_rt_sigsuspend_args *uap;
709{
621 linux_sigset_t lmask;
710 l_sigset_t lmask;
622 sigset_t *bmask;
623 struct sigsuspend_args bsd;
624 caddr_t sg = stackgap_init();
625 int error;
626
627#ifdef DEBUG
628 if (ldebug(rt_sigsuspend))
629 printf(ARGS(rt_sigsuspend, "%p, %d"),
630 (void *)uap->newset, uap->sigsetsize);
631#endif
632
711 sigset_t *bmask;
712 struct sigsuspend_args bsd;
713 caddr_t sg = stackgap_init();
714 int error;
715
716#ifdef DEBUG
717 if (ldebug(rt_sigsuspend))
718 printf(ARGS(rt_sigsuspend, "%p, %d"),
719 (void *)uap->newset, uap->sigsetsize);
720#endif
721
633 if (uap->sigsetsize != sizeof(linux_sigset_t))
722 if (uap->sigsetsize != sizeof(l_sigset_t))
634 return (EINVAL);
635
723 return (EINVAL);
724
636 error = copyin(uap->newset, &lmask, sizeof(linux_sigset_t));
725 error = copyin(uap->newset, &lmask, sizeof(l_sigset_t));
637 if (error)
638 return (error);
639
640 bmask = stackgap_alloc(&sg, sizeof(sigset_t));
641 linux_to_bsd_sigset(&lmask, bmask);
642 bsd.sigmask = bmask;
643 return (sigsuspend(p, &bsd));
644}

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

665
666int
667linux_sigaltstack(p, uap)
668 struct proc *p;
669 struct linux_sigaltstack_args *uap;
670{
671 struct sigaltstack_args bsd;
672 stack_t *ss, *oss;
726 if (error)
727 return (error);
728
729 bmask = stackgap_alloc(&sg, sizeof(sigset_t));
730 linux_to_bsd_sigset(&lmask, bmask);
731 bsd.sigmask = bmask;
732 return (sigsuspend(p, &bsd));
733}

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

754
755int
756linux_sigaltstack(p, uap)
757 struct proc *p;
758 struct linux_sigaltstack_args *uap;
759{
760 struct sigaltstack_args bsd;
761 stack_t *ss, *oss;
673 linux_stack_t lss;
762 l_stack_t lss;
674 int error;
675 caddr_t sg = stackgap_init();
676
677#ifdef DEBUG
678 if (ldebug(sigaltstack))
679 printf(ARGS(sigaltstack, "%p, %p"), uap->uss, uap->uoss);
680#endif
681
682 if (uap->uss == NULL) {
683 ss = NULL;
684 } else {
763 int error;
764 caddr_t sg = stackgap_init();
765
766#ifdef DEBUG
767 if (ldebug(sigaltstack))
768 printf(ARGS(sigaltstack, "%p, %p"), uap->uss, uap->uoss);
769#endif
770
771 if (uap->uss == NULL) {
772 ss = NULL;
773 } else {
685 error = copyin(uap->uss, &lss, sizeof(linux_stack_t));
774 error = copyin(uap->uss, &lss, sizeof(l_stack_t));
686 if (error)
687 return (error);
688
689 ss = stackgap_alloc(&sg, sizeof(stack_t));
690 ss->ss_sp = lss.ss_sp;
691 ss->ss_size = lss.ss_size;
692 ss->ss_flags = linux_to_bsd_sigaltstack(lss.ss_flags);
693 }

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

698 bsd.ss = ss;
699 bsd.oss = oss;
700 error = sigaltstack(p, &bsd);
701
702 if (!error && oss != NULL) {
703 lss.ss_sp = oss->ss_sp;
704 lss.ss_size = oss->ss_size;
705 lss.ss_flags = bsd_to_linux_sigaltstack(oss->ss_flags);
775 if (error)
776 return (error);
777
778 ss = stackgap_alloc(&sg, sizeof(stack_t));
779 ss->ss_sp = lss.ss_sp;
780 ss->ss_size = lss.ss_size;
781 ss->ss_flags = linux_to_bsd_sigaltstack(lss.ss_flags);
782 }

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

787 bsd.ss = ss;
788 bsd.oss = oss;
789 error = sigaltstack(p, &bsd);
790
791 if (!error && oss != NULL) {
792 lss.ss_sp = oss->ss_sp;
793 lss.ss_size = oss->ss_size;
794 lss.ss_flags = bsd_to_linux_sigaltstack(oss->ss_flags);
706 error = copyout(&lss, uap->uoss, sizeof(linux_stack_t));
795 error = copyout(&lss, uap->uoss, sizeof(l_stack_t));
707 }
708
709 return (error);
710}
796 }
797
798 return (error);
799}