vfio/iommufd: Introduce a VFIOIOMMU iommufd QOM interface
[qemu/ar7.git] / bsd-user / bsd-file.h
blob3c00dc005678b263cebb40e48ffbcc7ed0bd4bce
1 /*
2 * file related system call shims and definitions
4 * Copyright (c) 2013 Stacey D. Son
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
20 #ifndef BSD_FILE_H
21 #define BSD_FILE_H
23 #include "qemu/path.h"
25 #define LOCK_PATH(p, arg) \
26 do { \
27 (p) = lock_user_string(arg); \
28 if ((p) == NULL) { \
29 return -TARGET_EFAULT; \
30 } \
31 } while (0)
33 #define UNLOCK_PATH(p, arg) unlock_user(p, arg, 0)
35 #define LOCK_PATH2(p1, arg1, p2, arg2) \
36 do { \
37 (p1) = lock_user_string(arg1); \
38 if ((p1) == NULL) { \
39 return -TARGET_EFAULT; \
40 } \
41 (p2) = lock_user_string(arg2); \
42 if ((p2) == NULL) { \
43 unlock_user(p1, arg1, 0); \
44 return -TARGET_EFAULT; \
45 } \
46 } while (0)
48 #define UNLOCK_PATH2(p1, arg1, p2, arg2) \
49 do { \
50 unlock_user(p2, arg2, 0); \
51 unlock_user(p1, arg1, 0); \
52 } while (0)
54 struct iovec *lock_iovec(int type, abi_ulong target_addr, int count, int copy);
55 void unlock_iovec(struct iovec *vec, abi_ulong target_addr, int count, int copy);
57 int safe_open(const char *path, int flags, mode_t mode);
58 int safe_openat(int fd, const char *path, int flags, mode_t mode);
60 ssize_t safe_read(int fd, void *buf, size_t nbytes);
61 ssize_t safe_pread(int fd, void *buf, size_t nbytes, off_t offset);
62 ssize_t safe_readv(int fd, const struct iovec *iov, int iovcnt);
63 ssize_t safe_preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset);
65 ssize_t safe_write(int fd, void *buf, size_t nbytes);
66 ssize_t safe_pwrite(int fd, void *buf, size_t nbytes, off_t offset);
67 ssize_t safe_writev(int fd, const struct iovec *iov, int iovcnt);
68 ssize_t safe_pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset);
70 /* read(2) */
71 static abi_long do_bsd_read(abi_long arg1, abi_long arg2, abi_long arg3)
73 abi_long ret;
74 void *p;
76 p = lock_user(VERIFY_WRITE, arg2, arg3, 0);
77 if (p == NULL) {
78 return -TARGET_EFAULT;
80 ret = get_errno(safe_read(arg1, p, arg3));
81 unlock_user(p, arg2, ret);
83 return ret;
86 /* pread(2) */
87 static abi_long do_bsd_pread(void *cpu_env, abi_long arg1,
88 abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6)
90 abi_long ret;
91 void *p;
93 p = lock_user(VERIFY_WRITE, arg2, arg3, 0);
94 if (p == NULL) {
95 return -TARGET_EFAULT;
97 if (regpairs_aligned(cpu_env) != 0) {
98 arg4 = arg5;
99 arg5 = arg6;
101 ret = get_errno(safe_pread(arg1, p, arg3, target_arg64(arg4, arg5)));
102 unlock_user(p, arg2, ret);
104 return ret;
107 /* readv(2) */
108 static abi_long do_bsd_readv(abi_long arg1, abi_long arg2, abi_long arg3)
110 abi_long ret;
111 struct iovec *vec = lock_iovec(VERIFY_WRITE, arg2, arg3, 0);
113 if (vec != NULL) {
114 ret = get_errno(safe_readv(arg1, vec, arg3));
115 unlock_iovec(vec, arg2, arg3, 1);
116 } else {
117 ret = -host_to_target_errno(errno);
120 return ret;
123 /* preadv(2) */
124 static abi_long do_bsd_preadv(void *cpu_env, abi_long arg1,
125 abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6)
127 abi_long ret;
128 struct iovec *vec = lock_iovec(VERIFY_WRITE, arg2, arg3, 1);
130 if (vec != NULL) {
131 if (regpairs_aligned(cpu_env) != 0) {
132 arg4 = arg5;
133 arg5 = arg6;
135 ret = get_errno(safe_preadv(arg1, vec, arg3, target_arg64(arg4, arg5)));
136 unlock_iovec(vec, arg2, arg3, 0);
137 } else {
138 ret = -host_to_target_errno(errno);
141 return ret;
144 /* write(2) */
145 static abi_long do_bsd_write(abi_long arg1, abi_long arg2, abi_long arg3)
147 abi_long nbytes, ret;
148 void *p;
150 /* nbytes < 0 implies that it was larger than SIZE_MAX. */
151 nbytes = arg3;
152 if (nbytes < 0) {
153 return -TARGET_EINVAL;
155 p = lock_user(VERIFY_READ, arg2, nbytes, 1);
156 if (p == NULL) {
157 return -TARGET_EFAULT;
159 ret = get_errno(safe_write(arg1, p, arg3));
160 unlock_user(p, arg2, 0);
162 return ret;
165 /* pwrite(2) */
166 static abi_long do_bsd_pwrite(void *cpu_env, abi_long arg1,
167 abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6)
169 abi_long ret;
170 void *p;
172 p = lock_user(VERIFY_READ, arg2, arg3, 1);
173 if (p == NULL) {
174 return -TARGET_EFAULT;
176 if (regpairs_aligned(cpu_env) != 0) {
177 arg4 = arg5;
178 arg5 = arg6;
180 ret = get_errno(safe_pwrite(arg1, p, arg3, target_arg64(arg4, arg5)));
181 unlock_user(p, arg2, 0);
183 return ret;
186 /* writev(2) */
187 static abi_long do_bsd_writev(abi_long arg1, abi_long arg2, abi_long arg3)
189 abi_long ret;
190 struct iovec *vec = lock_iovec(VERIFY_READ, arg2, arg3, 1);
192 if (vec != NULL) {
193 ret = get_errno(safe_writev(arg1, vec, arg3));
194 unlock_iovec(vec, arg2, arg3, 0);
195 } else {
196 ret = -host_to_target_errno(errno);
199 return ret;
202 /* pwritev(2) */
203 static abi_long do_bsd_pwritev(void *cpu_env, abi_long arg1,
204 abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6)
206 abi_long ret;
207 struct iovec *vec = lock_iovec(VERIFY_READ, arg2, arg3, 1);
209 if (vec != NULL) {
210 if (regpairs_aligned(cpu_env) != 0) {
211 arg4 = arg5;
212 arg5 = arg6;
214 ret = get_errno(safe_pwritev(arg1, vec, arg3, target_arg64(arg4, arg5)));
215 unlock_iovec(vec, arg2, arg3, 0);
216 } else {
217 ret = -host_to_target_errno(errno);
220 return ret;
223 /* open(2) */
224 static abi_long do_bsd_open(abi_long arg1, abi_long arg2, abi_long arg3)
226 abi_long ret;
227 void *p;
229 LOCK_PATH(p, arg1);
230 ret = get_errno(safe_open(path(p), target_to_host_bitmask(arg2,
231 fcntl_flags_tbl), arg3));
232 UNLOCK_PATH(p, arg1);
234 return ret;
237 /* openat(2) */
238 static abi_long do_bsd_openat(abi_long arg1, abi_long arg2,
239 abi_long arg3, abi_long arg4)
241 abi_long ret;
242 void *p;
244 LOCK_PATH(p, arg2);
245 ret = get_errno(safe_openat(arg1, path(p),
246 target_to_host_bitmask(arg3, fcntl_flags_tbl), arg4));
247 UNLOCK_PATH(p, arg2);
249 return ret;
252 /* close(2) */
253 static abi_long do_bsd_close(abi_long arg1)
255 return get_errno(close(arg1));
258 /* fdatasync(2) */
259 static abi_long do_bsd_fdatasync(abi_long arg1)
261 return get_errno(fdatasync(arg1));
264 /* fsync(2) */
265 static abi_long do_bsd_fsync(abi_long arg1)
267 return get_errno(fsync(arg1));
270 /* closefrom(2) */
271 static abi_long do_bsd_closefrom(abi_long arg1)
273 closefrom(arg1); /* returns void */
274 return get_errno(0);
277 /* revoke(2) */
278 static abi_long do_bsd_revoke(abi_long arg1)
280 abi_long ret;
281 void *p;
283 LOCK_PATH(p, arg1);
284 ret = get_errno(revoke(p)); /* XXX path(p)? */
285 UNLOCK_PATH(p, arg1);
287 return ret;
290 /* access(2) */
291 static abi_long do_bsd_access(abi_long arg1, abi_long arg2)
293 abi_long ret;
294 void *p;
296 LOCK_PATH(p, arg1);
297 ret = get_errno(access(path(p), arg2));
298 UNLOCK_PATH(p, arg1);
300 return ret;
303 /* eaccess(2) */
304 static abi_long do_bsd_eaccess(abi_long arg1, abi_long arg2)
306 abi_long ret;
307 void *p;
309 LOCK_PATH(p, arg1);
310 ret = get_errno(eaccess(path(p), arg2));
311 UNLOCK_PATH(p, arg1);
313 return ret;
316 /* faccessat(2) */
317 static abi_long do_bsd_faccessat(abi_long arg1, abi_long arg2,
318 abi_long arg3, abi_long arg4)
320 abi_long ret;
321 void *p;
323 LOCK_PATH(p, arg2);
324 ret = get_errno(faccessat(arg1, p, arg3, arg4)); /* XXX path(p)? */
325 UNLOCK_PATH(p, arg2);
327 return ret;
330 /* chdir(2) */
331 static abi_long do_bsd_chdir(abi_long arg1)
333 abi_long ret;
334 void *p;
336 LOCK_PATH(p, arg1);
337 ret = get_errno(chdir(p)); /* XXX path(p)? */
338 UNLOCK_PATH(p, arg1);
340 return ret;
343 /* fchdir(2) */
344 static abi_long do_bsd_fchdir(abi_long arg1)
346 return get_errno(fchdir(arg1));
349 /* rename(2) */
350 static abi_long do_bsd_rename(abi_long arg1, abi_long arg2)
352 abi_long ret;
353 void *p1, *p2;
355 LOCK_PATH2(p1, arg1, p2, arg2);
356 ret = get_errno(rename(p1, p2)); /* XXX path(p1), path(p2) */
357 UNLOCK_PATH2(p1, arg1, p2, arg2);
359 return ret;
362 /* renameat(2) */
363 static abi_long do_bsd_renameat(abi_long arg1, abi_long arg2,
364 abi_long arg3, abi_long arg4)
366 abi_long ret;
367 void *p1, *p2;
369 LOCK_PATH2(p1, arg2, p2, arg4);
370 ret = get_errno(renameat(arg1, p1, arg3, p2));
371 UNLOCK_PATH2(p1, arg2, p2, arg4);
373 return ret;
376 /* link(2) */
377 static abi_long do_bsd_link(abi_long arg1, abi_long arg2)
379 abi_long ret;
380 void *p1, *p2;
382 LOCK_PATH2(p1, arg1, p2, arg2);
383 ret = get_errno(link(p1, p2)); /* XXX path(p1), path(p2) */
384 UNLOCK_PATH2(p1, arg1, p2, arg2);
386 return ret;
389 /* linkat(2) */
390 static abi_long do_bsd_linkat(abi_long arg1, abi_long arg2,
391 abi_long arg3, abi_long arg4, abi_long arg5)
393 abi_long ret;
394 void *p1, *p2;
396 LOCK_PATH2(p1, arg2, p2, arg4);
397 ret = get_errno(linkat(arg1, p1, arg3, p2, arg5));
398 UNLOCK_PATH2(p1, arg2, p2, arg4);
400 return ret;
403 /* unlink(2) */
404 static abi_long do_bsd_unlink(abi_long arg1)
406 abi_long ret;
407 void *p;
409 LOCK_PATH(p, arg1);
410 ret = get_errno(unlink(p)); /* XXX path(p) */
411 UNLOCK_PATH(p, arg1);
413 return ret;
416 /* unlinkat(2) */
417 static abi_long do_bsd_unlinkat(abi_long arg1, abi_long arg2,
418 abi_long arg3)
420 abi_long ret;
421 void *p;
423 LOCK_PATH(p, arg2);
424 ret = get_errno(unlinkat(arg1, p, arg3)); /* XXX path(p) */
425 UNLOCK_PATH(p, arg2);
427 return ret;
430 /* mkdir(2) */
431 static abi_long do_bsd_mkdir(abi_long arg1, abi_long arg2)
433 abi_long ret;
434 void *p;
436 LOCK_PATH(p, arg1);
437 ret = get_errno(mkdir(p, arg2)); /* XXX path(p) */
438 UNLOCK_PATH(p, arg1);
440 return ret;
443 /* mkdirat(2) */
444 static abi_long do_bsd_mkdirat(abi_long arg1, abi_long arg2,
445 abi_long arg3)
447 abi_long ret;
448 void *p;
450 LOCK_PATH(p, arg2);
451 ret = get_errno(mkdirat(arg1, p, arg3));
452 UNLOCK_PATH(p, arg2);
454 return ret;
457 /* rmdir(2) */
458 static abi_long do_bsd_rmdir(abi_long arg1)
460 abi_long ret;
461 void *p;
463 LOCK_PATH(p, arg1);
464 ret = get_errno(rmdir(p)); /* XXX path(p)? */
465 UNLOCK_PATH(p, arg1);
467 return ret;
470 /* undocumented __getcwd(char *buf, size_t len) system call */
471 static abi_long do_bsd___getcwd(abi_long arg1, abi_long arg2)
473 abi_long ret;
474 void *p;
476 p = lock_user(VERIFY_WRITE, arg1, arg2, 0);
477 if (p == NULL) {
478 return -TARGET_EFAULT;
480 ret = safe_syscall(SYS___getcwd, p, arg2);
481 unlock_user(p, arg1, ret == 0 ? strlen(p) + 1 : 0);
483 return get_errno(ret);
486 /* dup(2) */
487 static abi_long do_bsd_dup(abi_long arg1)
489 return get_errno(dup(arg1));
492 /* dup2(2) */
493 static abi_long do_bsd_dup2(abi_long arg1, abi_long arg2)
495 return get_errno(dup2(arg1, arg2));
498 /* truncate(2) */
499 static abi_long do_bsd_truncate(void *cpu_env, abi_long arg1,
500 abi_long arg2, abi_long arg3, abi_long arg4)
502 abi_long ret;
503 void *p;
505 LOCK_PATH(p, arg1);
506 if (regpairs_aligned(cpu_env) != 0) {
507 arg2 = arg3;
508 arg3 = arg4;
510 ret = get_errno(truncate(p, target_arg64(arg2, arg3)));
511 UNLOCK_PATH(p, arg1);
513 return ret;
516 /* ftruncate(2) */
517 static abi_long do_bsd_ftruncate(void *cpu_env, abi_long arg1,
518 abi_long arg2, abi_long arg3, abi_long arg4)
520 if (regpairs_aligned(cpu_env) != 0) {
521 arg2 = arg3;
522 arg3 = arg4;
524 return get_errno(ftruncate(arg1, target_arg64(arg2, arg3)));
527 /* acct(2) */
528 static abi_long do_bsd_acct(abi_long arg1)
530 abi_long ret;
531 void *p;
533 if (arg1 == 0) {
534 ret = get_errno(acct(NULL));
535 } else {
536 LOCK_PATH(p, arg1);
537 ret = get_errno(acct(path(p)));
538 UNLOCK_PATH(p, arg1);
540 return ret;
543 /* sync(2) */
544 static abi_long do_bsd_sync(void)
546 sync();
547 return 0;
550 /* mount(2) */
551 static abi_long do_bsd_mount(abi_long arg1, abi_long arg2, abi_long arg3,
552 abi_long arg4)
554 abi_long ret;
555 void *p1, *p2;
557 LOCK_PATH2(p1, arg1, p2, arg2);
559 * XXX arg4 should be locked, but it isn't clear how to do that since it may
560 * be not be a NULL-terminated string.
562 if (arg4 == 0) {
563 ret = get_errno(mount(p1, p2, arg3, NULL)); /* XXX path(p2)? */
564 } else {
565 ret = get_errno(mount(p1, p2, arg3, g2h_untagged(arg4))); /* XXX path(p2)? */
567 UNLOCK_PATH2(p1, arg1, p2, arg2);
569 return ret;
572 /* unmount(2) */
573 static abi_long do_bsd_unmount(abi_long arg1, abi_long arg2)
575 abi_long ret;
576 void *p;
578 LOCK_PATH(p, arg1);
579 ret = get_errno(unmount(p, arg2)); /* XXX path(p)? */
580 UNLOCK_PATH(p, arg1);
582 return ret;
585 /* nmount(2) */
586 static abi_long do_bsd_nmount(abi_long arg1, abi_long count,
587 abi_long flags)
589 abi_long ret;
590 struct iovec *vec = lock_iovec(VERIFY_READ, arg1, count, 1);
592 if (vec != NULL) {
593 ret = get_errno(nmount(vec, count, flags));
594 unlock_iovec(vec, arg1, count, 0);
595 } else {
596 return -TARGET_EFAULT;
599 return ret;
602 /* symlink(2) */
603 static abi_long do_bsd_symlink(abi_long arg1, abi_long arg2)
605 abi_long ret;
606 void *p1, *p2;
608 LOCK_PATH2(p1, arg1, p2, arg2);
609 ret = get_errno(symlink(p1, p2)); /* XXX path(p1), path(p2) */
610 UNLOCK_PATH2(p1, arg1, p2, arg2);
612 return ret;
615 /* symlinkat(2) */
616 static abi_long do_bsd_symlinkat(abi_long arg1, abi_long arg2,
617 abi_long arg3)
619 abi_long ret;
620 void *p1, *p2;
622 LOCK_PATH2(p1, arg1, p2, arg3);
623 ret = get_errno(symlinkat(p1, arg2, p2)); /* XXX path(p1), path(p2) */
624 UNLOCK_PATH2(p1, arg1, p2, arg3);
626 return ret;
629 /* readlink(2) */
630 static abi_long do_bsd_readlink(CPUArchState *env, abi_long arg1,
631 abi_long arg2, abi_long arg3)
633 abi_long ret;
634 void *p1, *p2;
636 LOCK_PATH(p1, arg1);
637 p2 = lock_user(VERIFY_WRITE, arg2, arg3, 0);
638 if (p2 == NULL) {
639 UNLOCK_PATH(p1, arg1);
640 return -TARGET_EFAULT;
642 if (strcmp(p1, "/proc/curproc/file") == 0) {
643 CPUState *cpu = env_cpu(env);
644 TaskState *ts = (TaskState *)cpu->opaque;
645 strncpy(p2, ts->bprm->fullpath, arg3);
646 ret = MIN((abi_long)strlen(ts->bprm->fullpath), arg3);
647 } else {
648 ret = get_errno(readlink(path(p1), p2, arg3));
650 unlock_user(p2, arg2, ret);
651 UNLOCK_PATH(p1, arg1);
653 return ret;
656 /* readlinkat(2) */
657 static abi_long do_bsd_readlinkat(abi_long arg1, abi_long arg2,
658 abi_long arg3, abi_long arg4)
660 abi_long ret;
661 void *p1, *p2;
663 LOCK_PATH(p1, arg2);
664 p2 = lock_user(VERIFY_WRITE, arg3, arg4, 0);
665 if (p2 == NULL) {
666 UNLOCK_PATH(p1, arg2);
667 return -TARGET_EFAULT;
669 ret = get_errno(readlinkat(arg1, p1, p2, arg4));
670 unlock_user(p2, arg3, ret);
671 UNLOCK_PATH(p1, arg2);
673 return ret;
676 /* chmod(2) */
677 static abi_long do_bsd_chmod(abi_long arg1, abi_long arg2)
679 abi_long ret;
680 void *p;
682 LOCK_PATH(p, arg1);
683 ret = get_errno(chmod(p, arg2)); /* XXX path(p)? */
684 UNLOCK_PATH(p, arg1);
686 return ret;
689 /* fchmod(2) */
690 static abi_long do_bsd_fchmod(abi_long arg1, abi_long arg2)
692 return get_errno(fchmod(arg1, arg2));
695 /* lchmod(2) */
696 static abi_long do_bsd_lchmod(abi_long arg1, abi_long arg2)
698 abi_long ret;
699 void *p;
701 LOCK_PATH(p, arg1);
702 ret = get_errno(lchmod(p, arg2)); /* XXX path(p)? */
703 UNLOCK_PATH(p, arg1);
705 return ret;
708 /* fchmodat(2) */
709 static abi_long do_bsd_fchmodat(abi_long arg1, abi_long arg2,
710 abi_long arg3, abi_long arg4)
712 abi_long ret;
713 void *p;
715 LOCK_PATH(p, arg2);
716 ret = get_errno(fchmodat(arg1, p, arg3, arg4));
717 UNLOCK_PATH(p, arg2);
719 return ret;
722 /* pre-ino64 mknod(2) */
723 static abi_long do_bsd_freebsd11_mknod(abi_long arg1, abi_long arg2, abi_long arg3)
725 abi_long ret;
726 void *p;
728 LOCK_PATH(p, arg1);
729 ret = get_errno(syscall(SYS_freebsd11_mknod, p, arg2, arg3));
730 UNLOCK_PATH(p, arg1);
732 return ret;
735 /* pre-ino64 mknodat(2) */
736 static abi_long do_bsd_freebsd11_mknodat(abi_long arg1, abi_long arg2,
737 abi_long arg3, abi_long arg4)
739 abi_long ret;
740 void *p;
742 LOCK_PATH(p, arg2);
743 ret = get_errno(syscall(SYS_freebsd11_mknodat, arg1, p, arg3, arg4));
744 UNLOCK_PATH(p, arg2);
746 return ret;
749 /* post-ino64 mknodat(2) */
750 static abi_long do_bsd_mknodat(void *cpu_env, abi_long arg1,
751 abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5,
752 abi_long arg6)
754 abi_long ret;
755 void *p;
757 LOCK_PATH(p, arg2);
758 /* 32-bit arch's use two 32 registers for 64 bit return value */
759 if (regpairs_aligned(cpu_env) != 0) {
760 ret = get_errno(mknodat(arg1, p, arg3, target_arg64(arg5, arg6)));
761 } else {
762 ret = get_errno(mknodat(arg1, p, arg3, target_arg64(arg4, arg5)));
764 UNLOCK_PATH(p, arg2);
766 return ret;
769 /* chown(2) */
770 static abi_long do_bsd_chown(abi_long arg1, abi_long arg2, abi_long arg3)
772 abi_long ret;
773 void *p;
775 LOCK_PATH(p, arg1);
776 ret = get_errno(chown(p, arg2, arg3)); /* XXX path(p)? */
777 UNLOCK_PATH(p, arg1);
779 return ret;
782 /* fchown(2) */
783 static abi_long do_bsd_fchown(abi_long arg1, abi_long arg2,
784 abi_long arg3)
786 return get_errno(fchown(arg1, arg2, arg3));
789 /* lchown(2) */
790 static abi_long do_bsd_lchown(abi_long arg1, abi_long arg2,
791 abi_long arg3)
793 abi_long ret;
794 void *p;
796 LOCK_PATH(p, arg1);
797 ret = get_errno(lchown(p, arg2, arg3)); /* XXX path(p)? */
798 UNLOCK_PATH(p, arg1);
800 return ret;
803 /* fchownat(2) */
804 static abi_long do_bsd_fchownat(abi_long arg1, abi_long arg2,
805 abi_long arg3, abi_long arg4, abi_long arg5)
807 abi_long ret;
808 void *p;
810 LOCK_PATH(p, arg2);
811 ret = get_errno(fchownat(arg1, p, arg3, arg4, arg5)); /* XXX path(p)? */
812 UNLOCK_PATH(p, arg2);
814 return ret;
817 /* chflags(2) */
818 static abi_long do_bsd_chflags(abi_long arg1, abi_long arg2)
820 abi_long ret;
821 void *p;
823 LOCK_PATH(p, arg1);
824 ret = get_errno(chflags(p, arg2)); /* XXX path(p)? */
825 UNLOCK_PATH(p, arg1);
827 return ret;
830 /* lchflags(2) */
831 static abi_long do_bsd_lchflags(abi_long arg1, abi_long arg2)
833 abi_long ret;
834 void *p;
836 LOCK_PATH(p, arg1);
837 ret = get_errno(lchflags(p, arg2)); /* XXX path(p)? */
838 UNLOCK_PATH(p, arg1);
840 return ret;
843 /* fchflags(2) */
844 static abi_long do_bsd_fchflags(abi_long arg1, abi_long arg2)
846 return get_errno(fchflags(arg1, arg2));
849 /* chroot(2) */
850 static abi_long do_bsd_chroot(abi_long arg1)
852 abi_long ret;
853 void *p;
855 LOCK_PATH(p, arg1);
856 ret = get_errno(chroot(p)); /* XXX path(p)? */
857 UNLOCK_PATH(p, arg1);
859 return ret;
862 /* flock(2) */
863 static abi_long do_bsd_flock(abi_long arg1, abi_long arg2)
865 return get_errno(flock(arg1, arg2));
868 /* mkfifo(2) */
869 static abi_long do_bsd_mkfifo(abi_long arg1, abi_long arg2)
871 abi_long ret;
872 void *p;
874 LOCK_PATH(p, arg1);
875 ret = get_errno(mkfifo(p, arg2)); /* XXX path(p)? */
876 UNLOCK_PATH(p, arg1);
878 return ret;
881 /* mkfifoat(2) */
882 static abi_long do_bsd_mkfifoat(abi_long arg1, abi_long arg2,
883 abi_long arg3)
885 abi_long ret;
886 void *p;
888 LOCK_PATH(p, arg2);
889 ret = get_errno(mkfifoat(arg1, p, arg3));
890 UNLOCK_PATH(p, arg2);
892 return ret;
895 /* pathconf(2) */
896 static abi_long do_bsd_pathconf(abi_long arg1, abi_long arg2)
898 abi_long ret;
899 void *p;
901 LOCK_PATH(p, arg1);
902 ret = get_errno(pathconf(p, arg2)); /* XXX path(p)? */
903 UNLOCK_PATH(p, arg1);
905 return ret;
908 /* lpathconf(2) */
909 static abi_long do_bsd_lpathconf(abi_long arg1, abi_long arg2)
911 abi_long ret;
912 void *p;
914 LOCK_PATH(p, arg1);
915 ret = get_errno(lpathconf(p, arg2)); /* XXX path(p)? */
916 UNLOCK_PATH(p, arg1);
918 return ret;
921 /* fpathconf(2) */
922 static abi_long do_bsd_fpathconf(abi_long arg1, abi_long arg2)
924 return get_errno(fpathconf(arg1, arg2));
927 /* undelete(2) */
928 static abi_long do_bsd_undelete(abi_long arg1)
930 abi_long ret;
931 void *p;
933 LOCK_PATH(p, arg1);
934 ret = get_errno(undelete(p)); /* XXX path(p)? */
935 UNLOCK_PATH(p, arg1);
937 return ret;
940 #endif /* BSD_FILE_H */