From 2843a4e1d2fca851be6e47e7ff2413b45903ac9a Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 14 Nov 2003 02:54:03 +0000 Subject: [PATCH] 2003-09-06 Dmitry V. Levin * 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 . --- defs.h | 3 ++- io.c | 12 +++++++----- ioctl.c | 21 +++++++++++++++++++-- stream.c | 12 +++++++----- 4 files changed, 35 insertions(+), 13 deletions(-) diff --git a/defs.h b/defs.h index bec6bebe..7641e67d 100644 --- 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 65b48fdb..dd37638b 100644 --- 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 5d09328b..a49e7d6e 100644 --- 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 diff --git a/stream.c b/stream.c index 3dac2826..21deb181 100644 --- 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, ");