From 7cbe2f914c9bc492a5e60573b5402f6b84a00a71 Mon Sep 17 00:00:00 2001 From: Stacey Son Date: Mon, 2 Feb 2026 14:46:17 -0700 Subject: [PATCH] bsd-user: Add host_to_target_uuid for uuidgen(2) Add host_to_target_uuid() to convert host struct uuid to target ABI for the uuidgen(2) syscall. Signed-off-by: Stacey Son Reviewed-by: Richard Henderson Signed-off-by: Warner Losh --- bsd-user/bsd-misc.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 bsd-user/bsd-misc.c diff --git a/bsd-user/bsd-misc.c b/bsd-user/bsd-misc.c new file mode 100644 index 0000000000..68b67f37ba --- /dev/null +++ b/bsd-user/bsd-misc.c @@ -0,0 +1,35 @@ +/* + * BSD misc system call conversions routines + * + * Copyright (c) 2013 Stacey D. Son + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#include "qemu/osdep.h" + +#include + +#include "qemu.h" +#include "qemu-bsd.h" + +/* + * BSD uuidgen(2) struct uuid conversion + */ +abi_long host_to_target_uuid(abi_ulong target_addr, struct uuid *host_uuid) +{ + struct target_uuid *target_uuid; + + if (!lock_user_struct(VERIFY_WRITE, target_uuid, target_addr, 0)) { + return -TARGET_EFAULT; + } + __put_user(host_uuid->time_low, &target_uuid->time_low); + __put_user(host_uuid->time_mid, &target_uuid->time_mid); + __put_user(host_uuid->time_hi_and_version, + &target_uuid->time_hi_and_version); + host_uuid->clock_seq_hi_and_reserved = + target_uuid->clock_seq_hi_and_reserved; + host_uuid->clock_seq_low = target_uuid->clock_seq_low; + memcpy(host_uuid->node, target_uuid->node, TARGET_UUID_NODE_LEN); + unlock_user_struct(target_uuid, target_addr, 1); + return 0; +}