ioctl() Control I/0 Device
#include <io.h>
int ioctl(handle,cmd[,argdx,argcx]);
int handle; Handle associated with file/drive
int cmd; Function to be performed
int *argdx;
int argcx;
ioctl() is used as a direct interface to the MS-DOS call 0x44
(IOCTL). The exact function performed depends on the value of 'cmd':
0 Get device information
1 Set device information (in 'argdx')
2 Read 'argcx' bytes into the address pointed to
by 'argdx'
3 Write 'argcx' bytes from the address pointed to
by 'argdx'
4 Same as 2, except 'handle' is treated as a drive
number (0=default,1=A, etc)
5 Same as 3, except 'handle' is a drive number
(0=default, 1=A, etc)
6 Get input status
7 Get output status
8 Test removability; DOS 3.x only
11 Set sharing conflict retry count; DOS 3.x only
ioctl() can be used to get information about device channels. Regular
files can also be used, but only 'cmd' values 0, 6, and 7 are defined
for them. All other calls return an EINVAL error for files.
The arguments 'argdx' and 'argcx' are optional.
Returns: For 'cmd' 0 or 1, the return value is the device
information (DX of the IOCTL call).
For 'cmd' values of 2 through 5, the return value is the
number of bytes actually transferred.
For 'cmd' values of 6 or 7, the return value is the
device status.
On error, -1 is returned and 'errno' (defined in
<stdlib.h>) is set to one of the following:
EINVAL Invalid argument
EBADF Bad file number
EINVDAT Invalid data
Notes: ioctl() is available on UNIX systems, but not with these
parameters or this functionality. UNIX version 7 and
System III differ from each other in their use of
ioctl(). ioctl() calls are not portable to UNIX and are
rarely portable across MS-DOS machines.
DOS 3.0 extends ioctl() with 'cmd' values of 8 and 11.
This page last updated on Fri Nov 30 10:48:32 MSK 2001
Copyright © 1992-2001, Vitaly Filatov, Moscow, Russia
Webmaster