From: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com>
---
bsd-user/bsd-mem.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/bsd-user/bsd-mem.c b/bsd-user/bsd-mem.c
index 6c123abf04..e69250cc0d 100644
--- a/bsd-user/bsd-mem.c
+++ b/bsd-user/bsd-mem.c
@@ -36,3 +36,44 @@ void target_set_brk(abi_ulong new_brk)
bsd_target_original_brk = bsd_target_brk = HOST_PAGE_ALIGN(new_brk);
brk_page = HOST_PAGE_ALIGN(bsd_target_brk);
}
+
+abi_long target_to_host_ipc_perm(struct ipc_perm *host_ip,
+ abi_ulong target_addr)
+{
+ struct target_ipc_perm *target_ip;
+
+ if (!lock_user_struct(VERIFY_READ, target_ip, target_addr, 1)) {
+ return -TARGET_EFAULT;
+ }
+ __get_user(host_ip->cuid, &target_ip->cuid);
+ __get_user(host_ip->cgid, &target_ip->cgid);
+ __get_user(host_ip->uid, &target_ip->uid);
+ __get_user(host_ip->gid, &target_ip->gid);
+ __get_user(host_ip->mode, &target_ip->mode);
+ __get_user(host_ip->seq, &target_ip->seq);
+ __get_user(host_ip->key, &target_ip->key);
+ unlock_user_struct(target_ip, target_addr, 0);
+
+ return 0;
+}
+
+abi_long host_to_target_ipc_perm(abi_ulong target_addr,
+ struct ipc_perm *host_ip)
+{
+ struct target_ipc_perm *target_ip;
+
+ if (!lock_user_struct(VERIFY_WRITE, target_ip, target_addr, 0)) {
+ return -TARGET_EFAULT;
+ }
+ __put_user(host_ip->cuid, &target_ip->cuid);
+ __put_user(host_ip->cgid, &target_ip->cgid);
+ __put_user(host_ip->uid, &target_ip->uid);
+ __put_user(host_ip->gid, &target_ip->gid);
+ __put_user(host_ip->mode, &target_ip->mode);
+ __put_user(host_ip->seq, &target_ip->seq);
+ __put_user(host_ip->key, &target_ip->key);
+ unlock_user_struct(target_ip, target_addr, 1);
+
+ return 0;
+}
+
--
2.40.0