about summary refs log tree commit diff
path: root/hurd
diff options
context:
space:
mode:
Diffstat (limited to 'hurd')
-rw-r--r--hurd/hurd/ioctl.h9
-rw-r--r--hurd/hurdioctl.c12
2 files changed, 14 insertions, 7 deletions
diff --git a/hurd/hurd/ioctl.h b/hurd/hurd/ioctl.h
index 518ef51b33..431b3be425 100644
--- a/hurd/hurd/ioctl.h
+++ b/hurd/hurd/ioctl.h
@@ -1,5 +1,5 @@
 /* User-registered handlers for specific `ioctl' requests.
-Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
+Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
 This file is part of the GNU C Library.
 
 The GNU C Library is free software; you can redistribute it and/or
@@ -22,6 +22,7 @@ Cambridge, MA 02139, USA.  */
 
 #define	__need___va_list
 #include <stdarg.h>
+#include <ioctls.h>
 
 
 /* Type of handler function, called like ioctl to do its entire job.  */
@@ -30,7 +31,8 @@ typedef int (*ioctl_handler_t) (int fd, int request, void *arg);
 /* Structure that records an ioctl handler.  */
 struct ioctl_handler
   {
-    int first_request, last_request; /* Range of handled request values.  */
+    /* Range of handled _IOC_NOTYPE (REQUEST) values.  */
+    int first_request, last_request;
 
     /* Handler function, called like ioctl to do its entire job.  */
     ioctl_handler_t handler;
@@ -54,7 +56,8 @@ extern int hurd_register_ioctl_handler (int first_request, int last_request,
 #define	_HURD_HANDLE_IOCTLS(handler, first, last)			      \
   static const struct ioctl_handler handler##_ioctl_handler		      \
   	__attribute__ ((__unused__)) =					      \
-    { (first), (last), (int (*) (int, int, void *)) (handler), NULL };	      \
+    { _IOC_NOTYPE (first), _IOC_NOTYPE (last),				      \
+	(int (*) (int, int, void *)) (handler), NULL };	      		      \
   text_set_element (_hurd_ioctl_handler_lists, ##handler##_ioctl_handler)
 
 /* Define a library-internal handler for a single ioctl command.  */
diff --git a/hurd/hurdioctl.c b/hurd/hurdioctl.c
index 30cce1c1d3..bd91389ad7 100644
--- a/hurd/hurdioctl.c
+++ b/hurd/hurdioctl.c
@@ -36,6 +36,10 @@ _hurd_lookup_ioctl_handler (int request)
   void *const *ptr;
   const struct ioctl_handler *h;
 
+  /* Mask off the type bits, so that we see requests in a single group as a
+     contiguous block of values.  */
+  request = _IOC_NOTYPE (request);
+
   for (ptr = symbol_set_first_element (_hurd_ioctl_handler_lists);
        !symbol_set_end_p (_hurd_ioctl_handler_lists, ptr);
        ++ptr)
@@ -62,7 +66,7 @@ fioctl (int fd,
   switch (request)
     {
     default:
-      err = EGRATUITOUS;
+      err = ENOTTY;
       break;
 
     case FIONREAD:
@@ -97,7 +101,7 @@ fioctl (int fd,
       break;
     }
 
-  return err ? __hurd_fail (err) : 0;
+  return err ? __hurd_dfail (fd, err) : 0;
 }
 
 _HURD_HANDLE_IOCTLS (fioctl, FIOGETOWN, FIONREAD);
@@ -112,7 +116,7 @@ fioclex (int fd,
   switch (request)
     {
     default:
-      return __hurd_fail (EGRATUITOUS);
+      return __hurd_fail (ENOTTY);
     case FIOCLEX:
       flag = FD_CLOEXEC;
       break;
@@ -123,7 +127,7 @@ fioclex (int fd,
 
   return __fcntl (fd, F_SETFD, flag);
 }
-_HURD_HANDLE_IOCTLS (fioclex, FIOCLEX, FIONCLEX);
+_HURD_HANDLE_IOCTL (fioclex, FIOCLEX, FIONCLEX);
 
 #include <hurd/term.h>
 #include <hurd/tioctl.h>