1ioctl(2)                         System Calls                         ioctl(2)
2
3
4

NAME

6       ioctl - control device
7

SYNOPSIS

9       #include <unistd.h>
10       #include <stropts.h>
11
12       int ioctl(int fildes, int request, /* arg */ ...);
13
14

DESCRIPTION

16       The ioctl() function performs a variety of control functions on devices
17       and streams. For non-streams files, the  functions  performed  by  this
18       call  are  device-specific control functions.  The request argument and
19       an optional third argument with varying type are  passed  to  the  file
20       designated by fildes and are interpreted by the device driver.
21
22
23       For  streams  files,  specific  functions  are performed by the ioctl()
24       function as described in streamio(7I).
25
26
27       The fildes argument is an open file descriptor that refers to a device.
28       The  request  argument selects the control function to be performed and
29       depends on the device being addressed.  The arg argument  represents  a
30       third  argument  that has additional information that is needed by this
31       specific device to perform the requested function. The data type of arg
32       depends upon the particular control request, but it is either an int or
33       a pointer to a device-specific data structure.
34
35
36       In addition to device-specific and streams functions, generic functions
37       are  provided  by more than one device driver (for example, the general
38       terminal interface.)  See termio(7I)).
39

RETURN VALUES

41       Upon successful completion, the value returned depends upon the  device
42       control function, but must be a non-negative integer.  Otherwise, −1 is
43       returned and errno is set to indicate the error.
44

ERRORS

46       The ioctl() function will fail for any type of file if:
47
48       EBADF     The fildes argument is not a valid open file descriptor.
49
50
51       EINTR     A signal was caught during the execution of the ioctl() func‐
52                 tion.
53
54
55       EINVAL    The  stream  or  multiplexer  referenced  by fildes is linked
56                 (directly or indirectly) downstream from a multiplexer.
57
58
59
60       The ioctl() function will also fail if the  device  driver  detects  an
61       error.   In  this  case,  the  error  is passed through ioctl() without
62       change to the caller. A particular driver might not  have  all  of  the
63       following  error  cases.  Under  the  following conditions, requests to
64       device drivers may fail and set errno to indicate the error
65
66       EFAULT     The request argument requires a data transfer to or  from  a
67                  buffer  pointed  to  by  arg,  but  arg points to an illegal
68                  address.
69
70
71       EINVAL     The request or arg argument is not valid for this device.
72
73
74       EIO        Some physical I/O error has occurred.
75
76
77       ENOLINK    The fildes argument is on a remote machine and the  link  to
78                  that machine is no longer active.
79
80
81       ENOTTY     The  fildes argument is not associated with a streams device
82                  that accepts control functions.
83
84
85       ENXIO      The request and arg arguments  are  valid  for  this  device
86                  driver,  but  the  service requested can not be performed on
87                  this particular subdevice.
88
89
90       ENODEV     The fildes argument refers to a valid  streams  device,  but
91                  the corresponding device driver does not support the ioctl()
92                  function.
93
94
95
96       Streams errors are described in streamio(7I).
97

ATTRIBUTES

99       See attributes(5) for descriptions of the following attributes:
100
101
102
103
104       ┌─────────────────────────────┬─────────────────────────────┐
105       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
106       ├─────────────────────────────┼─────────────────────────────┤
107       │Interface Stability          │Standard                     │
108       └─────────────────────────────┴─────────────────────────────┘
109

SEE ALSO

111       attributes(5), standards(5), streamio(7I), termio(7I)
112
113
114
115SunOS 5.11                        15 Feb 1996                         ioctl(2)
Impressum