From 77d3522b3fb6da9f39ada61fe7c2d0121c10de7f Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Sat, 11 Jun 2022 21:32:19 -0600 Subject: 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 Signed-off-by: Jung-uk Kim Signed-off-by: Kyle Evans Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/freebsd/os-syscall.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'bsd-user/freebsd') 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; -- cgit v1.2.3-55-g7522