www.delorie.com/djgpp/doc/libc-2.01/libc_416.html   search  
Go to the first, previous, next, last section, table of contents.


ioctl (DOS)

The DOSish version of ioctl performs an interrupt 0x21, function 0x44. It takes care of supplying transfer buffers in low address regions, if they are needed. For an exhaustive description of the various commands and subcommands, see Ralph Browns interrupt list.

It is highly recommended to use only the DOS_* functions listed in `sys/ioctl.h'.

Syntax

ioctl(fd, cmd, ... );

#include <sys/ioctl.h>
int main(int argc, char **argv){
   char buf[6];
   short *s;

   open(fd,"EMMQXXX0",O_RDONLY);
   mybuf[0] = '\0';
   s = mybuf;
   ioctl(fd,DOS_SNDDATA,6, (int) &mybuf);
   if(*s ==0x25 )printf("EMM386 >= 4.45\n");
   mybuf[0]='\x02';
   ioctl(fd,DOS_SNDDATA,2,(int )&mybuf);
   printf("EMM Version %d.%d\n",(int )mybuf[0],(int) mybuf[1]);
   close(fd);
}

Description

The parameter fd must refer to a file descriptor for character device functions, or the number of a block device (usually current=0, A:=1, ...).

The following constants can be used for the cmd parameter:

DOS_GETDEVDATA
Get device information. Returns the device information word from DX.
DOS_SETDEVDATA
Set device information. Returns the new device information word form DX or -1
DOS_RCVDATA
Read from character device control channel. After cmd must follow the number of requested bytes to read and a pointer to a buffer. Returns the number of bytes actually read or -1 on error.
DOS_SNDDATA
Write to character device control channel. After cmd must follow the number of bytes to write and a pointer to a buffer holding the data. Returns the number of bytes actually written.
DOS_RCVCTLDATA
Read from block device control channel. See DOS_RCVDATA.
DOS_SNDCTLDATA
Write to block device control channel. See DOS_SNDDATA.
DOS_CHKINSTAT
Check the input status of a file. Returns 0 if not ready of at EOF, 0xff if file is ready.
DOS_CHKOUTSTAT
Check the output status of a file. Returns 0 if not ready of at EOF, 0xff if file is ready.
DOS_ISCHANGEABLE
Check if a block device is changeable. Returns 0 for removable or 1 for fixed.
DOS_ISREDIRBLK
Check if a block device is remote o local.
DOS_ISREDIRHND
Check if a file handle refers to a local or remote device.
DOS_SETRETRY
Set the sharing retry count. the first extra parameter specifies the pause between retries, the second number of retries.
DOS_GENCHARREQ
Generic character device request.
DOS_GENBLKREQ
Generic block device request.
DOS_GLDRVMAP
Get logical drive map.
DOS_SLDRVMAP
Set logical drive map.
DOS_QGIOCTLCAPH
Query generic ioctl capability (handle). Test if a handle supports ioctl functions beyond those in the standard DOS 3.2 set.
DOS_QGIOCTLCAPD
Query generic ioctl capability (drive). Test if a drive supports ioctl functions beyond those in the standard DOS 3.2 set.

If your specific device driver requires different commands, they must be or'ed together with the flags listed in `ioctl.h' to tell the drive about transfer buffers and what to return.

Return Value

See description above.

Device information word

The bits of the device information word have the following meaning:\\ Character device:

14 Device driver can process IOCTL request 13 output until busy supported 11 driver supports OPEN/CLOSE calls 7 set (indicates device) 6 EOF on input 5 raw (binary) mode 4 device is special (uses INT 29) 3 clock device 2 NUL device 1 standard output 0 standard input

Disk file:

15 file is remote (DOS 3.0+) 14 don't set file date/time on closing (DOS 3.0+) 11 media not removable 8 (DOS 4 only) generate INT 24 if no disk space on write or read past end of file 7 clear (indicates file) 6 file has not been written 5-0 drive number (0 = A:)


Go to the first, previous, next, last section, table of contents.

  prev next   webmaster     delorie software   privacy  
  Copyright © 1997     Updated Apr 1997