[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 16/36] bsd-user: Implement h2t_freebsd_fhandle t2h_freebsd_fhandle
From: |
Warner Losh |
Subject: |
[PULL 16/36] bsd-user: Implement h2t_freebsd_fhandle t2h_freebsd_fhandle |
Date: |
Mon, 28 Aug 2023 17:38:01 -0600 |
From: Stacey Son <sson@FreeBSD.org>
Implement the stat conversion functions:
h2t_freebsd_fhandle
t2h_freebsd_fhandle
Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
bsd-user/freebsd/os-stat.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/bsd-user/freebsd/os-stat.c b/bsd-user/freebsd/os-stat.c
index 8c73f7402c2..6716cee3e22 100644
--- a/bsd-user/freebsd/os-stat.c
+++ b/bsd-user/freebsd/os-stat.c
@@ -92,3 +92,40 @@ abi_long h2t_freebsd11_nstat(abi_ulong target_addr,
return 0;
}
+/*
+ * file handle conversion
+ */
+abi_long t2h_freebsd_fhandle(fhandle_t *host_fh, abi_ulong target_addr)
+{
+ target_freebsd_fhandle_t *target_fh;
+
+ if (!lock_user_struct(VERIFY_READ, target_fh, target_addr, 1)) {
+ return -TARGET_EFAULT;
+ }
+ __get_user(host_fh->fh_fsid.val[0], &target_fh->fh_fsid.val[0]);
+ __get_user(host_fh->fh_fsid.val[1], &target_fh->fh_fsid.val[0]);
+ __get_user(host_fh->fh_fid.fid_len, &target_fh->fh_fid.fid_len);
+ /* u_short fid_data0; */
+ memcpy(host_fh->fh_fid.fid_data, target_fh->fh_fid.fid_data,
+ TARGET_MAXFIDSZ);
+ unlock_user_struct(target_fh, target_addr, 0);
+ return 0;
+}
+
+abi_long h2t_freebsd_fhandle(abi_ulong target_addr, fhandle_t *host_fh)
+{
+ target_freebsd_fhandle_t *target_fh;
+
+ if (!lock_user_struct(VERIFY_WRITE, target_fh, target_addr, 0)) {
+ return -TARGET_EFAULT;
+ }
+ __put_user(host_fh->fh_fsid.val[0], &target_fh->fh_fsid.val[0]);
+ __put_user(host_fh->fh_fsid.val[1], &target_fh->fh_fsid.val[0]);
+ __put_user(host_fh->fh_fid.fid_len, &target_fh->fh_fid.fid_len);
+ /* u_short fid_data0; */
+ memcpy(target_fh->fh_fid.fid_data, host_fh->fh_fid.fid_data,
+ TARGET_MAXFIDSZ);
+ unlock_user_struct(target_fh, target_addr, 1);
+ return 0;
+}
+
--
2.41.0
- [PULL 02/36] bsd-user: Remove image_info.mmap, (continued)
- [PULL 02/36] bsd-user: Remove image_info.mmap, Warner Losh, 2023/08/28
- [PULL 03/36] bsd-user: Remove image_info.start_brk, Warner Losh, 2023/08/28
- [PULL 11/36] bsd-user: Add struct target_statfs, Warner Losh, 2023/08/28
- [PULL 10/36] bsd-user: Add structs target_freebsd11_{nstat,statfs}, Warner Losh, 2023/08/28
- [PULL 12/36] bsd-user: Add struct target_freebsd_fhandle and fcntl flags, Warner Losh, 2023/08/28
- [PULL 14/36] bsd-user: Rename target_freebsd_time_t to target_time_t, Warner Losh, 2023/08/28
- [PULL 07/36] bsd-user: Declarations of h2t and t2h conversion functions., Warner Losh, 2023/08/28
- [PULL 05/36] bsd-user: Disable clang warnings, Warner Losh, 2023/08/28
- [PULL 04/36] bsd-user: Move _WANT_FREEBSD macros to include/qemu/osdep.h, Warner Losh, 2023/08/28
- [PULL 13/36] bsd-user: Define safe_fcntl macro in bsd-user/syscall_defs.h, Warner Losh, 2023/08/28
- [PULL 16/36] bsd-user: Implement h2t_freebsd_fhandle t2h_freebsd_fhandle,
Warner Losh <=
- [PULL 18/36] bsd-user: Implement target_to_host_fcntl_cmd, Warner Losh, 2023/08/28
- [PULL 06/36] bsd-user; Update the definitions of __put_user and __get_user macros, Warner Losh, 2023/08/28
- [PULL 08/36] bsd-user: Add struct target_freebsd11_stat to bsd-user/syscall_defs, Warner Losh, 2023/08/28
- [PULL 09/36] bsd-user: Add struct target_stat to bsd-user/syscall_defs.h, Warner Losh, 2023/08/28
- [PULL 17/36] bsd-user: Implement h2t_freebds11_statfs, Warner Losh, 2023/08/28
- [PULL 20/36] bsd-user: Implement stat related syscalls, Warner Losh, 2023/08/28
- [PULL 22/36] bsd-user: Implement statfs related syscalls, Warner Losh, 2023/08/28
- [PULL 24/36] bsd-user: Implement stat related syscalls, Warner Losh, 2023/08/28
- [PULL 15/36] bsd-user: Implement h2t_freebsd11_stat h2t_freebsd_nstat, Warner Losh, 2023/08/28
- [PULL 19/36] bsd-uesr: Implement h2t_freebsd_stat and h2t_freebsd_statfs functions, Warner Losh, 2023/08/28