]> git.ipfire.org Git - thirdparty/glibc.git/blob - hurd/hurd/ioctl.h
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / hurd / hurd / ioctl.h
1 /* User-registered handlers for specific `ioctl' requests.
2 Copyright (C) 1993-2016 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19 #ifndef _HURD_IOCTL_H
20 #define _HURD_IOCTL_H 1
21
22 #define __need___va_list
23 #include <stdarg.h>
24 #include <bits/ioctls.h>
25
26
27 /* Type of handler function, called like ioctl to do its entire job. */
28 typedef int (*ioctl_handler_t) (int fd, int request, void *arg);
29
30 /* Structure that records an ioctl handler. */
31 struct ioctl_handler
32 {
33 /* Range of handled _IOC_NOTYPE (REQUEST) values. */
34 int first_request, last_request;
35
36 /* Handler function, called like ioctl to do its entire job. */
37 ioctl_handler_t handler;
38
39 struct ioctl_handler *next; /* Next handler. */
40 };
41
42
43 /* Register HANDLER to handle ioctls with REQUEST values between
44 FIRST_REQUEST and LAST_REQUEST inclusive. Returns zero if successful.
45 Return nonzero and sets `errno' for an error. */
46
47 extern int hurd_register_ioctl_handler (int first_request, int last_request,
48 ioctl_handler_t handler);
49
50
51 /* Define a library-internal handler for ioctl commands between FIRST and
52 LAST inclusive. The last element gratuitously references HANDLER to
53 avoid `defined but not used' warnings. */
54
55 #define _HURD_HANDLE_IOCTLS_1(handler, first, last, moniker) \
56 static const struct ioctl_handler handler##_ioctl_handler##moniker \
57 __attribute__ ((__unused__)) = \
58 { _IOC_NOTYPE (first), _IOC_NOTYPE (last), \
59 (ioctl_handler_t) (handler), NULL }; \
60 text_set_element (_hurd_ioctl_handler_lists, \
61 handler##_ioctl_handler##moniker)
62 #define _HURD_HANDLE_IOCTLS(handler, first, last) \
63 _HURD_HANDLE_IOCTLS_1 (handler, first, last, first##_to_##last)
64
65 /* Define a library-internal handler for a single ioctl command. */
66
67 #define _HURD_HANDLE_IOCTL(handler, ioctl) \
68 _HURD_HANDLE_IOCTLS_1 (handler, ioctl, ioctl, ioctl##_only)
69
70
71 /* Install a new CTTYID port, atomically updating the dtable appropriately.
72 This consumes the send right passed in. */
73
74 void _hurd_locked_install_cttyid (mach_port_t cttyid);
75
76 /* Lookup the handler for the given ioctl request. */
77
78 ioctl_handler_t _hurd_lookup_ioctl_handler (int request);
79
80
81 #endif /* hurd/ioctl.h */