ioctl(2) CLIX ioctl(2)
NAME
ioctl - Control device
LIBRARY
Standard C Library (libc.a)
SYNOPSIS
int ioctl(
int fildes ,
int request );
PARAMETERS
fildes Represents a file descriptor.
request Represents a request.
arg Requests specific data, either a pointer to a device-specific
data structure or an integer flag.
DESCRIPTION
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 infrequently used on non-STREAMS devices, with
the basic input/output functions performed through the read() and write()
functions.
For STREAMS files, specific functions are performed by ioctl() as
described in streamio(7).
The fildes parameter is an open file descriptor that refers to a device.
The request parameter selects the control function to be performed and
will depend on the device being addressed. The arg parameter represents
additional information that is needed by this specific device to perform
the requested function. The data type of arg depends upon the particular
control request, but it is either an integer or a pointer to a device-
specific data structure.
In addition to device-specific and STREAMS functions, generic functions
are provided by more than one device driver, such as the general terminal
interface. (See the termio command.)
EXAMPLES
To perform a PUSH function on an open stream:
2/94 - Intergraph Corporation 1
ioctl(2) CLIX ioctl(2)
if (ioctl(stream_fd, I_PUSH, module_name) == -1)
perror("ioctl PUSH failed");
RETURN VALUES
Upon successful completion, the value returned depends upon the device
control function, but must be a non-negative integer. Otherwise, a value
of -1 is returned and errno is set to indicate the error.
ERRORS
The ioctl() function fails for any type of file if one or more of the
following are true:
[EBADF] The fildes parameter is not a valid open file descriptor.
[ENOTTY] The value of fildes is not associated with a device driver that
accepts control functions.
[EINTR] A signal was caught during the ioctl() function.
The ioctl() function also fails if the device driver detects an error. In
this case, the error is passed through ioctl() without change to the
caller. A particular driver might not have all of the following error
cases. Other requests to device drivers fail if one or more of the
following are true:
[EFAULT] The value of request requires a data transfer to or from a
buffer pointed to by arg, but some part of the buffer is
outside the process's allocated space.
[EINVAL] The value of request or arg is not valid for this device.
[EIO] Some physical I/O error has occurred.
[ENXIO] The request and arg parameters are valid for this device
driver, but the service requested can not be performed on this
particular subdevice.
[ENOLINK] The specified fildes is on a remote machine and the link to
that machine is no longer active.
STREAMS errors are described in streamio().
RELATED INFORMATION
Files: streamio(7), termio(7), termios(7)
2 Intergraph Corporation - 2/94