summaryrefslogtreecommitdiffstats
path: root/bsd-user/freebsd
diff options
context:
space:
mode:
authorWarner Losh2022-06-12 05:32:19 +0200
committerWarner Losh2022-06-13 23:48:09 +0200
commit77d3522b3fb6da9f39ada61fe7c2d0121c10de7f (patch)
treed49dd3f074e090dd5def2c6a765840e07de26c0e /bsd-user/freebsd
parentMerge tag 'mips-20220611' of https://github.com/philmd/qemu into staging (diff)
downloadqemu-77d3522b3fb6da9f39ada61fe7c2d0121c10de7f.tar.gz
qemu-77d3522b3fb6da9f39ada61fe7c2d0121c10de7f.tar.xz
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')
-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;