Back to index

glibc  2.9
ioctl.h
Go to the documentation of this file.
00001 /* User-registered handlers for specific `ioctl' requests.
00002    Copyright (C) 1993,94,95,96,97,2000,01 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #ifndef       _HURD_IOCTL_H
00021 #define       _HURD_IOCTL_H 1
00022 
00023 #define       __need___va_list
00024 #include <stdarg.h>
00025 #include <bits/ioctls.h>
00026 
00027 
00028 /* Type of handler function, called like ioctl to do its entire job.  */
00029 typedef int (*ioctl_handler_t) (int fd, int request, void *arg);
00030 
00031 /* Structure that records an ioctl handler.  */
00032 struct ioctl_handler
00033   {
00034     /* Range of handled _IOC_NOTYPE (REQUEST) values.  */
00035     int first_request, last_request;
00036 
00037     /* Handler function, called like ioctl to do its entire job.  */
00038     ioctl_handler_t handler;
00039 
00040     struct ioctl_handler *next;    /* Next handler.  */
00041   };
00042 
00043 
00044 /* Register HANDLER to handle ioctls with REQUEST values between
00045    FIRST_REQUEST and LAST_REQUEST inclusive.  Returns zero if successful.
00046    Return nonzero and sets `errno' for an error.  */
00047 
00048 extern int hurd_register_ioctl_handler (int first_request, int last_request,
00049                                    ioctl_handler_t handler);
00050 
00051 
00052 /* Define a library-internal handler for ioctl commands between FIRST and
00053    LAST inclusive.  The last element gratuitously references HANDLER to
00054    avoid `defined but not used' warnings.  */
00055 
00056 #define       _HURD_HANDLE_IOCTLS_1(handler, first, last, moniker)                 \
00057   static const struct ioctl_handler handler##_ioctl_handler##moniker        \
00058        __attribute__ ((__unused__)) =                                       \
00059     { _IOC_NOTYPE (first), _IOC_NOTYPE (last),                              \
00060        (int (*) (int, int, void *)) (handler), NULL };                      \
00061   text_set_element (_hurd_ioctl_handler_lists,                              \
00062                     handler##_ioctl_handler##moniker)
00063 #define       _HURD_HANDLE_IOCTLS(handler, first, last)                     \
00064   _HURD_HANDLE_IOCTLS_1 (handler, first, last, first##_to_##last)
00065 
00066 /* Define a library-internal handler for a single ioctl command.  */
00067 
00068 #define _HURD_HANDLE_IOCTL(handler, ioctl) \
00069   _HURD_HANDLE_IOCTLS_1 (handler, ioctl, ioctl, ioctl##_only)
00070 
00071 
00072 /* Lookup the handler for the given ioctl request.  */
00073 
00074 ioctl_handler_t _hurd_lookup_ioctl_handler (int request);
00075 
00076 
00077 #endif /* hurd/ioctl.h */