Index Index for
Section 9
Index Alphabetical
listing for D
Bottom of page Bottom of
page

DEVGETINFO(9r)

NAME

DEVGETINFO - Disk: Obtains information about a device

SYNOPSIS

#include <io/common/devio.h> #include <sys/ioctl.h> int ioctl( dev_t dev, register int DEVGETINFO, caddr_t data, int flag );

DESCRIPTION

The DEVGETINFO ioctl command returns information about a device by polling the underlying device driver. The DEVGETINFO ioctl command queries the device for as much information as it can, initializes members of the appropriate data structures within the device_info_t union, then assigns the address of this union to the user's data buffer. The device_info_t union is the top-level definition of the information returned to the DEVGETINFO ioctl command. It has the following definition: typedef union device_info { int version; v1_device_info_t v1; uchar_t pad[1024]; } device_info_t; The v1_device_info_t structure contains all the information returned to the user data buffer by the DEVGETINFO ioctl command. This structure is contained within the device_info_t structure so that the same interface can be used for various versions of the data structure. It has the following definition: typedef struct v1_device_info { int version; short category; short bus; char interface[DEV_STRING_SIZE]; char device[DEV_STRING_SIZE]; char dev_name[DEV_STRING_SIZE]; ulong_t soft_count; ulong_t hard_count; v1_devtype_info_t devinfo; v1_bustype_info_t businfo; uchar_t private[DEV_PRIVATE_LEN]; } v1_device_info_t; The v1_devtype_info_t union returns device-specific information. The contents of the v1_devtype_info_t union depends on the device type, either disk, tape, or other device type. The structure has the following definition: typedef union v1_devtype_info { v1_disk_dev_info_t disk; v1_tape_dev_info_t tape; uchar_t devdata[DEV_TYPE_LEN]; } v1_devtype_info_t; The v1_bustype_info_t structure returns information about the bus type. It has the following definition: typedef struct v1_bustype_info { int adpt_num; int nexus_num; int bus_num; int ctlr_num; int rctlr_num; int slave_num; int unit_num; int pad0; union { v1_scsi_bus_info_t scsi; uchar_t busdata[DEV_BUS_LEN]; } bus; } v1_bustype_info_t; For disk devices, the v1_devtype_info_t union contains a v1_disk_dev_info_t structure, defined as follows: typedef struct v1_disk_dev_info { ulong_t status; ulong_t capacity; ulong_t blocksz; uchar_t class; uchar_t part_num; uchar_t raid_level; uchar_t pad0; ushort_t media_changes; ushort_t pad1; union { struct { uchar_t density_code; uchar_t flags; } scsi; uchar_t archdata[DEV_ARCH_LEN]; } arch; } v1_disk_dev_info_t; For tape devices, the v1_devtype_info_t union contains a v1_tape_dev_info_t structure, defined as follows: typedef struct v1_tape_dev_info { uint_t media_status; uint_t unit_status; long recordsz; long density_bpi; long density_bpi_wrt; long position; long fm_cnt; uchar_t class; uchar_t pad[7]; union { struct { uint_t blocking_factor; uchar_t valid_flags; uchar_t density_code; uchar_t buffered_mode; uchar_t speed; uchar_t compression_code; } scsi; uchar_t archdata[DEV_ARCH_LEN]; } arch; } v1_tape_dev_info_t;

NOTES

The DEVGETINFO ioctl command replaces the DEVIOCGET ioctl command. Your driver may still support DEVIOCGET for backwards compatibility, but we recommend that you use the DEVGETINFO ioctl command. The DEVIOCGET ioctl command may not be supported in future releases.

EXAMPLE

The following example shows how a device driver can return generic information about any device type. For information on filling in bus- specific information and polling a disk device for device-specific information, see Writing Device Drivers: Advanced Topics. . . . case DEVGETINFO: { struct device *device; [1] v1_device_info_t *devi_p; devi_p = (v1_device_info_t *)data; [2] bzero((caddr_t)devi_p,sizeof(*devi_p)); /**************************************************** * fill in generic information ****************************************************/ devi_p->version = VERSION_1; [3] devi_p->category = DEV_DISK; devi_p->bus = FILLIN; bcopy("XXX", devi_p->interface, 3); bcopy("xxxdev", devi_p->device, 6); bcopy("xx", devi_p->dev_name, 2); devi_p->soft_count = devp->soft_err_cnt; devi_p->hard_count = devp->hard_err_cnt; . . . 1. Declares the data structures and unions that this ioctl command returns. 2. Assigns the address of the data buffer to the devi_p variable, casting the data buffer to a device information structure. In this way, information is returned to the caller. 3. Provides general information about the device from hard-coded values, such as the version number and device category, or from device- specific data structures, such as the soft and hard error counts.

SEE ALSO

Data Structures: device_info_t(9s), v1_bustype_info_t(9s), v1_device_info_t(9s), v1_devtype_info_t(9s), v1_disk_dev_info_t(9s), v1_tape_dev_info_t(9s)

Index Index for
Section 9
Index Alphabetical
listing for D
Top of page Top of
page