ioctl(2) — System Calls
NAME
ioctl − Controls devices
SYNOPSIS
#include <sys/ioctl.h> ioctl(
int d,
int request,
void ∗ arg );
PARAMETERS
dSpecifies the file descriptor of the requested device.
requestSpecifies the ioctl command to be performed on the device.
argSpecifies parameters for this request. The type of arg is dependent on the specific ioctl() request and device to which the ioctl is targeted. See the appropriate Section 7 reference page or the documentation accompanying the device for more information.
DESCRIPTION
The ioctl() function performs a variety of operations on open file descriptors. In particular, many operating characteristics of character special files (for example, terminals) are controlled with ioctl() requests.
An ioctl() request has encoded in it whether the parameter is an "in" parameter or "out" parameter, and the size of the arg parameter in bytes. Macros and defines used to specify an ioctl() request are located in the <sys/ioctl.h> header file.
The ioctl() function performs a variety of control functions on devices and STREAMS. For non-STREAMS files, the functions performed by this call are device-specific control functions. The request and arg parameters are passed to the file designated by fildes and are interpreted by the device driver. This control is occasionally used on non-STREAMS devices, with the basic input/output functions performed through the read() and write() system calls.
For STREAMS files, specific functions are performed by the ioctl() function as described in streamio(7).
STREAMS errors are described in streamio(7).
RETURN VALUES
If an error occurs, a value of −1 is returned and errno is set to indicate the error.
ERRORS
If the ioctl() function fails, errno may be set to one of the following values:
[EBADF]The d parameter is not a valid descriptor.
[ENOTTY]The d parameter is not associated with a character special device.
[ENOTTY]The specified request does not apply to the kind of object that the d parameter references.
[EINVAL]Either the request or arg parameter is not valid.
FILES
<sys/ioctl.h>
RELATED INFORMATION
Files: tty(7), lvm(7), streamio(7).