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>.
This commit is contained in:
parent
f25ef3916f
commit
2843a4e1d2
3
defs.h
3
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));
|
||||
|
12
io.c
12
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]);
|
||||
}
|
||||
|
21
ioctl.c
21
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
|
||||
|
12
stream.c
12
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, ");
|
||||
|
Loading…
Reference in New Issue
Block a user