X-Git-Url: https://granicus.if.org/sourcecode?a=blobdiff_plain;f=ioctl.c;h=814caf0c1eb0d28b23c97355177e1bbf17ffae1c;hb=ee36ce19e03e08f4b692570090ee58b72d2f0f50;hp=24e84ba868b38009ca421205af42ce9bb3f68932;hpb=9ce1a63eb20b069607c06f9645ac5a17b418a5f3;p=strace diff --git a/ioctl.c b/ioctl.c index 24e84ba8..814caf0c 100644 --- a/ioctl.c +++ b/ioctl.c @@ -2,6 +2,7 @@ * Copyright (c) 1991, 1992 Paul Kranenburg * Copyright (c) 1993 Branko Lankester * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey + * Copyright (c) 1996-2001 Wichert Akkerman * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,7 +32,7 @@ #include "defs.h" -struct ioctlent ioctlent0[] = { +const struct ioctlent ioctlent0[] = { /* * `ioctlent.h' may be generated from `ioctlent.raw' by the auxiliary * program `ioctlsort', such that the list is sorted by the `code' field. @@ -42,25 +43,29 @@ struct ioctlent ioctlent0[] = { #include "ioctlent.h" }; -int nioctlents0 = sizeof ioctlent0 / sizeof ioctlent0[0]; +#ifdef LINUX +#include +#endif + +const int nioctlents0 = sizeof ioctlent0 / sizeof ioctlent0[0]; #if SUPPORTED_PERSONALITIES >= 2 -struct ioctlent ioctlent1[] = { +const struct ioctlent ioctlent1[] = { #include "ioctlent1.h" }; -int nioctlents1 = sizeof ioctlent1 / sizeof ioctlent1[0]; +const int nioctlents1 = sizeof ioctlent1 / sizeof ioctlent1[0]; #endif /* SUPPORTED_PERSONALITIES >= 2 */ #if SUPPORTED_PERSONALITIES >= 3 -struct ioctlent ioctlent2[] = { +const struct ioctlent ioctlent2[] = { #include "ioctlent2.h" }; -int nioctlents1 = sizeof ioctlent2 / sizeof ioctlent2[0]; +int nioctlents2 = sizeof ioctlent2 / sizeof ioctlent2[0]; #endif /* SUPPORTED_PERSONALITIES >= 3 */ -struct ioctlent *ioctlent; +const struct ioctlent *ioctlent; int nioctlents; static int @@ -73,16 +78,36 @@ const void *b; return (code1 > code2) ? 1 : (code1 < code2) ? -1 : 0; } -char * +const struct ioctlent * ioctl_lookup(code) long code; { struct ioctlent *iop, ioent; ioent.code = code; +#ifdef LINUX + ioent.code &= (_IOC_NRMASK<<_IOC_NRSHIFT) | (_IOC_TYPEMASK<<_IOC_TYPESHIFT); +#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; +} + +const struct ioctlent * +ioctl_next_match(iop) +const struct ioctlent *iop; +{ + long code; + + code = (iop++)->code; + if (iop < ioctlent + nioctlents && iop->code == code) + return iop; + return NULL; } int @@ -92,7 +117,7 @@ long code, arg; { switch ((code >> 8) & 0xff) { #ifdef LINUX -#ifdef ALPHA +#if defined(ALPHA) || defined(POWERPC) case 'f': case 't': case 'T': #else /* !ALPHA */ case 0x54: @@ -104,15 +129,22 @@ long code, arg; #ifdef LINUX case 0x89: #else /* !LINUX */ - case 'r': case 's': case 'i': case 'p': + case 'r': case 's': case 'i': +#ifndef FREEBSD + case 'p': +#endif #endif /* !LINUX */ return sock_ioctl(tcp, code, arg); -#ifdef SVR4 -#ifndef SVR4_MP +#ifdef USE_PROCFS +#ifndef HAVE_MP_PROCFS +#ifndef FREEBSD case 'q': +#else + case 'p': +#endif return proc_ioctl(tcp, code, arg); #endif -#endif /* SVR4 */ +#endif /* USE_PROCFS */ #ifdef HAVE_SYS_STREAM_H case 'S': return stream_ioctl(tcp, code, arg); @@ -170,4 +202,3 @@ long code, arg; * * End of Registry */ -