Under the following general conditions, ioctl() shall fail if:
EBADF The fildes argument is not a valid open file descriptor.
EINTR A signal was caught during the ioctl() operation.
EINVAL The STREAM or multiplexer referenced by fildes is linked
(directly or indirectly) downstream from a multiplexer.
If an underlying device driver detects an error, then ioctl()
shall fail if:
EINVAL The request or arg argument is not valid for this device.
EIO Some physical I/O error has occurred.
ENOTTY The file associated with the fildes argument is not a
STREAMS device that accepts control functions.
ENXIO The request and arg arguments are valid for this device
driver, but the service requested cannot be performed on
this particular sub-device.
ENODEV The fildes argument refers to a valid STREAMS device, but
the corresponding device driver does not support the
ioctl() function.
If a STREAM is connected downstream from a multiplexer, any
ioctl() command except I_UNLINK and I_PUNLINK shall set errno to
[EINVAL].
The following sections are informative.