1IOCTL(2) Linux Programmer's Manual IOCTL(2)
2
3
4
6 ioctl - control device
7
9 #include <sys/ioctl.h>
10
11 int ioctl(int d, int request, ...);
12
14 The ioctl() function manipulates the underlying device parameters of
15 special files. In particular, many operating characteristics of char‐
16 acter special files (e.g., terminals) may be controlled with ioctl()
17 requests. The argument d must be an open file descriptor.
18
19 The second argument is a device-dependent request code. The third
20 argument is an untyped pointer to memory. It's traditionally char
21 *argp (from the days before void * was valid C), and will be so named
22 for this discussion.
23
24 An ioctl() request has encoded in it whether the argument is an in
25 parameter or out parameter, and the size of the argument argp in bytes.
26 Macros and defines used in specifying an ioctl() request are located in
27 the file <sys/ioctl.h>.
28
30 Usually, on success zero is returned. A few ioctl() requests use the
31 return value as an output parameter and return a non-negative value on
32 success. On error, -1 is returned, and errno is set appropriately.
33
35 EBADF d is not a valid descriptor.
36
37 EFAULT argp references an inaccessible memory area.
38
39 EINVAL Request or argp is not valid.
40
41 ENOTTY d is not associated with a character special device.
42
43 ENOTTY The specified request does not apply to the kind of object that
44 the descriptor d references.
45
47 No single standard. Arguments, returns, and semantics of ioctl() vary
48 according to the device driver in question (the call is used as a
49 catch-all for operations that don't cleanly fit the Unix stream I/O
50 model). See ioctl_list(2) for a list of many of the known ioctl()
51 calls. The ioctl() function call appeared in Version 7 AT&T Unix.
52
54 In order to use this call, one needs an open file descriptor. Often
55 the open(2) call has unwanted side effects, that can be avoided under
56 Linux by giving it the O_NONBLOCK flag.
57
59 execve(2), fcntl(2), ioctl_list(2), open(2), sd(4), tty(4)
60
62 This page is part of release 3.22 of the Linux man-pages project. A
63 description of the project, and information about reporting bugs, can
64 be found at http://www.kernel.org/doc/man-pages/.
65
66
67
68Linux 2000-09-21 IOCTL(2)