linux32_unistd.c revision 1.36 1 /* $NetBSD: linux32_unistd.c,v 1.36 2013/11/18 01:35:22 chs Exp $ */
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 */
33
34 #include <sys/cdefs.h>
35
36 __KERNEL_RCSID(0, "$NetBSD: linux32_unistd.c,v 1.36 2013/11/18 01:35:22 chs Exp $");
37
38 #include <sys/types.h>
39 #include <sys/param.h>
40 #include <sys/fstypes.h>
41 #include <sys/signal.h>
42 #include <sys/dirent.h>
43 #include <sys/kernel.h>
44 #include <sys/fcntl.h>
45 #include <sys/select.h>
46 #include <sys/proc.h>
47 #include <sys/ucred.h>
48 #include <sys/swap.h>
49 #include <sys/kauth.h>
50 #include <sys/filedesc.h>
51 #include <sys/vfs_syscalls.h>
52
53 #include <machine/types.h>
54
55 #include <sys/syscallargs.h>
56
57 #include <compat/netbsd32/netbsd32.h>
58 #include <compat/netbsd32/netbsd32_conv.h>
59
60 #include <compat/linux/common/linux_types.h>
61 #include <compat/linux/common/linux_signal.h>
62 #include <compat/linux/common/linux_machdep.h>
63 #include <compat/linux/common/linux_misc.h>
64 #include <compat/linux/common/linux_oldolduname.h>
65 #include <compat/linux/common/linux_ipc.h>
66 #include <compat/linux/common/linux_sem.h>
67 #include <compat/linux/common/linux_fcntl.h>
68 #include <compat/linux/linux_syscallargs.h>
69
70 #include <compat/linux32/common/linux32_types.h>
71 #include <compat/linux32/common/linux32_signal.h>
72 #include <compat/linux32/common/linux32_machdep.h>
73 #include <compat/linux32/common/linux32_sched.h>
74 #include <compat/linux32/common/linux32_sysctl.h>
75 #include <compat/linux32/common/linux32_socketcall.h>
76 #include <compat/linux32/linux32_syscallargs.h>
77
78 static int linux32_select1(struct lwp *, register_t *,
79 int, fd_set *, fd_set *, fd_set *, struct timeval *);
80
81 int
82 linux32_sys_brk(struct lwp *l, const struct linux32_sys_brk_args *uap, register_t *retval)
83 {
84 /* {
85 syscallarg(netbsd32_charp) nsize;
86 } */
87 struct linux_sys_brk_args ua;
88
89 NETBSD32TOP_UAP(nsize, char);
90 return linux_sys_brk(l, &ua, retval);
91 }
92
93 int
94 linux32_sys_llseek(struct lwp *l, const struct linux32_sys_llseek_args *uap, register_t *retval)
95 {
96 /* {
97 syscallarg(int) fd;
98 syscallarg(u_int32_t) ohigh;
99 syscallarg(u_int32_t) olow;
100 syscallarg(netbsd32_voidp) res;
101 syscallarg(int) whence;
102 } */
103 struct linux_sys_llseek_args ua;
104
105 NETBSD32TO64_UAP(fd);
106 NETBSD32TO64_UAP(ohigh);
107 NETBSD32TO64_UAP(olow);
108 NETBSD32TOP_UAP(res, void);
109 NETBSD32TO64_UAP(whence);
110
111 return linux_sys_llseek(l, &ua, retval);
112 }
113
114 int
115 linux32_sys_select(struct lwp *l, const struct linux32_sys_select_args *uap, register_t *retval)
116 {
117 /* {
118 syscallarg(int) nfds;
119 syscallarg(netbsd32_fd_setp_t) readfds;
120 syscallarg(netbsd32_fd_setp_t) writefds;
121 syscallarg(netbsd32_fd_setp_t) exceptfds;
122 syscallarg(netbsd32_timeval50p_t) timeout;
123 } */
124
125 return linux32_select1(l, retval, SCARG(uap, nfds),
126 SCARG_P32(uap, readfds),
127 SCARG_P32(uap, writefds),
128 SCARG_P32(uap, exceptfds),
129 SCARG_P32(uap, timeout));
130 }
131
132 int
133 linux32_sys_oldselect(struct lwp *l, const struct linux32_sys_oldselect_args *uap, register_t *retval)
134 {
135 /* {
136 syscallarg(linux32_oldselectp_t) lsp;
137 } */
138 struct linux32_oldselect lsp32;
139 int error;
140
141 if ((error = copyin(SCARG_P32(uap, lsp), &lsp32, sizeof(lsp32))) != 0)
142 return error;
143
144 return linux32_select1(l, retval, lsp32.nfds,
145 NETBSD32PTR64(lsp32.readfds), NETBSD32PTR64(lsp32.writefds),
146 NETBSD32PTR64(lsp32.exceptfds), NETBSD32PTR64(lsp32.timeout));
147 }
148
149 static int
150 linux32_select1(struct lwp *l, register_t *retval, int nfds,
151 fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
152 struct timeval *timeout)
153 {
154 struct timespec ts0, ts1, uts, *ts = NULL;
155 struct netbsd32_timeval50 utv32;
156 int error;
157
158
159 /*
160 * Store current time for computation of the amount of
161 * time left.
162 */
163 if (timeout) {
164 if ((error = copyin(timeout, &utv32, sizeof(utv32))))
165 return error;
166
167 uts.tv_sec = utv32.tv_sec;
168 uts.tv_nsec = utv32.tv_usec * 1000;
169
170 if (itimespecfix(&uts)) {
171 /*
172 * The timeval was invalid. Convert it to something
173 * valid that will act as it does under Linux.
174 */
175 uts.tv_sec += uts.tv_nsec / 1000000000;
176 uts.tv_nsec %= 1000000000;
177 if (uts.tv_nsec < 0) {
178 uts.tv_sec -= 1;
179 uts.tv_nsec += 1000000000;
180 }
181 if (uts.tv_sec < 0)
182 timespecclear(&uts);
183 }
184 nanotime(&ts0);
185 ts = &uts;
186 } else
187 timespecclear(&uts); /* XXX GCC4 */
188
189 error = selcommon(retval, nfds, readfds, writefds, exceptfds, ts, NULL);
190
191 if (error) {
192 /*
193 * See fs/select.c in the Linux kernel. Without this,
194 * Maelstrom doesn't work.
195 */
196 if (error == ERESTART)
197 error = EINTR;
198 return error;
199 }
200
201 if (timeout) {
202 if (*retval) {
203 /*
204 * Compute how much time was left of the timeout,
205 * by subtracting the current time and the time
206 * before we started the call, and subtracting
207 * that result from the user-supplied value.
208 */
209 nanotime(&ts1);
210 timespecsub(&ts1, &ts0, &ts1);
211 timespecsub(&uts, &ts1, &uts);
212 if (uts.tv_sec < 0)
213 timespecclear(&uts);
214 } else {
215 timespecclear(&uts);
216 }
217
218 utv32.tv_sec = uts.tv_sec;
219 utv32.tv_usec = uts.tv_nsec / 1000;
220
221 if ((error = copyout(&utv32, timeout, sizeof(utv32))))
222 return error;
223 }
224
225 return 0;
226 }
227
228 static int
229 linux32_pipe(struct lwp *l, int *fd, register_t *retval, int flags)
230 {
231 /* {
232 syscallarg(netbsd32_intp) fd;
233 } */
234 int error;
235 int pfds[2];
236
237 pfds[0] = (int)retval[0];
238 pfds[1] = (int)retval[1];
239
240 if ((error = copyout(pfds, fd, 2 * sizeof(*fd))) != 0)
241 return error;
242
243 if (flags & LINUX_O_CLOEXEC) {
244 fd_set_exclose(l, retval[0], true);
245 fd_set_exclose(l, retval[1], true);
246 }
247 retval[0] = 0;
248 retval[1] = 0;
249
250 return 0;
251 }
252
253 int
254 linux32_sys_pipe(struct lwp *l, const struct linux32_sys_pipe_args *uap,
255 register_t *retval)
256 {
257 int error;
258 if ((error = pipe1(l, retval, 0)))
259 return error;
260 return linux32_pipe(l, SCARG_P32(uap, fd), retval, 0);
261 }
262
263 int
264 linux32_sys_pipe2(struct lwp *l, const struct linux32_sys_pipe2_args *uap,
265 register_t *retval)
266 {
267 int flag = 0;
268 int error;
269
270 switch (SCARG(uap, flags)) {
271 case LINUX_O_CLOEXEC:
272 break;
273 case LINUX_O_NONBLOCK:
274 case LINUX_O_NONBLOCK|LINUX_O_CLOEXEC:
275 flag = O_NONBLOCK;
276 break;
277 default:
278 return EINVAL;
279 }
280
281 if ((error = pipe1(l, retval, flag)))
282 return error;
283
284 return linux32_pipe(l, SCARG_P32(uap, fd), retval, SCARG(uap, flags));
285 }
286
287 int
288 linux32_sys_dup3(struct lwp *l, const struct linux32_sys_dup3_args *uap,
289 register_t *retval)
290 {
291 /* {
292 syscallarg(int) from;
293 syscallarg(int) to;
294 syscallarg(int) flags;
295 } */
296 struct sys_dup2_args ua;
297 int error;
298
299 NETBSD32TO64_UAP(from);
300 NETBSD32TO64_UAP(to);
301
302 if ((error = sys_dup2(l, &ua, retval)))
303 return error;
304
305 if (SCARG(uap, flags) & LINUX_O_CLOEXEC)
306 fd_set_exclose(l, SCARG(uap, to), true);
307
308 return 0;
309 }
310
311
312 int
313 linux32_sys_openat(struct lwp *l, const struct linux32_sys_openat_args *uap, register_t *retval)
314 {
315 /* {
316 syscallarg(int) fd;
317 syscallarg(const netbsd32_charp) path;
318 syscallarg(int) flags;
319 syscallarg(int) mode;
320 } */
321 struct linux_sys_openat_args ua;
322
323 NETBSD32TO64_UAP(fd);
324 NETBSD32TOP_UAP(path, const char);
325 NETBSD32TO64_UAP(flags);
326 NETBSD32TO64_UAP(mode);
327
328 return linux_sys_openat(l, &ua, retval);
329 }
330
331 int
332 linux32_sys_mknodat(struct lwp *l, const struct linux32_sys_mknodat_args *uap, register_t *retval)
333 {
334 /* {
335 syscallarg(int) fd;
336 syscallarg(const netbsd32_charp) path;
337 syscallarg(linux_umode_t) mode;
338 syscallarg(unsigned) dev;
339 } */
340 struct linux_sys_mknodat_args ua;
341
342 NETBSD32TO64_UAP(fd);
343 NETBSD32TOP_UAP(path, const char);
344 NETBSD32TO64_UAP(mode);
345 NETBSD32TO64_UAP(dev);
346
347 return linux_sys_mknodat(l, &ua, retval);
348 }
349
350 int
351 linux32_sys_linkat(struct lwp *l, const struct linux32_sys_linkat_args *uap, register_t *retval)
352 {
353 /* {
354 syscallarg(int) fd1;
355 syscallarg(netbsd32_charp) name1;
356 syscallarg(int) fd2;
357 syscallarg(netbsd32_charp) name2;
358 syscallarg(int) flags;
359 } */
360 int fd1 = SCARG(uap, fd1);
361 const char *name1 = SCARG_P32(uap, name1);
362 int fd2 = SCARG(uap, fd2);
363 const char *name2 = SCARG_P32(uap, name2);
364 int follow;
365
366 follow = SCARG(uap, flags) & LINUX_AT_SYMLINK_FOLLOW;
367
368 return do_sys_linkat(l, fd1, name1, fd2, name2, follow, retval);
369 }
370
371 int
372 linux32_sys_unlink(struct lwp *l, const struct linux32_sys_unlink_args *uap, register_t *retval)
373 {
374 /* {
375 syscallarg(const netbsd32_charp) path;
376 } */
377 struct linux_sys_unlink_args ua;
378
379 NETBSD32TOP_UAP(path, const char);
380
381 return linux_sys_unlink(l, &ua, retval);
382 }
383
384 int
385 linux32_sys_unlinkat(struct lwp *l, const struct linux32_sys_unlinkat_args *uap, register_t *retval)
386 {
387 /* {
388 syscallarg(int) fd;
389 syscallarg(const netbsd32_charp) path;
390 syscallarg(int) flag;
391 } */
392 struct linux_sys_unlinkat_args ua;
393
394 NETBSD32TO64_UAP(fd);
395 NETBSD32TOP_UAP(path, const char);
396 NETBSD32TO64_UAP(flag);
397
398 return linux_sys_unlinkat(l, &ua, retval);
399 }
400
401 int
402 linux32_sys_fchmodat(struct lwp *l, const struct linux32_sys_fchmodat_args *uap, register_t *retval)
403 {
404 /* {
405 syscallarg(int) fd;
406 syscallarg(netbsd_charp) path;
407 syscallarg(linux_umode_t) mode;
408 } */
409
410 return do_sys_chmodat(l, SCARG(uap, fd), SCARG_P32(uap, path),
411 SCARG(uap, mode), AT_SYMLINK_FOLLOW);
412 }
413
414 int
415 linux32_sys_fchownat(struct lwp *l, const struct linux32_sys_fchownat_args *uap, register_t *retval)
416 {
417 /* {
418 syscallarg(int) fd;
419 syscallarg(netbsd_charp) path;
420 syscallarg(uid_t) owner;
421 syscallarg(gid_t) group;
422 syscallarg(int) flag;
423 } */
424 int flag;
425
426 flag = linux_to_bsd_atflags(SCARG(uap, flag));
427 return do_sys_chownat(l, SCARG(uap, fd), SCARG_P32(uap, path),
428 SCARG(uap, owner), SCARG(uap, group), flag);
429 }
430
431 int
432 linux32_sys_faccessat(struct lwp *l, const struct linux32_sys_faccessat_args *uap, register_t *retval)
433 {
434 /* {
435 syscallarg(int) fd;
436 syscallarg(netbsd_charp) path;
437 syscallarg(int) amode;
438 } */
439
440 return do_sys_accessat(l, SCARG(uap, fd), SCARG_P32(uap, path),
441 SCARG(uap, amode), AT_SYMLINK_FOLLOW);
442 }
443
444 int
445 linux32_sys_utimensat(struct lwp *l, const struct linux32_sys_utimensat_args *uap, register_t *retval)
446 {
447 /* {
448 syscallarg(int) fd;
449 syscallarg(const netbsd32_charp) path;
450 syscallarg(const linux32_timespecp_t) times;
451 syscallarg(int) flags;
452 } */
453 int error;
454 struct linux32_timespec lts[2];
455 struct timespec *tsp = NULL, ts[2];
456
457 if (SCARG_P32(uap, times)) {
458 error = copyin(SCARG_P32(uap, times), <s, sizeof(lts));
459 if (error != 0)
460 return error;
461 linux32_to_native_timespec(&ts[0], <s[0]);
462 linux32_to_native_timespec(&ts[1], <s[1]);
463 tsp = ts;
464 }
465
466 return linux_do_sys_utimensat(l, SCARG(uap, fd), SCARG_P32(uap, path),
467 tsp, SCARG(uap, flag), retval);
468 }
469
470 int
471 linux32_sys_creat(struct lwp *l, const struct linux32_sys_creat_args *uap, register_t *retval)
472 {
473 /* {
474 syscallarg(const netbsd32_charp) path;
475 syscallarg(int) mode;
476 } */
477 struct sys_open_args ua;
478
479 NETBSD32TOP_UAP(path, const char);
480 SCARG(&ua, flags) = O_CREAT | O_TRUNC | O_WRONLY;
481 NETBSD32TO64_UAP(mode);
482
483 return sys_open(l, &ua, retval);
484 }
485
486 int
487 linux32_sys_mknod(struct lwp *l, const struct linux32_sys_mknod_args *uap, register_t *retval)
488 {
489 /* {
490 syscallarg(const netbsd32_charp) path;
491 syscallarg(int) mode;
492 syscallarg(int) dev;
493 } */
494 struct linux_sys_mknod_args ua;
495
496 NETBSD32TOP_UAP(path, const char);
497 NETBSD32TO64_UAP(mode);
498 NETBSD32TO64_UAP(dev);
499
500 return linux_sys_mknod(l, &ua, retval);
501 }
502
503 int
504 linux32_sys_break(struct lwp *l, const struct linux32_sys_break_args *uap, register_t *retval)
505 {
506 #if 0
507 /* {
508 syscallarg(const netbsd32_charp) nsize;
509 } */
510 #endif
511
512 return ENOSYS;
513 }
514
515 int
516 linux32_sys_swapon(struct lwp *l, const struct linux32_sys_swapon_args *uap, register_t *retval)
517 {
518 /* {
519 syscallarg(const netbsd32_charp) name;
520 } */
521 struct sys_swapctl_args ua;
522
523 SCARG(&ua, cmd) = SWAP_ON;
524 SCARG(&ua, arg) = SCARG_P32(uap, name);
525 SCARG(&ua, misc) = 0; /* priority */
526 return (sys_swapctl(l, &ua, retval));
527 }
528
529 int
530 linux32_sys_swapoff(struct lwp *l, const struct linux32_sys_swapoff_args *uap, register_t *retval)
531 {
532 /* {
533 syscallarg(const netbsd32_charp) path;
534 } */
535 struct sys_swapctl_args ua;
536
537 SCARG(&ua, cmd) = SWAP_OFF;
538 SCARG(&ua, arg) = SCARG_P32(uap, path);
539 SCARG(&ua, misc) = 0; /* priority */
540 return (sys_swapctl(l, &ua, retval));
541 }
542
543
544 int
545 linux32_sys_reboot(struct lwp *l, const struct linux32_sys_reboot_args *uap, register_t *retval)
546 {
547 /* {
548 syscallarg(int) magic1;
549 syscallarg(int) magic2;
550 syscallarg(int) cmd;
551 syscallarg(netbsd32_voidp) arg;
552 } */
553 struct linux_sys_reboot_args ua;
554
555 NETBSD32TO64_UAP(magic1);
556 NETBSD32TO64_UAP(magic2);
557 NETBSD32TO64_UAP(cmd);
558 NETBSD32TOP_UAP(arg, void);
559
560 return linux_sys_reboot(l, &ua, retval);
561 }
562
563 int
564 linux32_sys_setresuid(struct lwp *l, const struct linux32_sys_setresuid_args *uap, register_t *retval)
565 {
566 /* {
567 syscallarg(uid_t) ruid;
568 syscallarg(uid_t) euid;
569 syscallarg(uid_t) suid;
570 } */
571 struct linux_sys_setresuid_args ua;
572
573 NETBSD32TO64_UAP(ruid);
574 NETBSD32TO64_UAP(euid);
575 NETBSD32TO64_UAP(suid);
576
577 return linux_sys_setresuid(l, &ua, retval);
578 }
579
580 int
581 linux32_sys_getresuid(struct lwp *l, const struct linux32_sys_getresuid_args *uap, register_t *retval)
582 {
583 /* {
584 syscallarg(linux32_uidp_t) ruid;
585 syscallarg(linux32_uidp_t) euid;
586 syscallarg(linux32_uidp_t) suid;
587 } */
588 kauth_cred_t pc = l->l_cred;
589 int error;
590 uid_t uid;
591
592 uid = kauth_cred_getuid(pc);
593 if ((error = copyout(&uid, SCARG_P32(uap, ruid), sizeof(uid_t))) != 0)
594 return error;
595
596 uid = kauth_cred_geteuid(pc);
597 if ((error = copyout(&uid, SCARG_P32(uap, euid), sizeof(uid_t))) != 0)
598 return error;
599
600 uid = kauth_cred_getsvuid(pc);
601 return copyout(&uid, SCARG_P32(uap, suid), sizeof(uid_t));
602 }
603
604 int
605 linux32_sys_setresgid(struct lwp *l, const struct linux32_sys_setresgid_args *uap, register_t *retval)
606 {
607 /* {
608 syscallarg(gid_t) rgid;
609 syscallarg(gid_t) egid;
610 syscallarg(gid_t) sgid;
611 } */
612 struct linux_sys_setresgid_args ua;
613
614 NETBSD32TO64_UAP(rgid);
615 NETBSD32TO64_UAP(egid);
616 NETBSD32TO64_UAP(sgid);
617
618 return linux_sys_setresgid(l, &ua, retval);
619 }
620
621 int
622 linux32_sys_getresgid(struct lwp *l, const struct linux32_sys_getresgid_args *uap, register_t *retval)
623 {
624 /* {
625 syscallarg(linux32_gidp_t) rgid;
626 syscallarg(linux32_gidp_t) egid;
627 syscallarg(linux32_gidp_t) sgid;
628 } */
629 kauth_cred_t pc = l->l_cred;
630 int error;
631 gid_t gid;
632
633 gid = kauth_cred_getgid(pc);
634 if ((error = copyout(&gid, SCARG_P32(uap, rgid), sizeof(gid_t))) != 0)
635 return error;
636
637 gid = kauth_cred_getegid(pc);
638 if ((error = copyout(&gid, SCARG_P32(uap, egid), sizeof(gid_t))) != 0)
639 return error;
640
641 gid = kauth_cred_getsvgid(pc);
642 return copyout(&gid, SCARG_P32(uap, sgid), sizeof(gid_t));
643 }
644
645 int
646 linux32_sys_nice(struct lwp *l, const struct linux32_sys_nice_args *uap, register_t *retval)
647 {
648 /* {
649 syscallarg(int) incr;
650 } */
651 struct proc *p = l->l_proc;
652 struct sys_setpriority_args bsa;
653 int error;
654
655 SCARG(&bsa, which) = PRIO_PROCESS;
656 SCARG(&bsa, who) = 0;
657 SCARG(&bsa, prio) = p->p_nice - NZERO + SCARG(uap, incr);
658
659 error = sys_setpriority(l, &bsa, retval);
660 return (error) ? EPERM : 0;
661 }
662
663 int
664 linux32_sys_alarm(struct lwp *l, const struct linux32_sys_alarm_args *uap, register_t *retval)
665 {
666 /* {
667 syscallarg(unsigned int) secs;
668 } */
669 struct linux_sys_alarm_args ua;
670
671 NETBSD32TO64_UAP(secs);
672
673 return linux_sys_alarm(l, &ua, retval);
674 }
675
676 int
677 linux32_sys_fdatasync(struct lwp *l, const struct linux32_sys_fdatasync_args *uap, register_t *retval)
678 {
679 /* {
680 syscallarg(int) fd;
681 } */
682 struct linux_sys_fdatasync_args ua;
683
684 NETBSD32TO64_UAP(fd);
685
686 return linux_sys_fdatasync(l, &ua, retval);
687 }
688
689 int
690 linux32_sys_setfsuid(struct lwp *l, const struct linux32_sys_setfsuid_args *uap, register_t *retval)
691 {
692 /* {
693 syscallarg(uid_t) uid;
694 } */
695 struct linux_sys_setfsuid_args ua;
696
697 NETBSD32TO64_UAP(uid);
698
699 return linux_sys_setfsuid(l, &ua, retval);
700 }
701
702 int
703 linux32_sys_setfsgid(struct lwp *l, const struct linux32_sys_setfsgid_args *uap, register_t *retval)
704 {
705 /* {
706 syscallarg(gid_t) gid;
707 } */
708 struct linux_sys_setfsgid_args ua;
709
710 NETBSD32TO64_UAP(gid);
711
712 return linux_sys_setfsgid(l, &ua, retval);
713 }
714
715 /*
716 * pread(2).
717 */
718 int
719 linux32_sys_pread(struct lwp *l,
720 const struct linux32_sys_pread_args *uap, register_t *retval)
721 {
722 /* {
723 syscallarg(int) fd;
724 syscallarg(netbsd32_voidp) buf;
725 syscallarg(netbsd32_size_t) nbyte;
726 syscallarg(linux32_off_t) offset;
727 } */
728 struct sys_pread_args pra;
729
730 SCARG(&pra, fd) = SCARG(uap, fd);
731 SCARG(&pra, buf) = SCARG_P32(uap, buf);
732 SCARG(&pra, nbyte) = SCARG(uap, nbyte);
733 SCARG(&pra, offset) = SCARG(uap, offset);
734
735 return sys_pread(l, &pra, retval);
736 }
737
738 /*
739 * pwrite(2).
740 */
741 int
742 linux32_sys_pwrite(struct lwp *l,
743 const struct linux32_sys_pwrite_args *uap, register_t *retval)
744 {
745 /* {
746 syscallarg(int) fd;
747 syscallarg(const netbsd32_voidp) buf;
748 syscallarg(netbsd32_size_t) nbyte;
749 syscallarg(linux32_off_t) offset;
750 } */
751 struct sys_pwrite_args pra;
752
753 SCARG(&pra, fd) = SCARG(uap, fd);
754 SCARG(&pra, buf) = SCARG_P32(uap, buf);
755 SCARG(&pra, nbyte) = SCARG(uap, nbyte);
756 SCARG(&pra, offset) = SCARG(uap, offset);
757
758 return sys_pwrite(l, &pra, retval);
759 }
760
761