1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 2000 Marcel Moolenaar
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29 #include <sys/cdefs.h>
30 __FBSDID("$FreeBSD$");
31
32 #include <sys/param.h>
33 #include <sys/capsicum.h>
34 #include <sys/fcntl.h>
35 #include <sys/file.h>
36 #include <sys/imgact.h>
37 #include <sys/lock.h>
38 #include <sys/malloc.h>
39 #include <sys/mman.h>
40 #include <sys/mutex.h>
41 #include <sys/priv.h>
42 #include <sys/proc.h>
43 #include <sys/queue.h>
44 #include <sys/resource.h>
45 #include <sys/resourcevar.h>
46 #include <sys/sched.h>
47 #include <sys/signalvar.h>
48 #include <sys/syscallsubr.h>
49 #include <sys/sysproto.h>
50 #include <sys/systm.h>
51 #include <sys/sx.h>
52 #include <sys/unistd.h>
53 #include <sys/wait.h>
54
55 #include <machine/frame.h>
56 #include <machine/psl.h>
57 #include <machine/segments.h>
58 #include <machine/sysarch.h>
59
60 #include <vm/pmap.h>
61 #include <vm/vm.h>
62 #include <vm/vm_map.h>
63
64 #include <security/audit/audit.h>
65
66 #include <i386/linux/linux.h>
67 #include <i386/linux/linux_proto.h>
68 #include <compat/linux/linux_emul.h>
69 #include <compat/linux/linux_ipc.h>
70 #include <compat/linux/linux_misc.h>
71 #include <compat/linux/linux_mmap.h>
72 #include <compat/linux/linux_signal.h>
73 #include <compat/linux/linux_util.h>
74
75 #include <i386/include/pcb.h> /* needed for pcb definition in linux_set_thread_area */
76
77 #include "opt_posix.h"
78
79 extern struct sysentvec elf32_freebsd_sysvec; /* defined in i386/i386/elf_machdep.c */
80
81 struct l_descriptor {
82 l_uint entry_number;
83 l_ulong base_addr;
84 l_uint limit;
85 l_uint seg_32bit:1;
86 l_uint contents:2;
87 l_uint read_exec_only:1;
88 l_uint limit_in_pages:1;
89 l_uint seg_not_present:1;
90 l_uint useable:1;
91 };
92
93 struct l_old_select_argv {
94 l_int nfds;
95 l_fd_set *readfds;
96 l_fd_set *writefds;
97 l_fd_set *exceptfds;
98 struct l_timeval *timeout;
99 };
100
101 int
linux_execve(struct thread * td,struct linux_execve_args * args)102 linux_execve(struct thread *td, struct linux_execve_args *args)
103 {
104 struct image_args eargs;
105 char *newpath;
106 int error;
107
108 if (!LUSECONVPATH(td)) {
109 error = exec_copyin_args(&eargs, args->path, UIO_USERSPACE,
110 args->argp, args->envp);
111 } else {
112 LCONVPATHEXIST(td, args->path, &newpath);
113 error = exec_copyin_args(&eargs, newpath, UIO_SYSSPACE,
114 args->argp, args->envp);
115 LFREEPATH(newpath);
116 }
117 if (error == 0)
118 error = linux_common_execve(td, &eargs);
119 AUDIT_SYSCALL_EXIT(error == EJUSTRETURN ? 0 : error, td);
120 return (error);
121 }
122
123 struct l_ipc_kludge {
124 struct l_msgbuf *msgp;
125 l_long msgtyp;
126 };
127
128 int
linux_ipc(struct thread * td,struct linux_ipc_args * args)129 linux_ipc(struct thread *td, struct linux_ipc_args *args)
130 {
131
132 switch (args->what & 0xFFFF) {
133 case LINUX_SEMOP: {
134 struct linux_semop_args a;
135
136 a.semid = args->arg1;
137 a.tsops = PTRIN(args->ptr);
138 a.nsops = args->arg2;
139 return (linux_semop(td, &a));
140 }
141 case LINUX_SEMGET: {
142 struct linux_semget_args a;
143
144 a.key = args->arg1;
145 a.nsems = args->arg2;
146 a.semflg = args->arg3;
147 return (linux_semget(td, &a));
148 }
149 case LINUX_SEMCTL: {
150 struct linux_semctl_args a;
151 int error;
152
153 a.semid = args->arg1;
154 a.semnum = args->arg2;
155 a.cmd = args->arg3;
156 error = copyin(PTRIN(args->ptr), &a.arg, sizeof(a.arg));
157 if (error)
158 return (error);
159 return (linux_semctl(td, &a));
160 }
161 case LINUX_MSGSND: {
162 struct linux_msgsnd_args a;
163
164 a.msqid = args->arg1;
165 a.msgp = PTRIN(args->ptr);
166 a.msgsz = args->arg2;
167 a.msgflg = args->arg3;
168 return (linux_msgsnd(td, &a));
169 }
170 case LINUX_MSGRCV: {
171 struct linux_msgrcv_args a;
172
173 a.msqid = args->arg1;
174 a.msgsz = args->arg2;
175 a.msgflg = args->arg3;
176 if ((args->what >> 16) == 0) {
177 struct l_ipc_kludge tmp;
178 int error;
179
180 if (args->ptr == 0)
181 return (EINVAL);
182 error = copyin(PTRIN(args->ptr), &tmp, sizeof(tmp));
183 if (error)
184 return (error);
185 a.msgp = PTRIN(tmp.msgp);
186 a.msgtyp = tmp.msgtyp;
187 } else {
188 a.msgp = PTRIN(args->ptr);
189 a.msgtyp = args->arg5;
190 }
191 return (linux_msgrcv(td, &a));
192 }
193 case LINUX_MSGGET: {
194 struct linux_msgget_args a;
195
196 a.key = args->arg1;
197 a.msgflg = args->arg2;
198 return (linux_msgget(td, &a));
199 }
200 case LINUX_MSGCTL: {
201 struct linux_msgctl_args a;
202
203 a.msqid = args->arg1;
204 a.cmd = args->arg2;
205 a.buf = PTRIN(args->ptr);
206 return (linux_msgctl(td, &a));
207 }
208 case LINUX_SHMAT: {
209 struct linux_shmat_args a;
210 l_uintptr_t addr;
211 int error;
212
213 a.shmid = args->arg1;
214 a.shmaddr = PTRIN(args->ptr);
215 a.shmflg = args->arg2;
216 error = linux_shmat(td, &a);
217 if (error != 0)
218 return (error);
219 addr = td->td_retval[0];
220 error = copyout(&addr, PTRIN(args->arg3), sizeof(addr));
221 td->td_retval[0] = 0;
222 return (error);
223 }
224 case LINUX_SHMDT: {
225 struct linux_shmdt_args a;
226
227 a.shmaddr = PTRIN(args->ptr);
228 return (linux_shmdt(td, &a));
229 }
230 case LINUX_SHMGET: {
231 struct linux_shmget_args a;
232
233 a.key = args->arg1;
234 a.size = args->arg2;
235 a.shmflg = args->arg3;
236 return (linux_shmget(td, &a));
237 }
238 case LINUX_SHMCTL: {
239 struct linux_shmctl_args a;
240
241 a.shmid = args->arg1;
242 a.cmd = args->arg2;
243 a.buf = PTRIN(args->ptr);
244 return (linux_shmctl(td, &a));
245 }
246 default:
247 break;
248 }
249
250 return (EINVAL);
251 }
252
253 int
linux_old_select(struct thread * td,struct linux_old_select_args * args)254 linux_old_select(struct thread *td, struct linux_old_select_args *args)
255 {
256 struct l_old_select_argv linux_args;
257 struct linux_select_args newsel;
258 int error;
259
260 error = copyin(args->ptr, &linux_args, sizeof(linux_args));
261 if (error)
262 return (error);
263
264 newsel.nfds = linux_args.nfds;
265 newsel.readfds = linux_args.readfds;
266 newsel.writefds = linux_args.writefds;
267 newsel.exceptfds = linux_args.exceptfds;
268 newsel.timeout = linux_args.timeout;
269 return (linux_select(td, &newsel));
270 }
271
272 int
linux_set_cloned_tls(struct thread * td,void * desc)273 linux_set_cloned_tls(struct thread *td, void *desc)
274 {
275 struct segment_descriptor sd;
276 struct l_user_desc info;
277 int idx, error;
278 int a[2];
279
280 error = copyin(desc, &info, sizeof(struct l_user_desc));
281 if (error) {
282 linux_msg(td, "set_cloned_tls copyin failed!");
283 } else {
284 idx = info.entry_number;
285
286 /*
287 * looks like we're getting the idx we returned
288 * in the set_thread_area() syscall
289 */
290 if (idx != 6 && idx != 3) {
291 linux_msg(td, "set_cloned_tls resetting idx!");
292 idx = 3;
293 }
294
295 /* this doesnt happen in practice */
296 if (idx == 6) {
297 /* we might copy out the entry_number as 3 */
298 info.entry_number = 3;
299 error = copyout(&info, desc, sizeof(struct l_user_desc));
300 if (error)
301 linux_msg(td, "set_cloned_tls copyout failed!");
302 }
303
304 a[0] = LINUX_LDT_entry_a(&info);
305 a[1] = LINUX_LDT_entry_b(&info);
306
307 memcpy(&sd, &a, sizeof(a));
308 /* set %gs */
309 td->td_pcb->pcb_gsd = sd;
310 td->td_pcb->pcb_gs = GSEL(GUGS_SEL, SEL_UPL);
311 }
312
313 return (error);
314 }
315
316 int
linux_set_upcall(struct thread * td,register_t stack)317 linux_set_upcall(struct thread *td, register_t stack)
318 {
319
320 if (stack)
321 td->td_frame->tf_esp = stack;
322
323 /*
324 * The newly created Linux thread returns
325 * to the user space by the same path that a parent do.
326 */
327 td->td_frame->tf_eax = 0;
328 return (0);
329 }
330
331 int
linux_mmap2(struct thread * td,struct linux_mmap2_args * args)332 linux_mmap2(struct thread *td, struct linux_mmap2_args *args)
333 {
334
335 return (linux_mmap_common(td, args->addr, args->len, args->prot,
336 args->flags, args->fd, (uint64_t)(uint32_t)args->pgoff *
337 PAGE_SIZE));
338 }
339
340 int
linux_mmap(struct thread * td,struct linux_mmap_args * args)341 linux_mmap(struct thread *td, struct linux_mmap_args *args)
342 {
343 int error;
344 struct l_mmap_argv linux_args;
345
346 error = copyin(args->ptr, &linux_args, sizeof(linux_args));
347 if (error)
348 return (error);
349
350 return (linux_mmap_common(td, linux_args.addr, linux_args.len,
351 linux_args.prot, linux_args.flags, linux_args.fd,
352 (uint32_t)linux_args.pgoff));
353 }
354
355 int
linux_mprotect(struct thread * td,struct linux_mprotect_args * uap)356 linux_mprotect(struct thread *td, struct linux_mprotect_args *uap)
357 {
358
359 return (linux_mprotect_common(td, PTROUT(uap->addr), uap->len, uap->prot));
360 }
361
362 int
linux_madvise(struct thread * td,struct linux_madvise_args * uap)363 linux_madvise(struct thread *td, struct linux_madvise_args *uap)
364 {
365
366 return (linux_madvise_common(td, PTROUT(uap->addr), uap->len, uap->behav));
367 }
368
369 int
linux_ioperm(struct thread * td,struct linux_ioperm_args * args)370 linux_ioperm(struct thread *td, struct linux_ioperm_args *args)
371 {
372 int error;
373 struct i386_ioperm_args iia;
374
375 iia.start = args->start;
376 iia.length = args->length;
377 iia.enable = args->enable;
378 error = i386_set_ioperm(td, &iia);
379 return (error);
380 }
381
382 int
linux_iopl(struct thread * td,struct linux_iopl_args * args)383 linux_iopl(struct thread *td, struct linux_iopl_args *args)
384 {
385 int error;
386
387 if (args->level < 0 || args->level > 3)
388 return (EINVAL);
389 if ((error = priv_check(td, PRIV_IO)) != 0)
390 return (error);
391 if ((error = securelevel_gt(td->td_ucred, 0)) != 0)
392 return (error);
393 td->td_frame->tf_eflags = (td->td_frame->tf_eflags & ~PSL_IOPL) |
394 (args->level * (PSL_IOPL / 3));
395 return (0);
396 }
397
398 int
linux_modify_ldt(struct thread * td,struct linux_modify_ldt_args * uap)399 linux_modify_ldt(struct thread *td, struct linux_modify_ldt_args *uap)
400 {
401 int error;
402 struct i386_ldt_args ldt;
403 struct l_descriptor ld;
404 union descriptor desc;
405 int size, written;
406
407 switch (uap->func) {
408 case 0x00: /* read_ldt */
409 ldt.start = 0;
410 ldt.descs = uap->ptr;
411 ldt.num = uap->bytecount / sizeof(union descriptor);
412 error = i386_get_ldt(td, &ldt);
413 td->td_retval[0] *= sizeof(union descriptor);
414 break;
415 case 0x02: /* read_default_ldt = 0 */
416 size = 5*sizeof(struct l_desc_struct);
417 if (size > uap->bytecount)
418 size = uap->bytecount;
419 for (written = error = 0; written < size && error == 0; written++)
420 error = subyte((char *)uap->ptr + written, 0);
421 td->td_retval[0] = written;
422 break;
423 case 0x01: /* write_ldt */
424 case 0x11: /* write_ldt */
425 if (uap->bytecount != sizeof(ld))
426 return (EINVAL);
427
428 error = copyin(uap->ptr, &ld, sizeof(ld));
429 if (error)
430 return (error);
431
432 ldt.start = ld.entry_number;
433 ldt.descs = &desc;
434 ldt.num = 1;
435 desc.sd.sd_lolimit = (ld.limit & 0x0000ffff);
436 desc.sd.sd_hilimit = (ld.limit & 0x000f0000) >> 16;
437 desc.sd.sd_lobase = (ld.base_addr & 0x00ffffff);
438 desc.sd.sd_hibase = (ld.base_addr & 0xff000000) >> 24;
439 desc.sd.sd_type = SDT_MEMRO | ((ld.read_exec_only ^ 1) << 1) |
440 (ld.contents << 2);
441 desc.sd.sd_dpl = 3;
442 desc.sd.sd_p = (ld.seg_not_present ^ 1);
443 desc.sd.sd_xx = 0;
444 desc.sd.sd_def32 = ld.seg_32bit;
445 desc.sd.sd_gran = ld.limit_in_pages;
446 error = i386_set_ldt(td, &ldt, &desc);
447 break;
448 default:
449 error = ENOSYS;
450 break;
451 }
452
453 if (error == EOPNOTSUPP) {
454 linux_msg(td, "modify_ldt needs kernel option USER_LDT");
455 error = ENOSYS;
456 }
457
458 return (error);
459 }
460
461 int
linux_sigaction(struct thread * td,struct linux_sigaction_args * args)462 linux_sigaction(struct thread *td, struct linux_sigaction_args *args)
463 {
464 l_osigaction_t osa;
465 l_sigaction_t act, oact;
466 int error;
467
468 if (args->nsa != NULL) {
469 error = copyin(args->nsa, &osa, sizeof(l_osigaction_t));
470 if (error)
471 return (error);
472 act.lsa_handler = osa.lsa_handler;
473 act.lsa_flags = osa.lsa_flags;
474 act.lsa_restorer = osa.lsa_restorer;
475 LINUX_SIGEMPTYSET(act.lsa_mask);
476 act.lsa_mask.__mask = osa.lsa_mask;
477 }
478
479 error = linux_do_sigaction(td, args->sig, args->nsa ? &act : NULL,
480 args->osa ? &oact : NULL);
481
482 if (args->osa != NULL && !error) {
483 osa.lsa_handler = oact.lsa_handler;
484 osa.lsa_flags = oact.lsa_flags;
485 osa.lsa_restorer = oact.lsa_restorer;
486 osa.lsa_mask = oact.lsa_mask.__mask;
487 error = copyout(&osa, args->osa, sizeof(l_osigaction_t));
488 }
489
490 return (error);
491 }
492
493 /*
494 * Linux has two extra args, restart and oldmask. We dont use these,
495 * but it seems that "restart" is actually a context pointer that
496 * enables the signal to happen with a different register set.
497 */
498 int
linux_sigsuspend(struct thread * td,struct linux_sigsuspend_args * args)499 linux_sigsuspend(struct thread *td, struct linux_sigsuspend_args *args)
500 {
501 sigset_t sigmask;
502 l_sigset_t mask;
503
504 LINUX_SIGEMPTYSET(mask);
505 mask.__mask = args->mask;
506 linux_to_bsd_sigset(&mask, &sigmask);
507 return (kern_sigsuspend(td, sigmask));
508 }
509
510 int
linux_pause(struct thread * td,struct linux_pause_args * args)511 linux_pause(struct thread *td, struct linux_pause_args *args)
512 {
513 struct proc *p = td->td_proc;
514 sigset_t sigmask;
515
516 PROC_LOCK(p);
517 sigmask = td->td_sigmask;
518 PROC_UNLOCK(p);
519 return (kern_sigsuspend(td, sigmask));
520 }
521
522 int
linux_sigaltstack(struct thread * td,struct linux_sigaltstack_args * uap)523 linux_sigaltstack(struct thread *td, struct linux_sigaltstack_args *uap)
524 {
525 stack_t ss, oss;
526 l_stack_t lss;
527 int error;
528
529 if (uap->uss != NULL) {
530 error = copyin(uap->uss, &lss, sizeof(l_stack_t));
531 if (error)
532 return (error);
533
534 ss.ss_sp = lss.ss_sp;
535 ss.ss_size = lss.ss_size;
536 ss.ss_flags = linux_to_bsd_sigaltstack(lss.ss_flags);
537 }
538 error = kern_sigaltstack(td, (uap->uss != NULL) ? &ss : NULL,
539 (uap->uoss != NULL) ? &oss : NULL);
540 if (!error && uap->uoss != NULL) {
541 lss.ss_sp = oss.ss_sp;
542 lss.ss_size = oss.ss_size;
543 lss.ss_flags = bsd_to_linux_sigaltstack(oss.ss_flags);
544 error = copyout(&lss, uap->uoss, sizeof(l_stack_t));
545 }
546
547 return (error);
548 }
549
550 int
linux_set_thread_area(struct thread * td,struct linux_set_thread_area_args * args)551 linux_set_thread_area(struct thread *td, struct linux_set_thread_area_args *args)
552 {
553 struct l_user_desc info;
554 int error;
555 int idx;
556 int a[2];
557 struct segment_descriptor sd;
558
559 error = copyin(args->desc, &info, sizeof(struct l_user_desc));
560 if (error)
561 return (error);
562
563 idx = info.entry_number;
564 /*
565 * Semantics of Linux version: every thread in the system has array of
566 * 3 tls descriptors. 1st is GLIBC TLS, 2nd is WINE, 3rd unknown. This
567 * syscall loads one of the selected tls decriptors with a value and
568 * also loads GDT descriptors 6, 7 and 8 with the content of the
569 * per-thread descriptors.
570 *
571 * Semantics of FreeBSD version: I think we can ignore that Linux has 3
572 * per-thread descriptors and use just the 1st one. The tls_array[]
573 * is used only in set/get-thread_area() syscalls and for loading the
574 * GDT descriptors. In FreeBSD we use just one GDT descriptor for TLS
575 * so we will load just one.
576 *
577 * XXX: this doesn't work when a user space process tries to use more
578 * than 1 TLS segment. Comment in the Linux sources says wine might do
579 * this.
580 */
581
582 /*
583 * we support just GLIBC TLS now
584 * we should let 3 proceed as well because we use this segment so
585 * if code does two subsequent calls it should succeed
586 */
587 if (idx != 6 && idx != -1 && idx != 3)
588 return (EINVAL);
589
590 /*
591 * we have to copy out the GDT entry we use
592 * FreeBSD uses GDT entry #3 for storing %gs so load that
593 *
594 * XXX: what if a user space program doesn't check this value and tries
595 * to use 6, 7 or 8?
596 */
597 idx = info.entry_number = 3;
598 error = copyout(&info, args->desc, sizeof(struct l_user_desc));
599 if (error)
600 return (error);
601
602 if (LINUX_LDT_empty(&info)) {
603 a[0] = 0;
604 a[1] = 0;
605 } else {
606 a[0] = LINUX_LDT_entry_a(&info);
607 a[1] = LINUX_LDT_entry_b(&info);
608 }
609
610 memcpy(&sd, &a, sizeof(a));
611 /* this is taken from i386 version of cpu_set_user_tls() */
612 critical_enter();
613 /* set %gs */
614 td->td_pcb->pcb_gsd = sd;
615 PCPU_GET(fsgs_gdt)[1] = sd;
616 load_gs(GSEL(GUGS_SEL, SEL_UPL));
617 critical_exit();
618
619 return (0);
620 }
621
622 int
linux_get_thread_area(struct thread * td,struct linux_get_thread_area_args * args)623 linux_get_thread_area(struct thread *td, struct linux_get_thread_area_args *args)
624 {
625
626 struct l_user_desc info;
627 int error;
628 int idx;
629 struct l_desc_struct desc;
630 struct segment_descriptor sd;
631
632 error = copyin(args->desc, &info, sizeof(struct l_user_desc));
633 if (error)
634 return (error);
635
636 idx = info.entry_number;
637 /* XXX: I am not sure if we want 3 to be allowed too. */
638 if (idx != 6 && idx != 3)
639 return (EINVAL);
640
641 idx = 3;
642
643 memset(&info, 0, sizeof(info));
644
645 sd = PCPU_GET(fsgs_gdt)[1];
646
647 memcpy(&desc, &sd, sizeof(desc));
648
649 info.entry_number = idx;
650 info.base_addr = LINUX_GET_BASE(&desc);
651 info.limit = LINUX_GET_LIMIT(&desc);
652 info.seg_32bit = LINUX_GET_32BIT(&desc);
653 info.contents = LINUX_GET_CONTENTS(&desc);
654 info.read_exec_only = !LINUX_GET_WRITABLE(&desc);
655 info.limit_in_pages = LINUX_GET_LIMIT_PAGES(&desc);
656 info.seg_not_present = !LINUX_GET_PRESENT(&desc);
657 info.useable = LINUX_GET_USEABLE(&desc);
658
659 error = copyout(&info, args->desc, sizeof(struct l_user_desc));
660 if (error)
661 return (EFAULT);
662
663 return (0);
664 }
665
666 /* XXX: this wont work with module - convert it */
667 int
linux_mq_open(struct thread * td,struct linux_mq_open_args * args)668 linux_mq_open(struct thread *td, struct linux_mq_open_args *args)
669 {
670 #ifdef P1003_1B_MQUEUE
671 return (sys_kmq_open(td, (struct kmq_open_args *)args));
672 #else
673 return (ENOSYS);
674 #endif
675 }
676
677 int
linux_mq_unlink(struct thread * td,struct linux_mq_unlink_args * args)678 linux_mq_unlink(struct thread *td, struct linux_mq_unlink_args *args)
679 {
680 #ifdef P1003_1B_MQUEUE
681 return (sys_kmq_unlink(td, (struct kmq_unlink_args *)args));
682 #else
683 return (ENOSYS);
684 #endif
685 }
686
687 int
linux_mq_timedsend(struct thread * td,struct linux_mq_timedsend_args * args)688 linux_mq_timedsend(struct thread *td, struct linux_mq_timedsend_args *args)
689 {
690 #ifdef P1003_1B_MQUEUE
691 return (sys_kmq_timedsend(td, (struct kmq_timedsend_args *)args));
692 #else
693 return (ENOSYS);
694 #endif
695 }
696
697 int
linux_mq_timedreceive(struct thread * td,struct linux_mq_timedreceive_args * args)698 linux_mq_timedreceive(struct thread *td, struct linux_mq_timedreceive_args *args)
699 {
700 #ifdef P1003_1B_MQUEUE
701 return (sys_kmq_timedreceive(td, (struct kmq_timedreceive_args *)args));
702 #else
703 return (ENOSYS);
704 #endif
705 }
706
707 int
linux_mq_notify(struct thread * td,struct linux_mq_notify_args * args)708 linux_mq_notify(struct thread *td, struct linux_mq_notify_args *args)
709 {
710 #ifdef P1003_1B_MQUEUE
711 return (sys_kmq_notify(td, (struct kmq_notify_args *)args));
712 #else
713 return (ENOSYS);
714 #endif
715 }
716
717 int
linux_mq_getsetattr(struct thread * td,struct linux_mq_getsetattr_args * args)718 linux_mq_getsetattr(struct thread *td, struct linux_mq_getsetattr_args *args)
719 {
720 #ifdef P1003_1B_MQUEUE
721 return (sys_kmq_setattr(td, (struct kmq_setattr_args *)args));
722 #else
723 return (ENOSYS);
724 #endif
725 }
726