devinfo
Purpose
Contains device characteristics.
Synopsis
#include <sys/devinfo.h>
Description
The devinfo structure is defined for each device. The
IOCINFO operation of the ioctl system call fills in this
structure. The information returned by a device varies.
Most devices, other than disk devices, return a devtype
value and the remainder of this structure contains zeros.
This structure provides information about the capabili-
ties of a device, rather than its current status or set-
tings. For example, types of information provided are
the number of characters a printer handles per line or
the diskette capacity in number of blocks.
The maximum size of this structure is 12 bytes (no longer
than the disk version), so that programs can use the
ioctl system call without concern of overrun due to
increasing size.
struct devinfo
{ char devtype;
char flags;
union
{
struct /* for disks */
{ short bytpsec; /* bytes per sector */
short secptrk; /* sectors per track */
short trkpcyl; /* tracks per cylinder */
long numblks; /* blocks this minidisk */
} dk;
struct /* for memory mapped displays */
{
char capab; /* capabilities */
char mode; /* current mode */
short hres; /* horizontal resolution */
short vres; /* vertical resolution */
} tt;
} un;
};
The following flags specify some generic capabilities
(see DD_DISK):
Constant Value Function
DF_FIXED 01 Not removable
DF_RAND 02 Random access possible
DF_FAST 04 A relative term
The devinfo structures are defined for the following devices (specified in
the devtype field):
DD_DISK Indicates a disk. This devtype is R. The driver determines the
values. The fixed disk has flags DF_RAND | DF_FIXED | DF_FAST,
while the diskette has flags DF_RAND (see "fd" and "hd").
The number of the bytes per sector, sectors per track, and tracks
per cylinder for the fixed disk are predetermined. The minidisk
table determines the number of blocks. For the diskette, the minor
device driver or the physical media determines this information
when the device is opened.
DD_LP Indicates a line printer. The devtype is l. This fills in the
devtype field and returns zeros for the rest of the structure.
DD_PSEU Indicates a pseudo-device. This devtype is Z.
DD_RTC Indicates a real-time (calendar) clock. This devtype is c.
DD_TAPE Indicates a magnetic tape. This devtype is M.
DD_TTY Indicates a terminal. This returns a devtype of T and zeros for
the rest of the structure.
DT_STREAM Indicates a streaming tape drive. The devtype is 2.
DT_STRTSTP Indicates a start-stop tape drive. The devtype is 2.
Related Information
In this book: "ioctl," "fd," and "hd."