From ba4b26e6268d2217fad2437ecb0ec6c2e265e306 Mon Sep 17 00:00:00 2001 From: Stacey Son Date: Sat, 14 Mar 2026 11:28:24 -0600 Subject: [PATCH] bsd-user: Add log_unsupported_ioctl function Add helper function to log detailed information about unsupported ioctl commands, including direction, group, and parameter length. Signed-off-by: Stacey Son Reviewed-by: Pierrick Bouvier Signed-off-by: Warner Losh --- bsd-user/bsd-ioctl.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/bsd-user/bsd-ioctl.c b/bsd-user/bsd-ioctl.c index 94110d4ad5..2d84adce71 100644 --- a/bsd-user/bsd-ioctl.c +++ b/bsd-user/bsd-ioctl.c @@ -217,3 +217,27 @@ static IOCTLEntry ioctl_entries[] = { #include "os-ioctl-cmds.h" { 0, 0 }, }; + +static void log_unsupported_ioctl(unsigned long cmd) +{ + gemu_log("cmd=0x%08lx dir=", cmd); + switch (cmd & IOC_DIRMASK) { + case IOC_VOID: + gemu_log("VOID "); + break; + case IOC_OUT: + gemu_log("OUT "); + break; + case IOC_IN: + gemu_log("IN "); + break; + case IOC_INOUT: + gemu_log("INOUT"); + break; + default: + gemu_log("%01lx ???", (cmd & IOC_DIRMASK) >> 29); + break; + } + gemu_log(" '%c' %3d %lu\n", (char)IOCGROUP(cmd), (int)(cmd & 0xff), + IOCPARM_LEN(cmd)); +}