From: Stacey Son <sson@FreeBSD.org>
Add target_to_host_semid_ds() to convert target struct semid_ds to host
format for semctl(2) IPC_SET operations.
Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Mikael Urankar <mikael.urankar@gmail.com>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
bsd-user/bsd-misc.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/bsd-user/bsd-misc.c b/bsd-user/bsd-misc.c
index 677cb49d27..2a7c0520ca 100644
--- a/bsd-user/bsd-misc.c
+++ b/bsd-user/bsd-misc.c
@@ -112,3 +112,21 @@ abi_long host_to_target_semarray(int semid, abi_ulong target_addr,
unlock_user(array, target_addr, 1);
return 0;
}
+
+abi_long target_to_host_semid_ds(struct semid_ds *host_sd,
+ abi_ulong target_addr)
+{
+ struct target_semid_ds *target_sd;
+
+ if (!lock_user_struct(VERIFY_READ, target_sd, target_addr, 1)) {
+ return -TARGET_EFAULT;
+ }
+ target_to_host_ipc_perm__locked(&host_sd->sem_perm, &target_sd->sem_perm);
+ /* sem_base is not used by kernel for IPC_STAT/IPC_SET */
+ /* host_sd->sem_base = g2h_untagged(target_sd->sem_base); */
+ __get_user(host_sd->sem_nsems, &target_sd->sem_nsems);
+ __get_user(host_sd->sem_otime, &target_sd->sem_otime);
+ __get_user(host_sd->sem_ctime, &target_sd->sem_ctime);
+ unlock_user_struct(target_sd, target_addr, 0);
+ return 0;
+}
--
2.52.0