* Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
* Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
* Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
+ * Copyright (c) 1996-2001 Wichert Akkerman <wichert@cistron.nl>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
#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.
#include "ioctlent.h"
};
-int nioctlents0 = sizeof ioctlent0 / sizeof ioctlent0[0];
+#ifdef LINUX
+#include <asm/ioctl.h>
+#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
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
{
switch ((code >> 8) & 0xff) {
#ifdef LINUX
-#ifdef ALPHA
+#if defined(ALPHA) || defined(POWERPC)
case 'f': case 't': case 'T':
#else /* !ALPHA */
case 0x54:
#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);
*
* End of Registry
*/
-