]> granicus.if.org Git - strace/commitdiff
Move ioctl syscall parser to ioctl.c
authorDmitry V. Levin <ldv@altlinux.org>
Thu, 2 Jul 2015 21:37:23 +0000 (21:37 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 2 Jul 2015 21:42:51 +0000 (21:42 +0000)
* io.c (sys_ioctl): Move ...
* ioctl.c: ... here.
(ioctl_lookup, ioctl_next_match, ioctl_print_code, ioctl_decode,
ioctl_decode_command_number): Declare as static.
* defs.h (ioctl_lookup, ioctl_next_match, ioctl_print_code,
ioctl_decode, ioctl_decode_command_number): Remove.

defs.h
io.c
ioctl.c

diff --git a/defs.h b/defs.h
index 7e0b94874dc9fa03615cbeec2726391d082c998c..6fcb5186a025fa9d9bcf94898235d19e711745fd 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -562,11 +562,6 @@ extern const char *sprint_open_modes(int);
 extern void print_loff_t(struct tcb *, long);
 extern void print_seccomp_filter(struct tcb *tcp, unsigned 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 ioctl_decode_command_number(const unsigned int);
 extern int block_ioctl(struct tcb *, const unsigned int, long);
 extern int evdev_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 30ed5781a71cc56bd1ddafe5de039ae86a117203..eec496ad70d97e70e2fc0fb59751d0819cc7c4fa 100644 (file)
--- a/io.c
+++ b/io.c
@@ -383,32 +383,3 @@ SYS_FUNC(vmsplice)
        }
        return 0;
 }
-
-SYS_FUNC(ioctl)
-{
-       const struct_ioctlent *iop;
-
-       if (entering(tcp)) {
-               printfd(tcp, tcp->u_arg[0]);
-               tprints(", ");
-               if (!ioctl_decode_command_number(tcp->u_arg[1])) {
-                       iop = ioctl_lookup(tcp->u_arg[1]);
-                       if (iop) {
-                               tprints(iop->symbol);
-                               while ((iop = ioctl_next_match(iop)))
-                                       tprintf(" or %s", iop->symbol);
-                       } else {
-                               ioctl_print_code(tcp->u_arg[1]);
-                       }
-               }
-               ioctl_decode(tcp, tcp->u_arg[1], tcp->u_arg[2]);
-       }
-       else {
-               int ret = ioctl_decode(tcp, tcp->u_arg[1], tcp->u_arg[2]);
-               if (!ret)
-                       tprintf(", %#lx", tcp->u_arg[2]);
-               else
-                       return ret - 1;
-       }
-       return 0;
-}
diff --git a/ioctl.c b/ioctl.c
index 6efce65f43d5912aecdaa324b3b619bf15e9bf53..fef4c9adec3dd816715c9ab1fe2f65eb88bfeb1c 100644 (file)
--- a/ioctl.c
+++ b/ioctl.c
@@ -47,7 +47,7 @@ compare(const void *a, const void *b)
        return (code1 > code2) ? 1 : (code1 < code2) ? -1 : 0;
 }
 
-const struct_ioctlent *
+static const struct_ioctlent *
 ioctl_lookup(const unsigned int code)
 {
        struct_ioctlent *iop;
@@ -64,7 +64,7 @@ ioctl_lookup(const unsigned int code)
        return iop;
 }
 
-const struct_ioctlent *
+static const struct_ioctlent *
 ioctl_next_match(const struct_ioctlent *iop)
 {
        const unsigned int code = iop->code;
@@ -74,7 +74,7 @@ ioctl_next_match(const struct_ioctlent *iop)
        return NULL;
 }
 
-void
+static void
 ioctl_print_code(const unsigned int code)
 {
        tprints("_IOC(");
@@ -181,7 +181,7 @@ hiddev_decode_number(unsigned int arg)
        return 0;
 }
 
-int
+static int
 ioctl_decode_command_number(unsigned int arg)
 {
        switch (_IOC_TYPE(arg)) {
@@ -221,7 +221,7 @@ ioctl_decode_command_number(unsigned int arg)
        }
 }
 
-int
+static int
 ioctl_decode(struct tcb *tcp, unsigned int code, long arg)
 {
        switch (_IOC_TYPE(code)) {
@@ -263,3 +263,32 @@ ioctl_decode(struct tcb *tcp, unsigned int code, long arg)
        }
        return 0;
 }
+
+SYS_FUNC(ioctl)
+{
+       const struct_ioctlent *iop;
+
+       if (entering(tcp)) {
+               printfd(tcp, tcp->u_arg[0]);
+               tprints(", ");
+               if (!ioctl_decode_command_number(tcp->u_arg[1])) {
+                       iop = ioctl_lookup(tcp->u_arg[1]);
+                       if (iop) {
+                               tprints(iop->symbol);
+                               while ((iop = ioctl_next_match(iop)))
+                                       tprintf(" or %s", iop->symbol);
+                       } else {
+                               ioctl_print_code(tcp->u_arg[1]);
+                       }
+               }
+               ioctl_decode(tcp, tcp->u_arg[1], tcp->u_arg[2]);
+       }
+       else {
+               int ret = ioctl_decode(tcp, tcp->u_arg[1], tcp->u_arg[2]);
+               if (!ret)
+                       tprintf(", %#lx", tcp->u_arg[2]);
+               else
+                       return ret - 1;
+       }
+       return 0;
+}