 |
Index for Section 9 |
|
 |
Alphabetical listing for D |
|
 |
Bottom of page |
|
DEVGETGEOM(9r)
NAME
DEVGETGEOM - Disk: Obtains device geometry information
SYNOPSIS
#include <io/common/devio.h>
#include <sys/ioctl.h>
int ioctl(
dev_t dev,
register int DEVGETGEOM,
caddr_t data,
int flag );
DESCRIPTION
The DEVGETGEOM ioctl command obtains generic device geometry information by
polling the underlying device driver. DEVGETGEOM uses the following union
defined in the file /usr/sys/include/io/common/devio.h:
typedef union devgeom {
struct {
unsigned long dev_size;
unsigned short ntracks;
unsigned short nsectors;
unsigned short ncylinders;
unsigned long attributes;
unsigned long sector_size;
unsigned long min_trans;
unsigned long max_trans;
unsigned long prefer_trans;
} geom_info;
unsigned char pad[108];
} DEVGEOMST;
This union contains two members: a geom_info data structure and a pad array
that allocates space to allow for future expansion. The following list
describes the members of the geom_info structure:
dev_size
Specifies the total number of sectors/blocks on the device available
for use.
ntracks
Specifies the number of tracks per cylinder. This number may not
actually reflect the number of tracks per cylinder but is an estimate
(RAID devices).
nsectors
Specifies an average number of sectors per track.
ncylinders
Specifies an average number of cylinders per track.
attributes
Specifies one of the following device attributes: DEVGEOM_REMOVE (a
removable device) or DEVGEOM_DYNAMIC (a dynamic geometry device).
sector_size
Specifies the number of bytes in the sector.
min_trans
Specifies the minimum number of bytes for the transfer size.
max_trans
Specifies the maximum number of bytes for the transfer size.
prefer_trans
Specifies the preferred number of bytes for the transfer size.
EXAMPLE
The following code example shows how a disk device driver can use the
DEVGETGEOM ioctl command. The example uses the attributes, dev_size, and
sector_size members of the geom_info structure.
.
.
.
cdisk_ioctl(dev_t dev, register int cmd, caddr_t data, int flag)
{
.
.
.
switch (cmd) {
.
.
.
/*
* Disk geometry info.
*/
case DEVGETGEOM:
{
DEVGEOMST *devgeom = (DEVGEOMST *)data;
.
.
.
bzero((caddr_t)devgeom, sizeof(DEVGEOMST));
if(inqp->rmb)
devgeom->geom_info.attributes |= DEVGEOM_REMOVE;
/*
* HSX00 and HSX01 FIB RAID devices are flagged
* as having "dynamic geometry" because the
* geometry of the underlying device can change
* depending on the configuration of units.
*/
if ( dd->dd_flags & SZ_DYNAMIC_GEOM != 0)
devgeom->geom_info.attributes |= DEVGEOM_DYNAMIC;
/*
* Get disk size via read capacity command.
*/
read_cap_data = (DIR_READ_CAP_DATA *)
ccmn_get_dbuf((U32)sizeof(DIR_READ_CAP_DATA));
if(cdisk_read_capacity(pd, read_cap_data) == 0) {
BTOL(&read_cap_data->lbn3, nblocks);
/*
* RDCAP returns the address of the last LBN.
* Add one to get the number of LBNs.
*/
devgeom->geom_info.dev_size = ++nblocks;
/*
* Get the sector size.
*/
BTOL(&read_cap_data->block_len3, blk_len);
devgeom->geom_info.sector_size = blk_len ;
.
.
.
SEE ALSO
ioctl Commands: DEVIOCGET(9r)
 |
Index for Section 9 |
|
 |
Alphabetical listing for D |
|
 |
Top of page |
|