summaryrefslogtreecommitdiffstats
path: root/bsd-user/freebsd/os-syscall.c
diff options
context:
space:
mode:
authorRichard Henderson2022-06-19 22:56:13 +0200
committerRichard Henderson2022-06-19 22:56:13 +0200
commitc8b2d413761af732a0798d8df45ce968732083fe (patch)
treee675d44da99699577693f11d24b10b69a508ed67 /bsd-user/freebsd/os-syscall.c
parentMerge tag 'for_upstream' of git://git.kernel.org/pub/scm/virt/kvm/mst/qemu in... (diff)
parentbsd-user: Implement acct and sync (diff)
downloadqemu-c8b2d413761af732a0798d8df45ce968732083fe.tar.gz
qemu-c8b2d413761af732a0798d8df45ce968732083fe.tar.xz
qemu-c8b2d413761af732a0798d8df45ce968732083fe.zip
Merge tag 'bsd-user-syscall-2022q2-pull-request' of ssh://github.com/qemu-bsd-user/qemu-bsd-user into staging
bsd-user: Next round of syscalls Implement the next round of system calls. These are open, openat, close, fdatasync, fsync, close_from, revoke, access, eacccess, facccessat, chdir, fchdir, rename, renameat, mkdir, mkdirat, rmdir, _getcwd, dup, dup2, truncate, ftruncate, acct and sync. In addition, the helper functions needed for these to work are included. With the helper functions, all of these system calls are the 'obvious' wrapper... # -----BEGIN PGP SIGNATURE----- # Comment: GPGTools - https://gpgtools.org # # iQIzBAABCgAdFiEEIDX4lLAKo898zeG3bBzRKH2wEQAFAmKvZSwACgkQbBzRKH2w # EQCrdxAA0UeXmh/l1znPSrX4lif7Vhe4H5TdmHavGQX0p7B+dMd160SMLfKFJt7J # HHXuQZbPFNuwqE5qiFPTcXIFjT5tq2WSjd9ZC/ZexfzBJIICwcUWuWvG2WfCA3fD # hth/Ru2fX0vUwoUwvYw7lTPnhb9o52Z1rf5AEFu85E3UjKWEcARHCakm7n8a+Cg+ # PkF1qZ/qFic+bkBZkZLWyHB5qR2p2sIp+VHwlG1ew39Xim457kynQOoF8etIXc1Y # g5PrjePUsVhPR7qm4CFplM4UOyGOOqIykHERppaXKtk2+kP8dp9HWog9Z/IFVOKc # z3huDtf03UtmohjdJBYkpCcCzmd2EETRPgkFaVT5ciVGMb3Nom1b2/DOnndpS9qb # TdE7J6Ek1vp4Mr386QHzm6AfdoHGZc4tH+SpDQZrsWbnugklYnQd3++GCqj8D2rA # LJ8oWInviZP8xWDn5q1sXCNw/lgVup9ZNrMl7TcXmQDZXHSW1tElIAT2PZCebman # rSwg/umr7fPOXdIAkLhF77bAt3J3kAzxhuYwHEstB3kRXEJ2VinLMf3BJBrGLnuK # kr6kJy6hw7luIT5nUNLrrNtwsAAwEu6S7OSGhEiGaUSIhiER96k/tX2u/KOBtwGC # VzIP7vK5V2xYPepyj4tXkVRHkjxxw3s8fYRXf73IsaZ6Avot8pg= # =JmJY # -----END PGP SIGNATURE----- # gpg: Signature made Sun 19 Jun 2022 11:04:28 AM PDT # gpg: using RSA key 2035F894B00AA3CF7CCDE1B76C1CD1287DB01100 # gpg: Good signature from "Warner Losh <wlosh@netflix.com>" [unknown] # gpg: aka "Warner Losh <imp@bsdimp.com>" [unknown] # gpg: aka "Warner Losh <imp@freebsd.org>" [unknown] # gpg: aka "Warner Losh <imp@village.org>" [unknown] # gpg: aka "Warner Losh <wlosh@bsdimp.com>" [unknown] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 2035 F894 B00A A3CF 7CCD E1B7 6C1C D128 7DB0 1100 * tag 'bsd-user-syscall-2022q2-pull-request' of ssh://github.com/qemu-bsd-user/qemu-bsd-user: bsd-user: Implement acct and sync bsd-user: Implement trunctate and ftruncate bsd-user: Implement dup and dup2 bsd-user: Implement rmdir and undocumented __getcwd bsd-user: Implement mkdir and mkdirat bsd-user: Implement link, linkat, unlink and unlinkat bsd-user: Implement rename and renameat bsd-user: Implement chdir and fchdir bsd-user: Implement revoke, access, eaccess and faccessat bsd-user: Implement fdatasync, fsync and close_from bsd-user: Implement open, openat and close Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'bsd-user/freebsd/os-syscall.c')
-rw-r--r--bsd-user/freebsd/os-syscall.c116
1 files changed, 116 insertions, 0 deletions
diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c
index 71aa0d38e0..2623caf800 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,118 @@ 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;
+
+ case TARGET_FREEBSD_NR_fdatasync: /* fdatasync(2) */
+ ret = do_bsd_fdatasync(arg1);
+ break;
+
+ case TARGET_FREEBSD_NR_fsync: /* fsync(2) */
+ ret = do_bsd_fsync(arg1);
+ break;
+
+ case TARGET_FREEBSD_NR_freebsd12_closefrom: /* closefrom(2) */
+ ret = do_bsd_closefrom(arg1);
+ break;
+
+ case TARGET_FREEBSD_NR_revoke: /* revoke(2) */
+ ret = do_bsd_revoke(arg1);
+ break;
+
+ case TARGET_FREEBSD_NR_access: /* access(2) */
+ ret = do_bsd_access(arg1, arg2);
+ break;
+
+ case TARGET_FREEBSD_NR_eaccess: /* eaccess(2) */
+ ret = do_bsd_eaccess(arg1, arg2);
+ break;
+
+ case TARGET_FREEBSD_NR_faccessat: /* faccessat(2) */
+ ret = do_bsd_faccessat(arg1, arg2, arg3, arg4);
+ break;
+
+ case TARGET_FREEBSD_NR_chdir: /* chdir(2) */
+ ret = do_bsd_chdir(arg1);
+ break;
+
+ case TARGET_FREEBSD_NR_fchdir: /* fchdir(2) */
+ ret = do_bsd_fchdir(arg1);
+ break;
+
+ case TARGET_FREEBSD_NR_rename: /* rename(2) */
+ ret = do_bsd_rename(arg1, arg2);
+ break;
+
+ case TARGET_FREEBSD_NR_renameat: /* renameat(2) */
+ ret = do_bsd_renameat(arg1, arg2, arg3, arg4);
+ break;
+
+ case TARGET_FREEBSD_NR_link: /* link(2) */
+ ret = do_bsd_link(arg1, arg2);
+ break;
+
+ case TARGET_FREEBSD_NR_linkat: /* linkat(2) */
+ ret = do_bsd_linkat(arg1, arg2, arg3, arg4, arg5);
+ break;
+
+ case TARGET_FREEBSD_NR_unlink: /* unlink(2) */
+ ret = do_bsd_unlink(arg1);
+ break;
+
+ case TARGET_FREEBSD_NR_unlinkat: /* unlinkat(2) */
+ ret = do_bsd_unlinkat(arg1, arg2, arg3);
+ break;
+
+ case TARGET_FREEBSD_NR_mkdir: /* mkdir(2) */
+ ret = do_bsd_mkdir(arg1, arg2);
+ break;
+
+ case TARGET_FREEBSD_NR_mkdirat: /* mkdirat(2) */
+ ret = do_bsd_mkdirat(arg1, arg2, arg3);
+ break;
+
+ case TARGET_FREEBSD_NR_rmdir: /* rmdir(2) (XXX no rmdirat()?) */
+ ret = do_bsd_rmdir(arg1);
+ break;
+
+ case TARGET_FREEBSD_NR___getcwd: /* undocumented __getcwd() */
+ ret = do_bsd___getcwd(arg1, arg2);
+ break;
+
+ case TARGET_FREEBSD_NR_dup: /* dup(2) */
+ ret = do_bsd_dup(arg1);
+ break;
+
+ case TARGET_FREEBSD_NR_dup2: /* dup2(2) */
+ ret = do_bsd_dup2(arg1, arg2);
+ break;
+
+ case TARGET_FREEBSD_NR_truncate: /* truncate(2) */
+ ret = do_bsd_truncate(cpu_env, arg1, arg2, arg3, arg4);
+ break;
+
+ case TARGET_FREEBSD_NR_ftruncate: /* ftruncate(2) */
+ ret = do_bsd_ftruncate(cpu_env, arg1, arg2, arg3, arg4);
+ break;
+
+ case TARGET_FREEBSD_NR_acct: /* acct(2) */
+ ret = do_bsd_acct(arg1);
+ break;
+
+ case TARGET_FREEBSD_NR_sync: /* sync(2) */
+ ret = do_bsd_sync();
+ break;
+
default:
qemu_log_mask(LOG_UNIMP, "Unsupported syscall: %d\n", num);
ret = -TARGET_ENOSYS;