]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/i386/linux/linux_machdep.c
MFV r368464:
[FreeBSD/FreeBSD.git] / sys / i386 / linux / linux_machdep.c
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
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
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
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
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
317 linux_set_upcall_kse(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
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
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
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
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
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
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
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
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
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
511 linux_rt_sigsuspend(struct thread *td, struct linux_rt_sigsuspend_args *uap)
512 {
513         l_sigset_t lmask;
514         sigset_t sigmask;
515         int error;
516
517         if (uap->sigsetsize != sizeof(l_sigset_t))
518                 return (EINVAL);
519
520         error = copyin(uap->newset, &lmask, sizeof(l_sigset_t));
521         if (error)
522                 return (error);
523
524         linux_to_bsd_sigset(&lmask, &sigmask);
525         return (kern_sigsuspend(td, sigmask));
526 }
527
528 int
529 linux_pause(struct thread *td, struct linux_pause_args *args)
530 {
531         struct proc *p = td->td_proc;
532         sigset_t sigmask;
533
534         PROC_LOCK(p);
535         sigmask = td->td_sigmask;
536         PROC_UNLOCK(p);
537         return (kern_sigsuspend(td, sigmask));
538 }
539
540 int
541 linux_sigaltstack(struct thread *td, struct linux_sigaltstack_args *uap)
542 {
543         stack_t ss, oss;
544         l_stack_t lss;
545         int error;
546
547         if (uap->uss != NULL) {
548                 error = copyin(uap->uss, &lss, sizeof(l_stack_t));
549                 if (error)
550                         return (error);
551
552                 ss.ss_sp = lss.ss_sp;
553                 ss.ss_size = lss.ss_size;
554                 ss.ss_flags = linux_to_bsd_sigaltstack(lss.ss_flags);
555         }
556         error = kern_sigaltstack(td, (uap->uss != NULL) ? &ss : NULL,
557             (uap->uoss != NULL) ? &oss : NULL);
558         if (!error && uap->uoss != NULL) {
559                 lss.ss_sp = oss.ss_sp;
560                 lss.ss_size = oss.ss_size;
561                 lss.ss_flags = bsd_to_linux_sigaltstack(oss.ss_flags);
562                 error = copyout(&lss, uap->uoss, sizeof(l_stack_t));
563         }
564
565         return (error);
566 }
567
568 int
569 linux_set_thread_area(struct thread *td, struct linux_set_thread_area_args *args)
570 {
571         struct l_user_desc info;
572         int error;
573         int idx;
574         int a[2];
575         struct segment_descriptor sd;
576
577         error = copyin(args->desc, &info, sizeof(struct l_user_desc));
578         if (error)
579                 return (error);
580
581         idx = info.entry_number;
582         /*
583          * Semantics of Linux version: every thread in the system has array of
584          * 3 tls descriptors. 1st is GLIBC TLS, 2nd is WINE, 3rd unknown. This
585          * syscall loads one of the selected tls decriptors with a value and
586          * also loads GDT descriptors 6, 7 and 8 with the content of the
587          * per-thread descriptors.
588          *
589          * Semantics of FreeBSD version: I think we can ignore that Linux has 3
590          * per-thread descriptors and use just the 1st one. The tls_array[]
591          * is used only in set/get-thread_area() syscalls and for loading the
592          * GDT descriptors. In FreeBSD we use just one GDT descriptor for TLS
593          * so we will load just one.
594          *
595          * XXX: this doesn't work when a user space process tries to use more
596          * than 1 TLS segment. Comment in the Linux sources says wine might do
597          * this.
598          */
599
600         /*
601          * we support just GLIBC TLS now
602          * we should let 3 proceed as well because we use this segment so
603          * if code does two subsequent calls it should succeed
604          */
605         if (idx != 6 && idx != -1 && idx != 3)
606                 return (EINVAL);
607
608         /*
609          * we have to copy out the GDT entry we use
610          * FreeBSD uses GDT entry #3 for storing %gs so load that
611          *
612          * XXX: what if a user space program doesn't check this value and tries
613          * to use 6, 7 or 8?
614          */
615         idx = info.entry_number = 3;
616         error = copyout(&info, args->desc, sizeof(struct l_user_desc));
617         if (error)
618                 return (error);
619
620         if (LINUX_LDT_empty(&info)) {
621                 a[0] = 0;
622                 a[1] = 0;
623         } else {
624                 a[0] = LINUX_LDT_entry_a(&info);
625                 a[1] = LINUX_LDT_entry_b(&info);
626         }
627
628         memcpy(&sd, &a, sizeof(a));
629         /* this is taken from i386 version of cpu_set_user_tls() */
630         critical_enter();
631         /* set %gs */
632         td->td_pcb->pcb_gsd = sd;
633         PCPU_GET(fsgs_gdt)[1] = sd;
634         load_gs(GSEL(GUGS_SEL, SEL_UPL));
635         critical_exit();
636
637         return (0);
638 }
639
640 int
641 linux_get_thread_area(struct thread *td, struct linux_get_thread_area_args *args)
642 {
643
644         struct l_user_desc info;
645         int error;
646         int idx;
647         struct l_desc_struct desc;
648         struct segment_descriptor sd;
649
650         error = copyin(args->desc, &info, sizeof(struct l_user_desc));
651         if (error)
652                 return (error);
653
654         idx = info.entry_number;
655         /* XXX: I am not sure if we want 3 to be allowed too. */
656         if (idx != 6 && idx != 3)
657                 return (EINVAL);
658
659         idx = 3;
660
661         memset(&info, 0, sizeof(info));
662
663         sd = PCPU_GET(fsgs_gdt)[1];
664
665         memcpy(&desc, &sd, sizeof(desc));
666
667         info.entry_number = idx;
668         info.base_addr = LINUX_GET_BASE(&desc);
669         info.limit = LINUX_GET_LIMIT(&desc);
670         info.seg_32bit = LINUX_GET_32BIT(&desc);
671         info.contents = LINUX_GET_CONTENTS(&desc);
672         info.read_exec_only = !LINUX_GET_WRITABLE(&desc);
673         info.limit_in_pages = LINUX_GET_LIMIT_PAGES(&desc);
674         info.seg_not_present = !LINUX_GET_PRESENT(&desc);
675         info.useable = LINUX_GET_USEABLE(&desc);
676
677         error = copyout(&info, args->desc, sizeof(struct l_user_desc));
678         if (error)
679                 return (EFAULT);
680
681         return (0);
682 }
683
684 /* XXX: this wont work with module - convert it */
685 int
686 linux_mq_open(struct thread *td, struct linux_mq_open_args *args)
687 {
688 #ifdef P1003_1B_MQUEUE
689         return (sys_kmq_open(td, (struct kmq_open_args *)args));
690 #else
691         return (ENOSYS);
692 #endif
693 }
694
695 int
696 linux_mq_unlink(struct thread *td, struct linux_mq_unlink_args *args)
697 {
698 #ifdef P1003_1B_MQUEUE
699         return (sys_kmq_unlink(td, (struct kmq_unlink_args *)args));
700 #else
701         return (ENOSYS);
702 #endif
703 }
704
705 int
706 linux_mq_timedsend(struct thread *td, struct linux_mq_timedsend_args *args)
707 {
708 #ifdef P1003_1B_MQUEUE
709         return (sys_kmq_timedsend(td, (struct kmq_timedsend_args *)args));
710 #else
711         return (ENOSYS);
712 #endif
713 }
714
715 int
716 linux_mq_timedreceive(struct thread *td, struct linux_mq_timedreceive_args *args)
717 {
718 #ifdef P1003_1B_MQUEUE
719         return (sys_kmq_timedreceive(td, (struct kmq_timedreceive_args *)args));
720 #else
721         return (ENOSYS);
722 #endif
723 }
724
725 int
726 linux_mq_notify(struct thread *td, struct linux_mq_notify_args *args)
727 {
728 #ifdef P1003_1B_MQUEUE
729         return (sys_kmq_notify(td, (struct kmq_notify_args *)args));
730 #else
731         return (ENOSYS);
732 #endif
733 }
734
735 int
736 linux_mq_getsetattr(struct thread *td, struct linux_mq_getsetattr_args *args)
737 {
738 #ifdef P1003_1B_MQUEUE
739         return (sys_kmq_setattr(td, (struct kmq_setattr_args *)args));
740 #else
741         return (ENOSYS);
742 #endif
743 }