bsd-user: Add do_bsd_semop implementation
Add implementation of semop(2) syscall to perform System V semaphore operations. Converts target sembuf array to host format and executes 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:
@@ -77,6 +77,28 @@ static inline abi_long do_bsd_semget(abi_long key, int nsems,
|
||||
target_to_host_bitmask(target_flags, ipc_flags_tbl)));
|
||||
}
|
||||
|
||||
/* semop(2) */
|
||||
static inline abi_long do_bsd_semop(int semid, abi_long ptr, unsigned nsops)
|
||||
{
|
||||
g_autofree struct sembuf *sops = g_malloc(nsops * sizeof(struct sembuf));
|
||||
struct target_sembuf *target_sembuf;
|
||||
int i;
|
||||
|
||||
target_sembuf = lock_user(VERIFY_READ, ptr,
|
||||
nsops * sizeof(struct target_sembuf), 1);
|
||||
if (target_sembuf == NULL) {
|
||||
return -TARGET_EFAULT;
|
||||
}
|
||||
for (i = 0; i < nsops; i++) {
|
||||
__get_user(sops[i].sem_num, &target_sembuf[i].sem_num);
|
||||
__get_user(sops[i].sem_op, &target_sembuf[i].sem_op);
|
||||
__get_user(sops[i].sem_flg, &target_sembuf[i].sem_flg);
|
||||
}
|
||||
unlock_user(target_sembuf, ptr, 0);
|
||||
|
||||
return semop(semid, sops, nsops);
|
||||
}
|
||||
|
||||
/* getdtablesize(2) */
|
||||
static inline abi_long do_bsd_getdtablesize(void)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user