summary refs log tree commit diff stats
path: root/bsd-user/freebsd/os-syscall.c
diff options
context:
space:
mode:
authorWarner Losh <imp@bsdimp.com>2022-06-11 21:32:19 -0600
committerWarner Losh <imp@bsdimp.com>2022-06-13 15:48:09 -0600
commit77d3522b3fb6da9f39ada61fe7c2d0121c10de7f (patch)
treed49dd3f074e090dd5def2c6a765840e07de26c0e /bsd-user/freebsd/os-syscall.c
parentdcb40541ebca7ec98a14d461593b3cd7282b4fac (diff)
downloadfocaccia-qemu-77d3522b3fb6da9f39ada61fe7c2d0121c10de7f.tar.gz
focaccia-qemu-77d3522b3fb6da9f39ada61fe7c2d0121c10de7f.zip
bsd-user: Implement open, openat and close
Add the open, openat and close system calls. We need to lock paths, so
implmenent that as well.

Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Jung-uk Kim <jkim@FreeBSD.org>
Signed-off-by: Kyle Evans <kevans@FreeBSD.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'bsd-user/freebsd/os-syscall.c')
-rw-r--r--bsd-user/freebsd/os-syscall.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c
index 71aa0d38e0..a824785fee 100644
--- a/bsd-user/freebsd/os-syscall.c
+++ b/bsd-user/freebsd/os-syscall.c
@@ -44,6 +44,10 @@
 #include "bsd-proc.h"
 
 /* I/O */
+safe_syscall3(int, open, const char *, path, int, flags, mode_t, mode);
+safe_syscall4(int, openat, int, fd, const char *, path, int, flags, mode_t,
+    mode);
+
 safe_syscall3(ssize_t, read, int, fd, void *, buf, size_t, nbytes);
 safe_syscall4(ssize_t, pread, int, fd, void *, buf, size_t, nbytes, off_t,
     offset);
@@ -257,6 +261,18 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1,
         ret = do_bsd_pwritev(cpu_env, arg1, arg2, arg3, arg4, arg5, arg6);
         break;
 
+    case TARGET_FREEBSD_NR_open: /* open(2) */
+        ret = do_bsd_open(arg1, arg2, arg3);
+        break;
+
+    case TARGET_FREEBSD_NR_openat: /* openat(2) */
+        ret = do_bsd_openat(arg1, arg2, arg3, arg4);
+        break;
+
+    case TARGET_FREEBSD_NR_close: /* close(2) */
+        ret = do_bsd_close(arg1);
+        break;
+
     default:
         qemu_log_mask(LOG_UNIMP, "Unsupported syscall: %d\n", num);
         ret = -TARGET_ENOSYS;