Browse Source

bsd-user: Add do_bsd_msgctl implementation

Add implementation of msgctl(2) syscall for System V message queue control
operations. Handles command translation and structure conversions for
IPC_STAT/IPC_SET/IPC_RMID 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>
master
Stacey Son 6 months ago
committed by Warner Losh
parent
commit
1bbdc46d58
  1. 47
      bsd-user/bsd-misc.h

47
bsd-user/bsd-misc.h

@ -213,6 +213,53 @@ out:
return ret;
}
/* msgctl(2) */
static inline abi_long do_bsd_msgctl(int msgid, int target_cmd, abi_long ptr)
{
struct msqid_ds dsarg;
abi_long ret = -TARGET_EINVAL;
int host_cmd;
switch (target_cmd) {
case TARGET_IPC_STAT:
host_cmd = IPC_STAT;
break;
case TARGET_IPC_SET:
host_cmd = IPC_SET;
break;
case TARGET_IPC_RMID:
host_cmd = IPC_RMID;
break;
default:
return -TARGET_EINVAL;
}
switch (host_cmd) {
case IPC_STAT:
case IPC_SET:
if (target_to_host_msqid_ds(&dsarg, ptr)) {
return -TARGET_EFAULT;
}
ret = get_errno(msgctl(msgid, host_cmd, &dsarg));
if (host_to_target_msqid_ds(ptr, &dsarg)) {
return -TARGET_EFAULT;
}
break;
case IPC_RMID:
ret = get_errno(msgctl(msgid, host_cmd, NULL));
break;
default:
ret = -TARGET_EINVAL;
break;
}
return ret;
}
/* getdtablesize(2) */
static inline abi_long do_bsd_getdtablesize(void)
{

Loading…
Cancel
Save