@samitouri / QOSamiQemu / commits / 1bbdc46d58

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>

Stacey Son committed Feb 2, 2026 at 16:46 UTC 1bbdc46d58fd9016aa01d1667014c8907becfdf4
1 file changed +47
bsd-user/bsd-misc.h
+47
@@ -213,6 +213,53 @@ out:
213 return ret;
214 }
215
216 +/* msgctl(2) */
217 +static inline abi_long do_bsd_msgctl(int msgid, int target_cmd, abi_long ptr)
218 +{
219 + struct msqid_ds dsarg;
220 + abi_long ret = -TARGET_EINVAL;
221 + int host_cmd;
222 +
223 + switch (target_cmd) {
224 + case TARGET_IPC_STAT:
225 + host_cmd = IPC_STAT;
226 + break;
227 +
228 + case TARGET_IPC_SET:
229 + host_cmd = IPC_SET;
230 + break;
231 +
232 + case TARGET_IPC_RMID:
233 + host_cmd = IPC_RMID;
234 + break;
235 +
236 + default:
237 + return -TARGET_EINVAL;
238 + }
239 +
240 + switch (host_cmd) {
241 + case IPC_STAT:
242 + case IPC_SET:
243 + if (target_to_host_msqid_ds(&dsarg, ptr)) {
244 + return -TARGET_EFAULT;
245 + }
246 + ret = get_errno(msgctl(msgid, host_cmd, &dsarg));
247 + if (host_to_target_msqid_ds(ptr, &dsarg)) {
248 + return -TARGET_EFAULT;
249 + }
250 + break;
251 +
252 + case IPC_RMID:
253 + ret = get_errno(msgctl(msgid, host_cmd, NULL));
254 + break;
255 +
256 + default:
257 + ret = -TARGET_EINVAL;
258 + break;
259 + }
260 + return ret;
261 +}
262 +
263 /* getdtablesize(2) */
264 static inline abi_long do_bsd_getdtablesize(void)
265 {