| Skip Navigation Links | |
| Exit Print View | |
![]() | man pages section 2: System Calls Oracle Solaris 11 Information Library |
- control device
#include <unistd.h>#include <stropts.h>intioctl(intfildes,intrequest,/*arg */ ...);
Theioctl() function performs a variety of control functions on devices andstreams. For non-streams files, the functions performed by this call are device-specificcontrol functions. Therequest argument and an optional third argument withvarying type are passed to the file designated byfildes and areinterpreted by the device driver.
For streams files, specific functions are performed by theioctl() function asdescribed instreamio(7I).
Thefildes argument is an open file descriptor that refers to adevice. Therequest argument selects the control function to be performedand depends on the device being addressed. Thearg argument representsa third argument that has additional information that is needed by this specificdevice to perform the requested function. The data type ofarg dependsupon the particular control request, but it is either anint ora pointer to a device-specific data structure.
In addition to device-specific and streams functions, generic functions are provided bymore than one device driver (for example, the general terminal interface.) Seetermio(7I)).
Upon successful completion, the value returned depends upon the device control function,but must be a non-negative integer. Otherwise,-1 is returned anderrno is set to indicate the error.
Theioctl() function will fail for any type of file if:
Thefildes argument is not a valid open file descriptor.
A signal was caught during the execution of theioctl() function.
The stream or multiplexer referenced byfildes is linked (directly or indirectly) downstream from a multiplexer.
Theioctl() function will also fail if the device driver detects anerror. In this case, the error is passed throughioctl() withoutchange to the caller. A particular driver might not have all ofthe following error cases. Under the following conditions, requests to device drivers mayfail and seterrno to indicate the error
Therequest argument requires a data transfer to or from a buffer pointed to byarg, butarg points to an illegal address.
Therequest orarg argument is not valid for this device.
Some physical I/O error has occurred.
Thefildes argument is on a remote machine and the link to that machine is no longer active.
Thefildes argument is not associated with a streams device that accepts control functions.
Therequest andarg arguments are valid for this device driver, but the service requested can not be performed on this particular subdevice.
Thefildes argument refers to a valid streams device, but the corresponding device driver does not support theioctl() function.
Streams errors are described instreamio(7I).
Seeattributes(5) for descriptions of the following attributes:
|
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.Legal Notices | ![]() ![]() |