* 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>.
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));
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]);
}
return (code1 > code2) ? 1 : (code1 < code2) ? -1 : 0;
}
-char *
+struct ioctlent *
ioctl_lookup(code)
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
int arg;
{
struct strioctl si;
- char *name;
+ strict ioctlent *iop;
int in_and_out;
int timod = 0;
#ifdef SI_GETUDATA
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, ");