[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 13/32] Implement h2t_freebsd_fhandle t2h_freebsd_fhandle funct
From: |
Karim Taha |
Subject: |
[PATCH v2 13/32] Implement h2t_freebsd_fhandle t2h_freebsd_fhandle functions |
Date: |
Sun, 13 Aug 2023 05:09:54 +0200 |
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>
---
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 8c73f7402c..6716cee3e2 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.40.0
- [PATCH v2 04/32] Declarations of h2t and t2h conversion functions., (continued)
- [PATCH v2 04/32] Declarations of h2t and t2h conversion functions., Karim Taha, 2023/08/13
- [PATCH v2 05/32] Add struct target_freebsd11_stat to bsd-user/syscall_defs, Karim Taha, 2023/08/13
- [PATCH v2 06/32] Add struct target_stat to bsd-user/syscall_defs.h, Karim Taha, 2023/08/13
- [PATCH v2 07/32] Add structs target_freebsd11_nstat and target_freebsd11_statfs to bsd-user/syscall_defs.h, Karim Taha, 2023/08/13
- [PATCH v2 08/32] Add struct target_statfs to bsd-user/syscall_defs.h, Karim Taha, 2023/08/13
- [PATCH v2 10/32] Define safe_fcntl macro in bsd-user/syscall_defs.h, Karim Taha, 2023/08/13
- [PATCH v2 11/32] Rename target_freebsd_time_t to target_time_t, Karim Taha, 2023/08/13
- [PATCH v2 09/32] Add struct target_freebsd_fhandle and fcntl flags to bsd-user/syscall_defs.h, Karim Taha, 2023/08/13
- [PATCH v2 13/32] Implement h2t_freebsd_fhandle t2h_freebsd_fhandle functions,
Karim Taha <=
- [PATCH v2 15/32] Implement target_to_host_fcntl_cmd, Karim Taha, 2023/08/13
- [PATCH v2 17/32] Implement stat related syscalls, Karim Taha, 2023/08/13
- [PATCH v2 21/32] Implement stat related syscalls, Karim Taha, 2023/08/13
- [PATCH v2 12/32] Implement h2t_freebsd11_stat h2t_freebsd_nstat, Karim Taha, 2023/08/13
- [PATCH v2 14/32] Implement h2t_freebds11_statfs, Karim Taha, 2023/08/13
- [PATCH v2 16/32] Implement h2t_freebsd_stat and h2t_freebsd_statfs functions, Karim Taha, 2023/08/13
- [PATCH v2 18/32] Implement stat related syscalls, Karim Taha, 2023/08/13
- [PATCH v2 26/32] Implement freebsd11 stat related syscalls, Karim Taha, 2023/08/13
- [PATCH v2 30/32] Add glue to call the following syscalls to the freebsd_syscall function:, Karim Taha, 2023/08/13
- [PATCH v2 31/32] Add glue to call the following syscalls to the freebsd_syscall function:, Karim Taha, 2023/08/13