diff mbox

[4/9,v3] FreeBSD-user: Implement print_ioctl() syscall

Message ID 1402062579-28716-5-git-send-email-sbruno@freebsd.org
State New
Headers show

Commit Message

Sean Bruno June 6, 2014, 1:49 p.m. UTC
Signed-off-by: Sean Bruno <sbruno@freebsd.org>
---
 bsd-user/freebsd/strace.list |  2 +-
 bsd-user/strace.c            | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)

Comments

Peter Maydell June 7, 2014, 10:01 p.m. UTC | #1
On 6 June 2014 14:49, Sean Bruno <sbruno@freebsd.org> wrote:
> Signed-off-by: Sean Bruno <sbruno@freebsd.org>

Here again the commit message is wrong: we're not implementing
a syscall, only adding strace support for an existing one; please
adjust it.

Otherwise
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM
diff mbox

Patch

diff --git a/bsd-user/freebsd/strace.list b/bsd-user/freebsd/strace.list
index 3235f16..718357b 100644
--- a/bsd-user/freebsd/strace.list
+++ b/bsd-user/freebsd/strace.list
@@ -80,7 +80,7 @@ 
 { TARGET_FREEBSD_NR_getsockopt, "getsockopt", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_gettimeofday, "gettimeofday", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_getuid, "getuid", "%s()", NULL, NULL },
-{ TARGET_FREEBSD_NR_ioctl, "ioctl", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_ioctl, "ioctl", NULL, print_ioctl, NULL },
 { TARGET_FREEBSD_NR_issetugid, "issetugid", "%s()", NULL, NULL },
 { TARGET_FREEBSD_NR_kevent, "kevent", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_kill, "kill", NULL, NULL, NULL },
diff --git a/bsd-user/strace.c b/bsd-user/strace.c
index b2633d0..e33dd4d 100644
--- a/bsd-user/strace.c
+++ b/bsd-user/strace.c
@@ -89,6 +89,25 @@  static void print_execve(const struct syscallname *name, abi_long arg1,
     gemu_log("NULL})");
 }
 
+static void print_ioctl(const struct syscallname *name,
+        abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4,
+        abi_long arg5, abi_long arg6)
+{
+    /* Decode the ioctl request */
+    gemu_log("%s(%d, 0x%0lx { IO%s%s GRP:0x%x('%c') CMD:%d LEN:%d }, 0x"
+            TARGET_ABI_FMT_lx ", ...)",
+            name->name,
+            (int)arg1,
+            (unsigned long)arg2,
+            arg2 & IOC_OUT ? "R" : "",
+            arg2 & IOC_IN ? "W" : "",
+            (unsigned)IOCGROUP(arg2),
+            isprint(IOCGROUP(arg2)) ? (char)IOCGROUP(arg2) : '?',
+            (int)arg2 & 0xFF,
+            (int)IOCPARM_LEN(arg2),
+            arg3);
+}
+
 /*
  * Variants for the return value output function
  */