bsd-user: Add host_to_target_msqid_ds for msgctl(2)
Add host_to_target_msqid_ds() to convert host struct msqid_ds to target format for msgctl(2) IPC_STAT operations. Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Brooks Davis <brooks@one-eyed-alien.net> Signed-off-by: Sean Bruno <sbruno@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>
Stacey Son committed
Feb 2, 2026 at 14:56 UTC
e2ad4ba061a43d200c5bb9e53baa1bbb334d3354
1 file changed
+27
bsd-user/bsd-misc.c
+27
@@ -163,3 +163,30 @@ abi_long target_to_host_msqid_ds(struct msqid_ds *host_md,
163
164
return 0;
165
}
166
+
167
+abi_long host_to_target_msqid_ds(abi_ulong target_addr,
168
+ struct msqid_ds *host_md)
169
+{
170
+ struct target_msqid_ds *target_md;
171
+
172
+ if (!lock_user_struct(VERIFY_WRITE, target_md, target_addr, 0)) {
173
+ return -TARGET_EFAULT;
174
+ }
175
+
176
+ memset(target_md, 0, sizeof(struct target_msqid_ds));
177
+ host_to_target_ipc_perm__locked(&target_md->msg_perm,
178
+ &host_md->msg_perm);
179
+
180
+ /* msg_first and msg_last are not used by IPC_SET/IPC_STAT in kernel. */
181
+ __put_user(target_md->msg_cbytes, &host_md->msg_cbytes);
182
+ __put_user(target_md->msg_qnum, &host_md->msg_qnum);
183
+ __put_user(target_md->msg_qbytes, &host_md->msg_qbytes);
184
+ __put_user(target_md->msg_lspid, &host_md->msg_lspid);
185
+ __put_user(target_md->msg_lrpid, &host_md->msg_lrpid);
186
+ __put_user(target_md->msg_stime, &host_md->msg_stime);
187
+ __put_user(target_md->msg_rtime, &host_md->msg_rtime);
188
+ __put_user(target_md->msg_ctime, &host_md->msg_ctime);
189
+ unlock_user_struct(target_md, target_addr, 1);
190
+
191
+ return 0;
192
+}