]> granicus.if.org Git - strace/commitdiff
ioctl: print unrecognized ioctl codes in _IOC(dir,type,nr,size) format
authorDmitry V. Levin <ldv@altlinux.org>
Tue, 20 Jan 2015 00:24:36 +0000 (00:24 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 21 Jan 2015 00:48:52 +0000 (00:48 +0000)
* defs.h (ioctl_print_code): New prototype.
* ioctl.c: Include xlat/ioctl_dirs.h.
(ioctl_print_code): New function.
* io.c (sys_ioctl): Use it.
* xlat/ioctl_dirs.in: New file.

defs.h
io.c
ioctl.c
xlat/ioctl_dirs.in [new file with mode: 0644]

diff --git a/defs.h b/defs.h
index a91031b49b52df9e082f799de9d9b7f76c5a1ea1..33cdef0330a8acbcf9c11611085d6e689134e507 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -733,6 +733,7 @@ extern void print_loff_t(struct tcb *, long);
 
 extern const struct_ioctlent *ioctl_lookup(const unsigned int);
 extern const struct_ioctlent *ioctl_next_match(const struct_ioctlent *);
+extern void ioctl_print_code(const unsigned int);
 extern int ioctl_decode(struct tcb *, const unsigned int, long);
 extern int block_ioctl(struct tcb *, const unsigned int, long);
 extern int loop_ioctl(struct tcb *, const unsigned int, long);
diff --git a/io.c b/io.c
index 87bdbba8c842cf2c0a266612dfcb71011d69ccd4..2a36c000d001b5075d73ed9eadeea3ceb088dea2 100644 (file)
--- a/io.c
+++ b/io.c
@@ -404,7 +404,7 @@ sys_ioctl(struct tcb *tcp)
                        while ((iop = ioctl_next_match(iop)))
                                tprintf(" or %s", iop->symbol);
                } else
-                       tprintf("%#lx", tcp->u_arg[1]);
+                       ioctl_print_code(tcp->u_arg[1]);
                ioctl_decode(tcp, tcp->u_arg[1], tcp->u_arg[2]);
        }
        else {
diff --git a/ioctl.c b/ioctl.c
index 3d867f7f86e420f3c2a1b86346855e4483bcb3b3..f9d570e8357172075d9e5556bf99a064a6fa7689 100644 (file)
--- a/ioctl.c
+++ b/ioctl.c
@@ -30,6 +30,7 @@
 
 #include "defs.h"
 #include <asm/ioctl.h>
+#include "xlat/ioctl_dirs.h"
 
 static int
 compare(const void *a, const void *b)
@@ -67,6 +68,15 @@ ioctl_next_match(const struct_ioctlent *iop)
        return NULL;
 }
 
+void
+ioctl_print_code(const unsigned int code)
+{
+       tprints("_IOC(");
+       printflags(ioctl_dirs, _IOC_DIR(code), "_IOC_???");
+       tprintf(", 0x%02x, 0x%02x, 0x%02x)",
+               _IOC_TYPE(code), _IOC_NR(code), _IOC_SIZE(code));
+}
+
 int
 ioctl_decode(struct tcb *tcp, unsigned int code, long arg)
 {
diff --git a/xlat/ioctl_dirs.in b/xlat/ioctl_dirs.in
new file mode 100644 (file)
index 0000000..4c97a86
--- /dev/null
@@ -0,0 +1,3 @@
+_IOC_READ
+_IOC_WRITE
+_IOC_NONE