#include <sys/dkio.h>#include <sys/vtoc.h>
Disk drivers support a set of ioctl(2) requests for disk controller, geometry, and partition information. Basic to these ioctl() requests are the definitions in <sys/dkio.h>.
The following ioctl() requests set and/or retrieve the current disk controller, partitions, or geometry information:
/* * Structures and definitions for disk I/O control commands */
#define DK_DEVLEN 16 /* device name max length, */ /* including unit # and NULL */
/* * Used for controller info */struct dk_cinfo {
};
char dki_cname[DK_DEVLEN ]; /* controller name (no unit #)*/ u_short dki_ctype; /* controller type */ u_short dki_flags; /* flags */ u_short dki_cnum; /* controller number */ u_int dki_addr; /* controller address */ u_int dki_space; /* controller bus type */ u_int dki_prio; /* interrupt priority */ u_int dki_vec; /* interrupt vector */ char dki_dname[DK_DEVLEN ]; /* drive name (no unit #) */ u_int dki_unit; /* unit number */ u_int dki_slave; /* slave number */ u_short dki_partition; /* partition number */ u_short dki_maxtransfer; /* maximum transfer size */ /* in DEV_BSIZE */
/* * Controller types */
#define DKC_UNKNOWN 0 #define DKC_CDROM 1 /* CD-ROM, SCSI or otherwise */ #define DKC_WDC2880 2 #define DKC_XXX_0 3 /* unassigned */ #define DKC_XXX_1 4 /* unassigned */ #define DKC_DSD5215 5 #define DKC_XY450 6 #define DKC_ACB4000 7 #define DKC_MD21 8 #define DKC_XXX_2 9 /* unassigned */ #define DKC_NCRFLOPPY 10 #define DKC_XD7053 11 #define DKC_SMSFLOPPY 12 #define DKC_SCSI_CCS 13 /* SCSI CCS compatible */ #define DKC_INTEL82072 14 /* native floppy chip */ #define DKC_PANTHER 15 #define DKC_SUN_IPI1 DKC_PANTHER /* Sun Panther */ /* VME/IPI controller */ #define DKC_MD 16 /* meta-disk (virtual-disk) */ /* driver */ #define DKC_CDC_9057 17 /* CDC 9057-321 (CM-3) */ /* IPI String Controller */ #define DKC_FJ_M1060 18 /* Fujitsu/Intellistor */ /* IM1060 PI-3 SC */ #define DKC_INTEL82077 19 /* 82077 floppy disk */ /* controller */ #define DKC_DIRECT 20 /* Intel direct attached */ /* device (IDE) */ #define DKC_PCMCIA_MEM 21 /* PCMCIA memory disk-like */ /* type */ #define DKC_PCMCIA_ATA 22 /* PCMCIA AT Attached type */
/* * Sun reserves up through 1023 */
#define DKC_CUSTOMER_BASE 1024
/* * Flags */
#define DKI_BAD144 0x01 /* use DEC std 144 bad sector fwding */ #define DKI_MAPTRK 0x02 /* controller does track mapping */ #define DKI_FMTTRK 0x04 /* formats only full track at a time */ #define DKI_FMTVOL 0x08 /* formats only full volume */ /* at a time*/ #define DKI_FMTCYL 0x10 /* formats only full cylinders */ /* at a time*/ #define DKI_HEXUNIT 0x20 /* unit number printed as 3 hex */ /* digits */ #define DKI_PCMCIA_PFD 0x40 /* PCMCIA pseudo-floppy memory card */
/* * Partition map (part of dk_label) */ struct dk_map {daddr_t dkl_cylno;/* starting cylinder */daddr_t dkl_nblk;/* number of blocks */ }; /* * Used for all partitions */struct dk_allmap {
};
struct dk_map dka_map[NDKMAP ];
/* * Used by applications to get partition or slice information */ struct part_info {};
daddr_t p_start; int p_length;
/* * Definition of a disk’s geometry */struct dk_geom {
};
unsigned short dkg_ncyl; /* # of data */ /* cylinders */ unsigned short dkg_acyl; /* # of alternate*/ /* cylinders */ unsigned short dkg_bcyl; /* cyl offset (for */ /* fixed head area) */ unsigned short dkg_nhead; /* # of heads */ unsigned short dkg_obs1; /* obsolete */ unsigned short dkg_nsect; /* # of sectors */ /* per track */ unsigned short dkg_intrlv; /* interleave factor */ unsigned short dkg_obs2; /* obsolete */ unsigned short dkg_obs3; /* obsolete */ unsigned short dkg_apc; /* alternates per*/ /* cyl (SCSI only) */ unsigned short dkg_rpm; /* revolutions per min*/ unsigned short dkg_pcyl; /* # of physical */ /* cylinders */ unsigned short dkg_write_reinstruct; /* # sectors to */ /* skip, writes */ unsigned short dkg_read_reinstruct; /* # sectors to */ /* skip, reads */ unsigned short dkg_extra[7]; /* for compatible*/ /* expansion */
#define dkg_gap1 dkg_extra[0] /* for application */ /* compatibility */ #define dkg_gap2 dkg_extra[1] /* for application */ /* compatibility */
struct partition {};
ushort p_tag; /* ID tag of partition */ ushort p_flag; /* permission flags */ daddr_t p_start; /* start sector of partition */ long p_size; /* # of blocks in partition */
If DKIOCSVTOC is used with a floppy diskette, the p_start field must be the first sector of a cylinder. Multiply the number of heads by the number of sectors per track to compute the number of sectors per cylinder.
struct vtoc {};
unsigned long v_bootinfo[3]; /* info needed */ /* by mboot */ /* (unsupported) */ unsigned long v_sanity; /* to verify vtoc */ /* sanity */ unsigned long v_version; /* layout version */ char v_volume[LEN_DKL_VVOL ]; /* volume name */ ushort v_sectorsz; /* sector size in */ /* bytes */ ushort v_nparts; /* number of */ /* partitions */ unsigned long v_reserved[10]; /* free space */ struct partition v_part[V_NUMPAR ]; /* partition */ /* headers*/ time_t timestamp[V_NUMPAR ]; /* partition */ /* timestamp */ /* (unsupported) */ char v_asciilabel[LEN_DKL_ASCII ]; /* compatibility */
/* * Partition permission flags */
#define V_UNMNT 0x01 /* Unmountable partition */ #define V_RONLY 0x10 /* Read only */
/* * Partition identification tags */
#define V_UNASSIGNED 0x00 /* unassigned partition */ #define V_BOOT 0x01 /* Boot partition */ #define V_ROOT 0x02 /* Root filesystem */ #define V_SWAP 0x03 /* Swap filesystem */ #define V_USR 0x04 /* Usr filesystem */ #define V_BACKUP 0x05 /* full disk */ #define V_VAR 0x07 /* Var partition */ #define V_HOME 0x08 /* Home partition */ #define V_ALTSCTR 0x09 /* Alternate sector partition */
enum dkio_state {};
DKIO_NONE , /* Return disk’s current state */ DKIO_EJECTED , /* Disk state is ’ejected’ */ DKIO_INSERTED /* Disk state is ’inserted’ */