]>
Commit | Line | Data |
---|---|---|
28f540f4 | 1 | /* User-registered handlers for specific `ioctl' requests. |
04277e02 | 2 | Copyright (C) 1993-2019 Free Software Foundation, Inc. |
c84142e8 UD |
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 | |
41bdb6e2 AJ |
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. | |
c84142e8 UD |
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 | |
41bdb6e2 | 13 | Lesser General Public License for more details. |
c84142e8 | 14 | |
41bdb6e2 | 15 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 PE |
16 | License along with the GNU C Library; if not, see |
17 | <http://www.gnu.org/licenses/>. */ | |
28f540f4 RM |
18 | |
19 | #ifndef _HURD_IOCTL_H | |
20 | #define _HURD_IOCTL_H 1 | |
21 | ||
22 | #define __need___va_list | |
23 | #include <stdarg.h> | |
5107cf1d | 24 | #include <bits/ioctls.h> |
e30c291a | 25 | #include <mach/port.h> |
28f540f4 RM |
26 | |
27 | ||
28 | /* Type of handler function, called like ioctl to do its entire job. */ | |
29 | typedef int (*ioctl_handler_t) (int fd, int request, void *arg); | |
30 | ||
31 | /* Structure that records an ioctl handler. */ | |
32 | struct ioctl_handler | |
33 | { | |
9e3db9cd RM |
34 | /* Range of handled _IOC_NOTYPE (REQUEST) values. */ |
35 | int first_request, last_request; | |
28f540f4 RM |
36 | |
37 | /* Handler function, called like ioctl to do its entire job. */ | |
38 | ioctl_handler_t handler; | |
39 | ||
40 | struct ioctl_handler *next; /* Next handler. */ | |
41 | }; | |
42 | ||
43 | ||
44 | /* Register HANDLER to handle ioctls with REQUEST values between | |
45 | FIRST_REQUEST and LAST_REQUEST inclusive. Returns zero if successful. | |
46 | Return nonzero and sets `errno' for an error. */ | |
47 | ||
48 | extern int hurd_register_ioctl_handler (int first_request, int last_request, | |
49 | ioctl_handler_t handler); | |
50 | ||
51 | ||
52 | /* Define a library-internal handler for ioctl commands between FIRST and | |
53 | LAST inclusive. The last element gratuitously references HANDLER to | |
54 | avoid `defined but not used' warnings. */ | |
55 | ||
72f841d5 RM |
56 | #define _HURD_HANDLE_IOCTLS_1(handler, first, last, moniker) \ |
57 | static const struct ioctl_handler handler##_ioctl_handler##moniker \ | |
350635a5 | 58 | __attribute__ ((__unused__)) = \ |
9e3db9cd | 59 | { _IOC_NOTYPE (first), _IOC_NOTYPE (last), \ |
0ea5278d | 60 | (ioctl_handler_t) (handler), NULL }; \ |
72f841d5 | 61 | text_set_element (_hurd_ioctl_handler_lists, \ |
8a0746ae | 62 | handler##_ioctl_handler##moniker) |
72f841d5 RM |
63 | #define _HURD_HANDLE_IOCTLS(handler, first, last) \ |
64 | _HURD_HANDLE_IOCTLS_1 (handler, first, last, first##_to_##last) | |
28f540f4 RM |
65 | |
66 | /* Define a library-internal handler for a single ioctl command. */ | |
67 | ||
68 | #define _HURD_HANDLE_IOCTL(handler, ioctl) \ | |
72f841d5 | 69 | _HURD_HANDLE_IOCTLS_1 (handler, ioctl, ioctl, ioctl##_only) |
28f540f4 RM |
70 | |
71 | ||
868df0f9 ST |
72 | /* Install a new CTTYID port, atomically updating the dtable appropriately. |
73 | This consumes the send right passed in. */ | |
74 | ||
75 | void _hurd_locked_install_cttyid (mach_port_t cttyid); | |
76 | ||
28f540f4 RM |
77 | /* Lookup the handler for the given ioctl request. */ |
78 | ||
79 | ioctl_handler_t _hurd_lookup_ioctl_handler (int request); | |
80 | ||
81 | ||
82 | #endif /* hurd/ioctl.h */ |