ioctl
Purpose
Controls input/output devices.
Syntax
#include <sys/ioctl.h>
#include <sys/devinfo.h>
int ioctl (fildes, op, arg)
int fildes, op;
char *arg;
Description
The ioctl system call performs a variety of control oper-
ations on the block or character special file (device)
specified by the fildes parameter. The op parameter
specifies the operation, and the use of the arg parameter
depends on the particular operation performed. The ioctl
operations that are valid for each type of device are
explained in Chapter 4, "Special Files." For more infor-
mation on the ioctl operations for use with sockets and
4.3BSD functions, see "socket" and "BSD 4.3 library."
Two operations are valid for all types of devices that
support ioctl system call. These two operations are:
IOCTYPE Returns the device type associated with
fildes. The device types are defined in the
sys/devinfo.h header file, which is discussed
in "devinfo."
IOCINFO Stores device information for the file speci-
fied by fildes into the buffer pointed to by
the arg parameter. See "devinfo" for the
format of the device information structure.
Some devices support additional requests. See the dis-
cussion of individual devices in Chapter 4, "Special
Files" for details about device-dependent ioctl calls.
Return Value
If ioctl fails, a value of -1 is returned and errno is
set to indicate the error.
Diagnostics
The ioctl fails if one or more of the following are true:
EBADF fildes is not a valid open file descriptor.
ENOTTY fildes is not associated with a character
special file.
ENODEV The device associated with fildes does not
support the ioctl system call.
EFAULT The arg parameter &pointsout..
EINVAL op or arg is not valid.
EINTR A signal was caught during the ioctl system
call.
Related Information
In this book: "devinfo," and Chapter 4, "Special
Files."
The discussion of ddioctl in Device Driver Development
Guide.
The discussion of termio in AIX Operating System Program-
ming Tools and Interfaces.