bsd-user: Add host_to_target_semid_ds for semctl(2)
Add host_to_target_semid_ds() to convert host struct semid_ds to target format for semctl(2) IPC_STAT operations. Signed-off-by: Stacey Son <sson@FreeBSD.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Warner Losh <imp@bsdimp.com>
This commit is contained in:
@@ -116,3 +116,23 @@ abi_long target_to_host_semid_ds(struct semid_ds *host_sd,
|
||||
unlock_user_struct(target_sd, target_addr, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
abi_long host_to_target_semid_ds(abi_ulong target_addr,
|
||||
struct semid_ds *host_sd)
|
||||
{
|
||||
struct target_semid_ds *target_sd;
|
||||
|
||||
if (!lock_user_struct(VERIFY_WRITE, target_sd, target_addr, 0)) {
|
||||
return -TARGET_EFAULT;
|
||||
}
|
||||
host_to_target_ipc_perm__locked(&target_sd->sem_perm,
|
||||
&host_sd->sem_perm);
|
||||
/* sem_base is not used by kernel for IPC_STAT/IPC_SET */
|
||||
/* target_sd->sem_base = h2g((void *)host_sd->sem_base); */
|
||||
__put_user(target_sd->sem_nsems, &host_sd->sem_nsems);
|
||||
__put_user(target_sd->sem_otime, &host_sd->sem_otime);
|
||||
__put_user(target_sd->sem_ctime, &host_sd->sem_ctime);
|
||||
unlock_user_struct(target_sd, target_addr, 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user