ioctl
Controls I/O device.
Defined in header <io.h>
Syntax
#include <io.h>
int ioctKint handle, intfiinc [, void *argdx, int argcx]);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ | ■ | ■ | ■ |
Remarks
ioctI is available on UNIX systems, but not with these parameters or functionality. UNIX version 7 and System III differ from each other in their use of ioctl. ioctI calls are not portable to UNIX and are rarely portable across DOS machines.
DOS 3.0 extends ioctl with func values of 8 and 11.
This is a direct interface to the DOS call 0x44 (IOCTL).
The exact function depends on the value oifunc as follows:
Get device information. Set device information (in argdx). Read argcx bytes into the address pointed to by argdx. Write argcx bytes from the address pointed to by argdx. Same as 2 except handle is treated as a drive number (0 equals default, 1 equals A, and so on). Same as 3 except handle is a drive number (0 equals default, 1 equals A, and so on). Get input status. Get output status. Test removability; DOS 3.0 only.
| 11 | Set sharing conflict retry count; DOS 3.0 only. |
ioctl can be used to get information about device channels. Regular files can also be used, but only fimc values 0, 6, and 7 are defined for them. All other calls return an EINVAL error for files.
See the documentation for system call 0x44 in your DOS reference manuals for detailed information on argument or return values.
The arguments argdx and argcx are optional.
ioctI provides a direct interface to DOS device drivers for special functions. As a result, the exact behavior of this function varies across different vendors' hardware and in different devices. Also, several vendors do not follow the interfaces described here. Refer to the vendor BIOS documentation for exact use of ioctl.
Return value
Forfunc 0 or 1, the return value is the device information (DX of the IOCTL call).
For func values of 2 through 5, the return value is the number of bytes actually transferred.
For fimc values of 6 or 7, the return value is the device status.
In any event, if an error is detected, a value of -1 is returned, and the global variable errno is set to one of the following:
| EINVAL | Invalid argument |
| EBADF | Bad file number |
| EINVDAT | Invalid data |
Example
#include <stdio.h>
#include <dir.h>
#include <io.h>
int main (void)
int Stat;
/* use func 8 to determine if the default drive is removable */
Stat = ioctl (0, 8, 0, 0);
if (istat)
printf( "Drive %c is removable.\n", getdiskO + 'A');
else
printf( "Drive %c is not removable.\n", getdiskO + 'A');
return 0;
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Extraction notes
- heading `iocti` read as `ioctl`
Stable link: /3.1/io.h/ioctl/
· short form /3.1/ioctl/