summaryrefslogtreecommitdiff
path: root/ioctl.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>2003-11-14 02:54:03 +0000
committerRoland McGrath <roland@redhat.com>2003-11-14 02:54:03 +0000
commit2843a4e1d2fca851be6e47e7ff2413b45903ac9a (patch)
tree74275d627444a6c5ba9b04b7c52338bfbfc02623 /ioctl.c
parentf25ef3916f41f9a6187c66c2053f0a1591b39812 (diff)
downloadstrace-2843a4e1d2fca851be6e47e7ff2413b45903ac9a.tar.gz
strace-2843a4e1d2fca851be6e47e7ff2413b45903ac9a.tar.bz2
strace-2843a4e1d2fca851be6e47e7ff2413b45903ac9a.tar.xz
2003-09-06 Dmitry V. Levin <ldv@altlinux.org>
* 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>.
Diffstat (limited to 'ioctl.c')
-rw-r--r--ioctl.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/ioctl.c b/ioctl.c
index 5d09328..a49e7d6 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