bsd-user: Add target_to_host_semid_ds for semctl(2)
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> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Warner Losh <imp@bsdimp.com>
This commit is contained in:
@@ -98,3 +98,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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user