]> granicus.if.org Git - strace/commitdiff
2003-09-06 Dmitry V. Levin <ldv@altlinux.org>
authorRoland McGrath <roland@redhat.com>
Fri, 14 Nov 2003 02:54:03 +0000 (02:54 +0000)
committerRoland McGrath <roland@redhat.com>
Fri, 14 Nov 2003 02:54:03 +0000 (02:54 +0000)
* defs.h (ioctl_lookup): Prototype change.
* ioctl.c (ioctl_next_match): New function.
* defs.h: Declare it.
* io.c (sys_ioctl): Use it, to display all possible ioctl names
when there's more than one match.
* ioctl.c (ioctl_lookup): Likewise.
* stream.c (internal_stream_ioctl): Likewise.
Patch from Solar Designer <solar@openwall.com>.

defs.h
io.c
ioctl.c
stream.c

diff --git a/defs.h b/defs.h
index bec6bebe864a74683454c669c1bfc6e52e721bee..7641e67d5c343a652964418db0c3c3139c0ec6ae 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -464,7 +464,8 @@ extern int internal_exec P((struct tcb *));
 extern int internal_wait P((struct tcb *));
 extern int internal_exit P((struct tcb *));
 
-extern char *ioctl_lookup P((long));
+extern struct ioctlent *ioctl_lookup P((long));
+extern struct ioctlent *ioctl_next_match P((struct ioctlent *));
 extern int ioctl_decode P((struct tcb *, long, long));
 extern int term_ioctl P((struct tcb *, long, long));
 extern int sock_ioctl P((struct tcb *, long, long));
diff --git a/io.c b/io.c
index 65b48fdb96541e24d4c03b03ee1d3a604eea01f1..dd37638be8c1443fa1a496994f8a0952798df662 100644 (file)
--- a/io.c
+++ b/io.c
@@ -353,14 +353,16 @@ int
 sys_ioctl(tcp)
 struct tcb *tcp;
 {
-       char *symbol;
+       struct ioctlent *iop;
 
        if (entering(tcp)) {
                tprintf("%ld, ", tcp->u_arg[0]);
-               symbol = ioctl_lookup(tcp->u_arg[1]);
-               if (symbol)
-                       tprintf("%s", symbol);
-               else
+               iop = ioctl_lookup(tcp->u_arg[1]);
+               if (iop) {
+                       tprintf("%s", iop->symbol);
+                       while ((iop = ioctl_next_match(iop)))
+                               tprintf(" or %s", iop->symbol);
+               } else
                        tprintf("%#lx", tcp->u_arg[1]);
                ioctl_decode(tcp, tcp->u_arg[1], tcp->u_arg[2]);
        }
diff --git a/ioctl.c b/ioctl.c
index 5d09328b8342fd55f979ca14266da068cc8ce58e..a49e7d6e6ec137d5b07208bd8138985adfc86afc 100644 (file)
--- a/ioctl.c
+++ b/ioctl.c
@@ -78,7 +78,7 @@ const void *b;
        return (code1 > code2) ? 1 : (code1 < code2) ? -1 : 0;
 }
 
-char *
+struct ioctlent *
 ioctl_lookup(code)
 long code;
 {
@@ -90,7 +90,24 @@ long code;
 #endif
        iop = (struct ioctlent *) bsearch((char *) &ioent, (char *) ioctlent,
                        nioctlents, sizeof(struct ioctlent), compare);
-       return iop ? iop->symbol : NULL;
+       while (iop > ioctlent)
+               if ((--iop)->code != ioent.code) {
+                       iop++;
+                       break;
+               }
+       return iop;
+}
+
+struct ioctlent *
+ioctl_next_match(iop)
+struct ioctlent *iop;
+{
+       long code;
+
+       code = (iop++)->code;
+       if (iop < ioctlent + nioctlents && iop->code == code)
+               return iop;
+       return NULL;
 }
 
 int
index 3dac2826a1e83693bc8f31ad1309ba326869adaa..21deb1816001c17e05a46c58a2ae5bb5d7112f65 100644 (file)
--- a/stream.c
+++ b/stream.c
@@ -932,7 +932,7 @@ struct tcb *tcp;
 int arg;
 {
        struct strioctl si;
-       char *name;
+       strict ioctlent *iop;
        int in_and_out;
        int timod = 0;
 #ifdef SI_GETUDATA
@@ -947,10 +947,12 @@ int arg;
                return 1;
        }
        if (entering(tcp)) {
-               name = ioctl_lookup(si.ic_cmd);
-               if (name)
-                       tprintf(", {ic_cmd=%s", name);
-               else
+               iop = ioctl_lookup(si.ic_cmd);
+               if (iop) {
+                       tprintf(", {ic_cmd=%s", iop->symbol);
+                       while ((iop = ioctl_next_match(iop)))
+                               tprintf(" or %s", iop->symbol);
+               } else
                        tprintf(", {ic_cmd=%#x", si.ic_cmd);
                if (si.ic_timout == INFTIM)
                        tprintf(", ic_timout=INFTIM, ");