xref: /illumos-gate/usr/src/man/man4i/dkio.4i (revision 899b7fc7762875c5244567fbc6bb4ccace75d6f7)
1bbf21555SRichard Lowe.\"
2bbf21555SRichard Lowe.\" The contents of this file are subject to the terms of the
3bbf21555SRichard Lowe.\" Common Development and Distribution License (the "License").
4bbf21555SRichard Lowe.\" You may not use this file except in compliance with the License.
5bbf21555SRichard Lowe.\"
6bbf21555SRichard Lowe.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
7bbf21555SRichard Lowe.\" or http://www.opensolaris.org/os/licensing.
8bbf21555SRichard Lowe.\" See the License for the specific language governing permissions
9bbf21555SRichard Lowe.\" and limitations under the License.
10bbf21555SRichard Lowe.\"
11bbf21555SRichard Lowe.\" When distributing Covered Code, include this CDDL HEADER in each
12bbf21555SRichard Lowe.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
13bbf21555SRichard Lowe.\" If applicable, add the following below this CDDL HEADER, with the
14bbf21555SRichard Lowe.\" fields enclosed by brackets "[]" replaced with your own identifying
15bbf21555SRichard Lowe.\" information: Portions Copyright [yyyy] [name of copyright owner]
16bbf21555SRichard Lowe.\"
17bbf21555SRichard Lowe.\"
18bbf21555SRichard Lowe.\" Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved.
19bbf21555SRichard Lowe.\" Copyright 2016 Nexenta Systems, Inc.
20bbf21555SRichard Lowe.\" Copyright (c) 2017, Joyent, Inc.
21bbf21555SRichard Lowe.\"
22*899b7fc7SPeter Tribble.Dd March 13, 2022
23bbf21555SRichard Lowe.Dt DKIO 4I
24bbf21555SRichard Lowe.Os
25bbf21555SRichard Lowe.Sh NAME
26bbf21555SRichard Lowe.Nm dkio
27bbf21555SRichard Lowe.Nd disk control operations
28bbf21555SRichard Lowe.Sh SYNOPSIS
29bbf21555SRichard Lowe.In sys/dkio.h
30bbf21555SRichard Lowe.In sys/vtoc.h
31bbf21555SRichard Lowe.Sh DESCRIPTION
32bbf21555SRichard LoweDisk drivers support a set of
33bbf21555SRichard Lowe.Xr ioctl 2
34bbf21555SRichard Lowerequests for disk controller, geometry, and partition information.
35bbf21555SRichard LoweBasic to these
36bbf21555SRichard Lowe.Xr ioctl 2
37bbf21555SRichard Lowerequests are the definitions in
38bbf21555SRichard Lowe.In sys/dkio.h .
39bbf21555SRichard Lowe.Sh IOCTLS
40bbf21555SRichard LoweThe following
41bbf21555SRichard Lowe.Xr ioctl 2
42bbf21555SRichard Lowerequests set and/or retrieve the current disk
43bbf21555SRichard Lowecontroller, partitions, or geometry information on all architectures:
44bbf21555SRichard Lowe.Bl -tag -width 1n
45bbf21555SRichard Lowe.It Dv DKIOCINFO
46bbf21555SRichard Lowe.Pp
47bbf21555SRichard LoweThe argument is a pointer to a
48bbf21555SRichard Lowe.Vt dk_cinfo
49bbf21555SRichard Lowestructure (described below).
50*899b7fc7SPeter TribbleThis structure contains the controller-type and attributes regarding bad-block
51bbf21555SRichard Loweprocessing done on the controller.
52bbf21555SRichard Lowe.Bd -literal -offset 2n
53bbf21555SRichard Lowe/*
54bbf21555SRichard Lowe * Structures and definitions for disk I/O control commands
55bbf21555SRichard Lowe */
56bbf21555SRichard Lowe#define DK_DEVLEN 16   /* device name max length, */
57bbf21555SRichard Lowe                       /* including unit # and NULL */
58bbf21555SRichard Lowe
59bbf21555SRichard Lowe/* Used for controller info */
60bbf21555SRichard Lowestruct dk_cinfo {
61bbf21555SRichard Lowe     char      dki_cname[DK_DEVLEN];    /* controller name */
62bbf21555SRichard Lowe                                        /* (no unit #) */
63bbf21555SRichard Lowe     ushort_t  dki_ctype;               /* controller type */
64bbf21555SRichard Lowe     ushort_t  dki_flags;               /* flags */
65bbf21555SRichard Lowe     ushort_t  dki_cnum;                /* controller number */
66bbf21555SRichard Lowe     uint_t    dki_addr;                /* controller address */
67bbf21555SRichard Lowe     uint_t    dki_space;               /* controller bus type */
68bbf21555SRichard Lowe     uint_t    dki_prio;                /* interrupt priority */
69bbf21555SRichard Lowe     uint_t    dki_vec;                 /* interrupt vector */
70bbf21555SRichard Lowe     char      dki_dname[DK_DEVLEN];    /* drive name (no unit #) */
71bbf21555SRichard Lowe     uint_t    dki_unit;                /* unit number */
72bbf21555SRichard Lowe     uint_t    dki_slave;               /* slave number */
73bbf21555SRichard Lowe     ushort_t  dki_partition;           /* partition number */
74bbf21555SRichard Lowe     ushort_t  dki_maxtransfer;         /* maximum transfer size */
75bbf21555SRichard Lowe                                        /* in DEV_BSIZE */
76bbf21555SRichard Lowe     };
77bbf21555SRichard Lowe
78bbf21555SRichard Lowe     /*
79bbf21555SRichard Lowe      * Controller types
80bbf21555SRichard Lowe      */
81bbf21555SRichard Lowe     #define DKC_UNKNOWN      0
82bbf21555SRichard Lowe     #define DKC_CDROM        1         /* CD-ROM, SCSI or other */
83bbf21555SRichard Lowe     #define DKC_WDC2880      2
84bbf21555SRichard Lowe     #define DKC_XXX_0        3         /* unassigned */
85bbf21555SRichard Lowe     #define DKC_XXX_1        4         /* unassigned */
86bbf21555SRichard Lowe     #define DKC_DSD5215      5
87bbf21555SRichard Lowe     #define DKC_ACB4000      7
88bbf21555SRichard Lowe     #define DKC_XXX_2        9         /* unassigned */
89bbf21555SRichard Lowe     #define DKC_NCRFLOPPY    10
90bbf21555SRichard Lowe     #define DKC_SMSFLOPPY    12
91bbf21555SRichard Lowe     #define DKC_SCSI_CCS     13        /* SCSI CCS compatible */
92bbf21555SRichard Lowe     #define DKC_INTEL82072   14        /* native floppy chip */
93bbf21555SRichard Lowe     #define DKC_INTEL82077   19        /* 82077 floppy disk */
94bbf21555SRichard Lowe                                        /* controller */
95bbf21555SRichard Lowe     #define DKC_DIRECT       20        /* Intel direct attached */
96bbf21555SRichard Lowe                                        /* device (IDE) */
97bbf21555SRichard Lowe     #define DKC_PCMCIA_MEM   21        /* PCMCIA memory disk-like */
98bbf21555SRichard Lowe                                        /* type */
99bbf21555SRichard Lowe     #define DKC_PCMCIA_ATA   22        /* PCMCIA AT Attached type */
100bbf21555SRichard Lowe
101bbf21555SRichard Lowe     /*
102bbf21555SRichard Lowe      * Sun reserves up through 1023
103bbf21555SRichard Lowe      */
104bbf21555SRichard Lowe
105bbf21555SRichard Lowe     #define DKC_CUSTOMER_BASE  1024
106bbf21555SRichard Lowe
107bbf21555SRichard Lowe     /*
108bbf21555SRichard Lowe      * Flags
109bbf21555SRichard Lowe      */
110bbf21555SRichard Lowe     #define DKI_BAD144       0x01          /* use  DEC  std  144  */
111bbf21555SRichard Lowe                                            /* bad  sector fwding */
112bbf21555SRichard Lowe     #define DKI_MAPTRK       0x02          /* controller does */
113bbf21555SRichard Lowe                                            /* track mapping */
114bbf21555SRichard Lowe     #define DKI_FMTTRK       0x04          /* formats only  full
115bbf21555SRichard Lowe                                            /* track at a time */
116bbf21555SRichard Lowe     #define DKI_FMTVOL       0x08          /* formats only full */
117bbf21555SRichard Lowe                                            /* volume at a time */
118bbf21555SRichard Lowe     #define DKI_FMTCYL       0x10          /* formats only full */
119bbf21555SRichard Lowe                                            /* cylinders at a time */
120bbf21555SRichard Lowe     #define DKI_HEXUNIT      0x20          /* unit number printed */
121bbf21555SRichard Lowe                                            /* as 3 hexdigits */
122bbf21555SRichard Lowe     #define DKI_PCMCIA_PFD   0x40          /* PCMCIA pseudo-floppy */
123bbf21555SRichard Lowe                                            /* memory card */
124bbf21555SRichard Lowe.Ed
125bbf21555SRichard Lowe.It Dv DKIOCGAPART
126bbf21555SRichard Lowe.Pp
127bbf21555SRichard LoweThe argument is a pointer to a
128bbf21555SRichard Lowe.Vt dk_allmap
129bbf21555SRichard Lowestructure (described below).
130bbf21555SRichard LoweThis
131bbf21555SRichard Lowe.Xr ioctl 2
132bbf21555SRichard Lowegets the controller's notion of the current partition table
133bbf21555SRichard Lowefor disk drive.
134bbf21555SRichard Lowe.It Dv DKIOCSAPART
135bbf21555SRichard Lowe.Pp
136bbf21555SRichard LoweThe argument is a pointer to a
137bbf21555SRichard Lowe.Vt dk_allmap
138bbf21555SRichard Lowestructure (described below).
139bbf21555SRichard LoweThis
140bbf21555SRichard Lowe.Xr ioctl 2
141bbf21555SRichard Lowesets the controller's notion of the partition table without
142bbf21555SRichard Lowechanging the disk itself.
143bbf21555SRichard Lowe.Bd -literal -offset 2n
144bbf21555SRichard Lowe/*
145bbf21555SRichard Lowe * Partition map (part of dk_label)
146bbf21555SRichard Lowe */
147bbf21555SRichard Lowestruct dk_map {
148bbf21555SRichard Lowe     daddr_t dkl_cylno;     /* starting cylinder */
149bbf21555SRichard Lowe     daddr_t dkl_nblk;      /* number of blocks */
150bbf21555SRichard Lowe};
151bbf21555SRichard Lowe
152bbf21555SRichard Lowe/*
153bbf21555SRichard Lowe * Used for all partitions
154bbf21555SRichard Lowe */
155bbf21555SRichard Lowestruct dk_allmap {
156bbf21555SRichard Lowe    struct dk_map    dka_map[NDKMAP];
157bbf21555SRichard Lowe};
158bbf21555SRichard Lowe.Ed
159bbf21555SRichard Lowe.It Dv DKIOCGGEOM
160bbf21555SRichard Lowe.Pp
161bbf21555SRichard LoweThe argument is a pointer to a
162bbf21555SRichard Lowe.Vt dk_geom
163bbf21555SRichard Lowestructure (described below).
164bbf21555SRichard LoweThis
165bbf21555SRichard Lowe.Xr ioctl 2
166bbf21555SRichard Lowegets the controller's notion of the current geometry of the disk drive.
167bbf21555SRichard Lowe.It Dv DKIOCSGEOM
168bbf21555SRichard Lowe.Pp
169bbf21555SRichard LoweThe argument is a pointer to a
170bbf21555SRichard Lowe.Vt dk_geom
171bbf21555SRichard Lowestructure (described below).
172bbf21555SRichard LoweThis
173bbf21555SRichard Lowe.Xr ioctl 2
174bbf21555SRichard Lowesets the controller's notion of the geometry without changing the disk itself.
175bbf21555SRichard Lowe.It Dv DKIOCGVTOC
176bbf21555SRichard Lowe.Pp
177bbf21555SRichard LoweThe argument is a pointer to a
178bbf21555SRichard Lowe.Vt vtoc
179bbf21555SRichard Lowestructure (described below).
180bbf21555SRichard LoweThis
181bbf21555SRichard Lowe.Xr ioctl 2
182bbf21555SRichard Lowereturns the device's current volume table of contents (VTOC).
183bbf21555SRichard LoweFor disks larger than 1TB,
184bbf21555SRichard Lowe.Dv DKIOCGEXTVTOC
185bbf21555SRichard Lowemust be used instead.
186bbf21555SRichard Lowe.It Dv DKIOCSVTOC
187bbf21555SRichard Lowe.Pp
188bbf21555SRichard LoweThe argument is a pointer to a
189bbf21555SRichard Lowe.Vt vtoc
190bbf21555SRichard Lowestructure (described below).
191bbf21555SRichard LoweThis
192bbf21555SRichard Lowe.Xr ioctl 2
193bbf21555SRichard Lowechanges the VTOC associated with the device.
194bbf21555SRichard LoweFor disks larger than 1TB,
195bbf21555SRichard Lowe.Dv DKIOCSEXTVTOC
196bbf21555SRichard Lowemust be used instead.
197bbf21555SRichard Lowe.Bd -literal -offset 2n
198bbf21555SRichard Lowestruct partition {
199bbf21555SRichard Lowe    ushort_t      p_tag;         /* ID tag of partition */
200bbf21555SRichard Lowe    ushort_t      p_flag;        /* permission flags */
201bbf21555SRichard Lowe    daddr_t       p_start;       /* start sector of partition */
202bbf21555SRichard Lowe    long          p_size;        /* # of blocks in partition */
203bbf21555SRichard Lowe};
204bbf21555SRichard Lowe.Ed
205bbf21555SRichard Lowe.Pp
206bbf21555SRichard LoweIf
207bbf21555SRichard Lowe.Dv DKIOCSVTOC
208bbf21555SRichard Loweis used with a floppy diskette, the
209bbf21555SRichard Lowe.Fa p_start
210bbf21555SRichard Lowefield must be the first sector of a cylinder.
211bbf21555SRichard LoweTo compute the number of sectors per
212bbf21555SRichard Lowecylinder, multiply the number of heads by the number of sectors per track.
213bbf21555SRichard Lowe.Bd -literal -offset 2n
214bbf21555SRichard Lowestruct vtoc {
215bbf21555SRichard Lowe    unsigned long     v_bootinfo[3];        /* info needed by mboot */
216bbf21555SRichard Lowe                                            /* (unsupported) */
217bbf21555SRichard Lowe    unsigned long     v_sanity;             /* to verify vtoc */
218bbf21555SRichard Lowe                                            /* sanity */
219bbf21555SRichard Lowe    unsigned long     v_version;            /* layout version */
220bbf21555SRichard Lowe    char              v_volume[LEN_DKL_VVOL]; /* volume name */
221bbf21555SRichard Lowe    ushort_t          v_sectorsz;           /* sector size in bytes */
222bbf21555SRichard Lowe    ushort_t          v_nparts;             /* number of partitions */
223bbf21555SRichard Lowe    unsigned long     v_reserved[10];       /* free space */
224bbf21555SRichard Lowe    struct partition  v_part[V_NUMPAR];     /* partition headers */
225bbf21555SRichard Lowe    time_t            timestamp[V_NUMPAR];  /* partition timestamp */
226bbf21555SRichard Lowe                                            /* (unsupported) */
227bbf21555SRichard Lowe    char              v_asciilabel[LEN_DKL_ASCII]; /* compatibility */
228bbf21555SRichard Lowe};
229bbf21555SRichard Lowe
230bbf21555SRichard Lowe/*
231bbf21555SRichard Lowe * Partition permission flags
232bbf21555SRichard Lowe */
233bbf21555SRichard Lowe#define V_UNMNT      0x01    /* Unmountable partition */
234bbf21555SRichard Lowe#define V_RONLY      0x10    /* Read only */
235bbf21555SRichard Lowe
236bbf21555SRichard Lowe/*
237bbf21555SRichard Lowe * Partition identification tags
238bbf21555SRichard Lowe */
239bbf21555SRichard Lowe#define V_UNASSIGNED   0x00  /* unassigned partition */
240bbf21555SRichard Lowe#define V_BOOT         0x01  /* Boot partition */
241bbf21555SRichard Lowe#define V_ROOT         0x02  /* Root filesystem */
242bbf21555SRichard Lowe#define V_SWAP         0x03  /* Swap filesystem */
243bbf21555SRichard Lowe#define V_USR          0x04  /* Usr filesystem */
244bbf21555SRichard Lowe#define V_BACKUP       0x05  /* full disk */
245bbf21555SRichard Lowe#define V_VAR          0x07  /* Var partition */
246bbf21555SRichard Lowe#define V_HOME         0x08  /* Home partition */
247bbf21555SRichard Lowe#define V_ALTSCTR      0x09  /* Alternate sector partition */
248bbf21555SRichard Lowe.Ed
249bbf21555SRichard Lowe.It Dv DKIOCGEXTVTOC
250bbf21555SRichard Lowe.Pp
251bbf21555SRichard LoweThe argument is a pointer to an
252bbf21555SRichard Lowe.Vt extvtoc
253bbf21555SRichard Lowestructure (described below).
254bbf21555SRichard LoweThis ioctl returns the device's current volume table of contents (VTOC).
255bbf21555SRichard LoweVTOC is extended to support a disk up to 2TB in size.
256bbf21555SRichard LoweFor disks larger than 1TB this ioctl must be used instead of
257bbf21555SRichard Lowe.Dv DKIOCGVTOC .
258bbf21555SRichard Lowe.It Dv DKIOCSEXTVTOC
259bbf21555SRichard Lowe.Pp
260bbf21555SRichard LoweThe argument is a pointer to an
261bbf21555SRichard Lowe.Vt extvtoc
262bbf21555SRichard Lowestructure (described below).
263bbf21555SRichard LoweThis ioctl changes the VTOC associated with the device.
264bbf21555SRichard LoweVTOC is extended to support a disk up to 2TB in size.
265bbf21555SRichard LoweFor disks larger than 1TB this ioctl must be used instead of
266bbf21555SRichard Lowe.Vt DKIOCSVTOC .
267bbf21555SRichard Lowe.Bd -literal -offset 2n
268bbf21555SRichard Lowestruct extpartition {
269bbf21555SRichard Lowe    ushort_t p_tag;         /* ID tag of partition */
270bbf21555SRichard Lowe    ushort_t p_flag;        /* permission flags */
271bbf21555SRichard Lowe    ushort_t p_pad[2];      /* reserved */
272bbf21555SRichard Lowe    diskaddr_t p_start;     /* start sector no of partition */
273bbf21555SRichard Lowe    diskaddr_t p_size;      /* # of blocks in partition */
274bbf21555SRichard Lowe};
275bbf21555SRichard Lowe
276bbf21555SRichard Lowestruct extvtoc {
277bbf21555SRichard Lowe    uint64_t   v_bootinfo[3]; /* info needed by mboot (unsupported) */
278bbf21555SRichard Lowe    uint64_t   v_sanity;      /* to verify vtoc sanity */
279bbf21555SRichard Lowe    uint64_t   v_version;     /* layout version */
280bbf21555SRichard Lowe    char    v_volume[LEN_DKL_VVOL]; /* volume name */
281bbf21555SRichard Lowe    ushort_t   v_sectorsz;    /* sector size in bytes */
282bbf21555SRichard Lowe    ushort_t   v_nparts;      /* number of partitions */
283bbf21555SRichard Lowe    ushort_t   pad[2];
284bbf21555SRichard Lowe    uint64_t   v_reserved[10];
285bbf21555SRichard Lowe    struct extpartition v_part[V_NUMPAR]; /* partition headers */
286bbf21555SRichard Lowe    uint64_t timestamp[V_NUMPAR]; /* partition timestamp */
287bbf21555SRichard Lowe                                  /* (unsupported) */
288bbf21555SRichard Lowe    char    v_asciilabel[LEN_DKL_ASCII];    /* for compatibility */
289bbf21555SRichard Lowe};
290bbf21555SRichard Lowe.Ed
291bbf21555SRichard Lowe.Pp
292bbf21555SRichard LowePartition permissions flags and identification tags
293bbf21555SRichard Loweare defined the same as vtoc structure.
294bbf21555SRichard Lowe.It Dv DKIOCEJECT
295bbf21555SRichard Lowe.Pp
296bbf21555SRichard LoweIf the drive supports removable media, this
297bbf21555SRichard Lowe.Xr ioctl 2
298bbf21555SRichard Lowerequests the disk drive to eject its disk.
299bbf21555SRichard Lowe.It Dv DKIOCREMOVABLE
300bbf21555SRichard Lowe.Pp
301bbf21555SRichard LoweThe argument to this
302bbf21555SRichard Lowe.Xr ioctl 2
303bbf21555SRichard Loweis an integer.
304bbf21555SRichard LoweAfter successful completion, this
305bbf21555SRichard Lowe.Xr ioctl 2
306bbf21555SRichard Lowesets that integer to a non-zero value if the drive in
307bbf21555SRichard Lowequestion has removable media.
308bbf21555SRichard LoweIf the media is not removable, the integer is set to
309bbf21555SRichard Lowe.Sy 0 .
310bbf21555SRichard Lowe.It Dv DKIOCHOTPLUGGABLE
311bbf21555SRichard Lowe.Pp
312bbf21555SRichard LoweThe argument to this
313bbf21555SRichard Lowe.Xr ioctl 2
314bbf21555SRichard Loweis an integer.
315bbf21555SRichard LoweAfter successful completion, this
316bbf21555SRichard Lowe.Xr ioctl 2
317bbf21555SRichard Lowesets that integer to a non-zero value if the drive in question is hotpluggable.
318bbf21555SRichard LoweIf the media is not hotpluggable, the integer is set to 0.
319bbf21555SRichard Lowe.It Dv DKIOCSTATE
320bbf21555SRichard Lowe.Pp
321bbf21555SRichard LoweThis
322bbf21555SRichard Lowe.Xr ioctl 2
323bbf21555SRichard Loweblocks until the state of the drive, inserted or ejected, is changed.
324bbf21555SRichard LoweThe argument is a pointer to a
325bbf21555SRichard Lowe.Vt dkio_state ,
326bbf21555SRichard Loweenum, whose possible enumerations are listed below.
327bbf21555SRichard LoweThe initial value should be either the last
328bbf21555SRichard Lowereported state of the drive, or
329bbf21555SRichard Lowe.Dv DKIO_NONE .
330bbf21555SRichard LoweUpon return, the enum pointed
331bbf21555SRichard Loweto by the argument is updated with the current state of the drive.
332bbf21555SRichard Lowe.Bd -literal -offset 2n
333bbf21555SRichard Loweenum dkio_state {
334bbf21555SRichard Lowe    DKIO_NONE,          /* Return disk's current state */
335bbf21555SRichard Lowe    DKIO_EJECTED,       /* Disk state is 'ejected' */
336bbf21555SRichard Lowe    DKIO_INSERTED       /* Disk state is 'inserted' */
337bbf21555SRichard Lowe};
338bbf21555SRichard Lowe.Ed
339bbf21555SRichard Lowe.It Dv DKIOCLOCK
340bbf21555SRichard Lowe.Pp
341bbf21555SRichard LoweFor devices with removable media, this
342bbf21555SRichard Lowe.Xr ioctl 2
343bbf21555SRichard Lowerequests the disk drive to lock the door.
344bbf21555SRichard Lowe.It Dv DKIOCUNLOCK
345bbf21555SRichard Lowe.Pp
346bbf21555SRichard LoweFor devices with removable media, this
347bbf21555SRichard Lowe.Xr ioctl 2
348bbf21555SRichard Lowerequests the disk drive to unlock the door.
349bbf21555SRichard Lowe.It Dv DKIOCGMEDIAINFO
350bbf21555SRichard Lowe.Pp
351bbf21555SRichard LoweThe argument to this
352bbf21555SRichard Lowe.Xr ioctl 2
353bbf21555SRichard Loweis a pointer to a
354bbf21555SRichard Lowe.Vt dk_minfo
355bbf21555SRichard Lowestructure.
356bbf21555SRichard LoweThe structure indicates the type of media or the command set profile used by
357bbf21555SRichard Lowethe drive to operate on the media.
358bbf21555SRichard LoweThe
359bbf21555SRichard Lowe.Vt dk_minfo
360bbf21555SRichard Lowestructure also indicates the logical media block size the drive uses as the
361bbf21555SRichard Lowebasic unit block size of operation and the raw formatted capacity of the media
362bbf21555SRichard Lowein number of logical blocks.
363bbf21555SRichard Lowe.It Dv DKIOCGMEDIAINFOEXT
364bbf21555SRichard Lowe.Pp
365bbf21555SRichard LoweThe argument to this
366bbf21555SRichard Lowe.Xr ioctl 2
367bbf21555SRichard Loweis a pointer to a
368bbf21555SRichard Lowe.Vt dk_minfo_ext
369bbf21555SRichard Lowestructure.
370bbf21555SRichard LoweThe structure indicates the type of media or the command set profile
371bbf21555SRichard Loweused by the drive to operate on the media.
372bbf21555SRichard LoweThe
373bbf21555SRichard Lowe.Vt dk_minfo_ext
374bbf21555SRichard Lowestructure
375bbf21555SRichard Lowealso indicates the logical media block size the drive uses as the basic unit
376bbf21555SRichard Loweblock size of operation, the raw formatted capacity of the media in number of
377bbf21555SRichard Lowelogical blocks and the physical block size of the media.
378bbf21555SRichard Lowe.Bd -literal -offset 2n
379bbf21555SRichard Lowe/*
380bbf21555SRichard Lowe * Used for media info or profile info
381bbf21555SRichard Lowe */
382bbf21555SRichard Lowestruct dk_minfo {
383bbf21555SRichard Lowe    uint_t dki_media_type;   /* Media type or profile info */
384bbf21555SRichard Lowe    uint_t dki_lbsize;       /* Logical blocksize of media */
385bbf21555SRichard Lowe    diskaddr_t dki_capacity; /* Capacity as # of dki_lbsize blks */
386bbf21555SRichard Lowe};
387bbf21555SRichard Lowe
388bbf21555SRichard Lowe/*
389bbf21555SRichard Lowe * Used for media info or profile info and physical blocksize
390bbf21555SRichard Lowe */
391bbf21555SRichard Lowestruct dk_minfo_ext {
392bbf21555SRichard Lowe    uint_t dki_media_type; /* Media type or profile info */
393bbf21555SRichard Lowe    uint_t dki_lbsize; /* Logical blocksize of media */
394bbf21555SRichard Lowe    diskaddr_t dki_capacity; /* Capacity as # of dki_lbsize blks */
395bbf21555SRichard Lowe    uint_t dki_pbsize; /* Physical blocksize of media */
396bbf21555SRichard Lowe};
397bbf21555SRichard Lowe
398bbf21555SRichard Lowe
399bbf21555SRichard Lowe/*
400bbf21555SRichard Lowe * Media types or profiles known
401bbf21555SRichard Lowe */
402bbf21555SRichard Lowe#define DK_UNKNOWN         0x00    /* Media inserted - type unknown */
403bbf21555SRichard Lowe
404bbf21555SRichard Lowe/*
405bbf21555SRichard Lowe * SFF 8090 Specification Version 3, media types 0x01 - 0xfffe are
406bbf21555SRichard Lowe * retained to maintain compatibility with SFF8090.  The following
407bbf21555SRichard Lowe * define the optical media type.
408bbf21555SRichard Lowe */
409bbf21555SRichard Lowe#define DK_MO_ERASABLE     0x03 /* MO Erasable */
410bbf21555SRichard Lowe#define DK_MO_WRITEONCE    0x04 /* MO Write once */
411bbf21555SRichard Lowe#define DK_AS_MO           0x05 /* AS MO */
412bbf21555SRichard Lowe#define DK_CDROM           0x08 /* CDROM */
413bbf21555SRichard Lowe#define DK_CDR             0x09 /* CD-R */
414bbf21555SRichard Lowe#define DK_CDRW            0x0A /* CD-RW */
415bbf21555SRichard Lowe#define DK_DVDROM          0x10 /* DVD-ROM */
416bbf21555SRichard Lowe#define DK_DVDR            0x11 /* DVD-R */
417bbf21555SRichard Lowe#define DK_DVDRAM          0x12 /* DVD_RAM or DVD-RW */
418bbf21555SRichard Lowe
419bbf21555SRichard Lowe/*
420bbf21555SRichard Lowe * Media types for other rewritable magnetic media
421bbf21555SRichard Lowe */
422bbf21555SRichard Lowe#define DK_FIXED_DISK      0x10001 /* Fixed disk SCSI or otherwise */
423bbf21555SRichard Lowe#define DK_FLOPPY          0x10002 /* Floppy media */
424bbf21555SRichard Lowe#define DK_ZIP             0x10003 /* IOMEGA ZIP media */
425bbf21555SRichard Lowe#define DK_JAZ             0x10004 /* IOMEGA JAZ media */
426bbf21555SRichard Lowe.Ed
427bbf21555SRichard Lowe.Pp
428bbf21555SRichard LoweIf the media exists and the host can obtain a current profile list, the command
429bbf21555SRichard Lowesucceeds and returns the
430bbf21555SRichard Lowe.Vt dk_minfo
431bbf21555SRichard Lowestructure with data representing that media.
432bbf21555SRichard Lowe.Pp
433bbf21555SRichard LoweIf there is no media in the drive, the command fails and the host returns an
434bbf21555SRichard Lowe.Er ENXIO
435bbf21555SRichard Loweerror, indicating that it cannot gather the information requested.
436bbf21555SRichard Lowe.Pp
437bbf21555SRichard LoweIf the profile list is not available, the host attempts to identify the
438bbf21555SRichard Lowemedia-type based on the available information.
439bbf21555SRichard Lowe.Pp
440bbf21555SRichard LoweIf identification is not possible, the host returns media type
441bbf21555SRichard Lowe.Dv DK_UNKNOWN .
442bbf21555SRichard LoweSee
443bbf21555SRichard Lowe.Sx NOTES
444bbf21555SRichard Lowefor blocksize usage and capacity information.
445bbf21555SRichard Lowe.It Dv DKIOCSMBOOT
446bbf21555SRichard Lowe.Pp
447bbf21555SRichard LoweThe argument is a pointer to struct
448bbf21555SRichard Lowe.Vt mboot .
449bbf21555SRichard Lowe.Pp
450bbf21555SRichard LoweCopies the
451bbf21555SRichard Lowe.Vt mboot
452bbf21555SRichard Loweinformation supplied in the argument to the absolute sector 0 of the device.
453bbf21555SRichard LowePrior to copying the information, this
454bbf21555SRichard Lowe.Xr ioctl 2
455bbf21555SRichard Loweperforms the following checks on the
456bbf21555SRichard Lowe.Vt mboot
457bbf21555SRichard Lowedata:
458bbf21555SRichard Lowe.Bl -bullet -offset indent
459bbf21555SRichard Lowe.It
460bbf21555SRichard LoweEnsures that the signature field is set to 0xAA55.
461bbf21555SRichard Lowe.It
462bbf21555SRichard LoweEnsures that partitions do not overlap.
463bbf21555SRichard Lowe.It
464bbf21555SRichard LoweOn SPARC platforms, determines if the device is a removable media.
465bbf21555SRichard Lowe.El
466bbf21555SRichard Lowe.Pp
467bbf21555SRichard LoweIf the above verification fails,
468bbf21555SRichard Lowe.Va errno
469bbf21555SRichard Loweis set to
470bbf21555SRichard Lowe.Er EINVAL
471bbf21555SRichard Loweand the
472bbf21555SRichard Lowe.Xr ioctl 2
473bbf21555SRichard Lowecommand fails.
474bbf21555SRichard Lowe.Pp
475bbf21555SRichard Lowex86 Platforms \(em Upon successful write of
476bbf21555SRichard Lowe.Vt mboot ,
477bbf21555SRichard Lowethe partition map structure maintained in the driver is updated.
478bbf21555SRichard LoweIf the new Solaris partition is
479bbf21555SRichard Lowedifferent from the previous one, the internal VTOC table maintained in the
480bbf21555SRichard Lowedriver is set as follows:
481bbf21555SRichard Lowe.Pp
482bbf21555SRichard LoweIf
483bbf21555SRichard Lowe.Dv _SUNOS_VTOC_8
484bbf21555SRichard Loweis defined:
485bbf21555SRichard Lowe.Bd -unfilled -offset 4n
486bbf21555SRichard LowePartition: 0 Start: 0 Capacity = Capacity of device.
487bbf21555SRichard LowePartition: 2 Start: 0 Capacity = Capacity of device.
488bbf21555SRichard Lowe.Ed
489bbf21555SRichard Lowe.Pp
490bbf21555SRichard LoweIf
491bbf21555SRichard Lowe.Dv _SUNOS_VTOC_16
492bbf21555SRichard Loweis defined:
493bbf21555SRichard Lowe.Bd -unfilled -offset 4n
494bbf21555SRichard LowePartition: 2 Start: 0 Size = Size specified in mboot - 2 cylinders.
495bbf21555SRichard LowePartition: 8 Start: 0 Size = Sectors/cylinder.
496bbf21555SRichard LowePartition: 9 Start: Sectors/cylinder  Size = 2 * sectors/cylinder
497bbf21555SRichard Lowe.Ed
498bbf21555SRichard Lowe.Pp
499bbf21555SRichard LoweTo determine if the Solaris partition has changed:
500bbf21555SRichard Lowe.Bd -offset 4n -ragged
501bbf21555SRichard LoweIf either offset or the size of the Solaris partition is different from the
502bbf21555SRichard Loweprevious one then it shall be deemed to have changed.
503bbf21555SRichard LoweIn all other cases, the
504bbf21555SRichard Loweinternal VTOC info remains as before.
505bbf21555SRichard Lowe.Ed
506bbf21555SRichard Lowe.Pp
507bbf21555SRichard LoweSPARC Platforms \(em The VTOC label and
508bbf21555SRichard Lowe.Vt mboot
509bbf21555SRichard Loweboth occupy the same location, namely sector 0.
510bbf21555SRichard LoweAs a result, following the successful write of
511bbf21555SRichard Lowe.Vt mboot
512bbf21555SRichard Loweinfo, the internal VTOC table maintained in the driver is set as follows:
513bbf21555SRichard Lowe.Bd -unfilled -offset 4n
514bbf21555SRichard LowePartition: 0  Start: 0  Size = Capacity of device.
515bbf21555SRichard LowePartition: 2  Start: 0  Size = Capacity of device.
516bbf21555SRichard Lowe.Ed
517bbf21555SRichard Lowe.Pp
518bbf21555SRichard LoweSee the
519bbf21555SRichard Lowe.Sx NOTES
520bbf21555SRichard Lowesection for usage of
521bbf21555SRichard Lowe.Dv DKIOCSMBOOT
522bbf21555SRichard Lowewhen modifying Solaris partitions.
523bbf21555SRichard Lowe.It Dv DKIOCGETVOLCAP
524bbf21555SRichard Lowe.Pp
525bbf21555SRichard LoweThis ioctl provides information and status of available capabilities.
526bbf21555SRichard Lowe.Fa vc_info
527bbf21555SRichard Loweis a bitmap and the valid flag values are:
528bbf21555SRichard Lowe.Pp
529bbf21555SRichard Lowe.Bl -tag -width DKV_ABR_CAP -compact -offset 2n
530bbf21555SRichard Lowe.It Dv DKV_ABR_CAP
531bbf21555SRichard LoweCapable of application-based recovery
532bbf21555SRichard Lowe.It Dv DKV_DMR_CAP
533bbf21555SRichard LoweAbility to read specific copy of data when multiple copies exist.
534bbf21555SRichard LoweFor example, in a two way mirror, this ioctl is used to read each
535bbf21555SRichard Loweside of the mirror.
536bbf21555SRichard Lowe.El
537bbf21555SRichard Lowe.Pp
538bbf21555SRichard Lowe.Fa vc_set
539bbf21555SRichard Loweis a bitmap and the valid flag values are:
540bbf21555SRichard Lowe.Pp
541bbf21555SRichard Lowe.Bl -tag -width DKV_ABR_CAP -compact -offset 2n
542bbf21555SRichard Lowe.It Dv DKV_ABR_CAP
543bbf21555SRichard LoweThis flag is set if ABR has been set on a device that supports ABR functionality.
544bbf21555SRichard Lowe.It Dv DKV_DMR_CAP
545bbf21555SRichard LoweDirected read has been enabled.
546bbf21555SRichard Lowe.El
547bbf21555SRichard Lowe.Pp
548bbf21555SRichard LoweThese capabilities are not required to be persistent across a system reboot and
549bbf21555SRichard Lowetheir persistence depends upon the implementation.
550bbf21555SRichard LoweFor example, if the ABR
551bbf21555SRichard Lowecapability for a DRL mirror simply clears the dirty-region list and
552bbf21555SRichard Lowesubsequently stops updating this list, there is no reason for persistence
553bbf21555SRichard Lowebecause the VM recovery is a no-op.
554bbf21555SRichard LoweConversely, if the ABR capability is
555bbf21555SRichard Loweapplied to a non-DRL mirror to indicate that the VM should not perform a full
556bbf21555SRichard Lowerecovery of the mirror following a system crash, the capability must be
557bbf21555SRichard Lowepersistent so that the VM know whether or not to perform recovery.
558bbf21555SRichard Lowe.Pp
559bbf21555SRichard LoweReturn Errors:
560bbf21555SRichard Lowe.Pp
561bbf21555SRichard Lowe.Bl -tag -width ENOTSUP -compact -offset 2n
562bbf21555SRichard Lowe.It Er EINVAL
563bbf21555SRichard LoweInvalid device for this operation.
564bbf21555SRichard Lowe.It Er ENOTSUP
565bbf21555SRichard LoweFunctionality that is attempted to be set is not supported.
566bbf21555SRichard Lowe.El
567bbf21555SRichard Lowe.It Dv DKIOCSETVOLCAP
568bbf21555SRichard Lowe.Pp
569bbf21555SRichard LoweThis ioctl sets the available capabilities for the device.
570bbf21555SRichard LoweIf a capability flag
571bbf21555SRichard Loweis not set in
572bbf21555SRichard Lowe.Fa vc_set ,
573bbf21555SRichard Lowethat capability is cleared.
574bbf21555SRichard Lowe.Pp
575bbf21555SRichard Lowe.Fa vc_info
576bbf21555SRichard Loweflags are ignored.
577bbf21555SRichard Lowe.Pp
578bbf21555SRichard Lowe.Fa vc_set
579bbf21555SRichard Lowevalid flags are:
580bbf21555SRichard Lowe.Pp
581bbf21555SRichard Lowe.Bl -tag -width DKV_ABR_CAP -compact -offset 2n
582bbf21555SRichard Lowe.It Dv DKV_ABR_CAP
583bbf21555SRichard LoweFlag to set application-based recovery.
584bbf21555SRichard LoweA device can successfully support ABR only if it is capable.
585bbf21555SRichard Lowe.It Dv DKV_DMR_CAP
586bbf21555SRichard LoweFlag to set directed read.
587bbf21555SRichard Lowe.El
588bbf21555SRichard Lowe.It Dv DKIODMR
589bbf21555SRichard Lowe.Pp
590bbf21555SRichard Lowe.Ft int
591bbf21555SRichard Lowe.Fo ioctl
592bbf21555SRichard Lowe.Fa int ,
593bbf21555SRichard Lowe.\" This could be .Fa as well -- but mandoc doesn't seem to allow both
594bbf21555SRichard Lowe.Dv DKIODMR ,
595bbf21555SRichard Lowe.Fa "vol_directed_rd *"
596bbf21555SRichard Lowe.Fc
597bbf21555SRichard Lowe.Pp
598bbf21555SRichard LoweThis ioctl allows highly available applications to perform round-robin reads
599bbf21555SRichard Lowefrom the underlying devices of a replicated device.
600bbf21555SRichard Lowe.Pp
601bbf21555SRichard Lowe.Bl -tag -width vdr_bytesread -offset 2n -compact
602bbf21555SRichard Lowe.It Fa vdr_offset
603bbf21555SRichard LoweOffset at which the read should occur.
604bbf21555SRichard Lowe.It Fa vdr_nbytes
605bbf21555SRichard LoweNumber of bytes to be read
606bbf21555SRichard Lowe.It Fa vdr_bytesread
607bbf21555SRichard LoweNumber of bytes successfully read by the kernel.
608bbf21555SRichard Lowe.It Fa vdr_data
609bbf21555SRichard LowePointer to a user allocated buffer to return the data read
610bbf21555SRichard Lowe.It Fa vdr_side
611bbf21555SRichard LoweSide to be read.
612bbf21555SRichard LoweInitialized to
613bbf21555SRichard Lowe.Dv DKV_SIDE_INIT
614bbf21555SRichard Lowe.It Fa vdr_side_name
615bbf21555SRichard LoweThe volume name that has been read.
616bbf21555SRichard Lowe.El
617bbf21555SRichard Lowe.Pp
618bbf21555SRichard LoweValid
619bbf21555SRichard Lowe.Fa vdr_flags
620bbf21555SRichard Loweare:
621bbf21555SRichard Lowe.Pp
622bbf21555SRichard Lowe.Bl -tag -width DKV_DMR_NEXT_SIDE -offset 2n -compact
623bbf21555SRichard Lowe.It Dv DKV_DMR_NEXT_SIDE
624bbf21555SRichard LoweSet by user
625bbf21555SRichard Lowe.It Dv DKV_DMR_DONE
626bbf21555SRichard LoweReturn value
627bbf21555SRichard Lowe.It Dv DKV_DMR_ERROR
628bbf21555SRichard LoweReturn value
629bbf21555SRichard Lowe.It Dv DKV_DMR_SUCCESS
630bbf21555SRichard LoweReturn value
631bbf21555SRichard Lowe.It Dv DKV_DMR_SHORT
632bbf21555SRichard LoweReturn value
633bbf21555SRichard Lowe.El
634bbf21555SRichard Lowe.Pp
635bbf21555SRichard LoweThe calling sequence is as follows: The caller sets the
636bbf21555SRichard Lowe.Fa vdr_flags
637bbf21555SRichard Loweto
638bbf21555SRichard Lowe.Dv DK_DMR_NEXT_SIDE
639bbf21555SRichard Loweand
640bbf21555SRichard Lowe.Fa vdr_side
641bbf21555SRichard Loweto
642bbf21555SRichard Lowe.Dv DKV_SIDE_INIT
643bbf21555SRichard Loweat the start.
644bbf21555SRichard LoweSubsequent calls should be made without any changes to these values.
645bbf21555SRichard LoweIf they are changed the results of the ioctl are indeterminate.
646bbf21555SRichard Lowe.Pp
647bbf21555SRichard LoweWhen
648bbf21555SRichard Lowe.Dv DKV_SIDE_INIT
649bbf21555SRichard Loweis set, the call results in the kernel reading from the first side.
650bbf21555SRichard LoweThe kernel updates
651bbf21555SRichard Lowe.Fa vdr_side
652bbf21555SRichard Loweto indicate the side that was read, and
653bbf21555SRichard Lowe.Fa vdr_side_name
654bbf21555SRichard Loweto contain the name of that side.
655bbf21555SRichard Lowe.Fa vdr_data
656bbf21555SRichard Lowecontains the data that was read.
657bbf21555SRichard LoweTherefore to perform a round-robin read all of
658bbf21555SRichard Lowethe valid sides, there is no need for the caller to change the contents of
659bbf21555SRichard Lowe.Fa vdr_side .
660bbf21555SRichard Lowe.Pp
661bbf21555SRichard LoweSubsequent
662bbf21555SRichard Lowe.Xr ioctl 2
663bbf21555SRichard Lowecalls result in reads from the next valid side until all valid
664bbf21555SRichard Lowesides have been read.
665bbf21555SRichard LoweOn success, the kernel sets
666bbf21555SRichard Lowe.Dv DKV_DMR_SUCCESS .
667bbf21555SRichard LoweThe following table shows the values of
668bbf21555SRichard Lowe.Fa vdr_flags
669bbf21555SRichard Lowethat are returned when an error occurs:
670bbf21555SRichard Lowe.Bl -column DKV_DMR_SHORT DKV_SIDE_INIT "Bytes requested cannot" -offset 2n
671bbf21555SRichard Lowe.It Fa vda_flags Ta Fa vdr_side Ta Notes
672bbf21555SRichard Lowe.It Dv DKV_DMR_ERROR Ta Dv DKV_SIDE_INIT Ta \&No valid side to read
673bbf21555SRichard Lowe.It Dv DKV_DMR_DONE Ta Not Init side Ta All valid sides read
674bbf21555SRichard Lowe.It Dv DKV_DMR_SHORT Ta Any value Ta Bytes requested cannot be read Fa vdr_bytesread No set to bytes actually read
675bbf21555SRichard Lowe.El
676bbf21555SRichard LoweTypical code fragment:
677bbf21555SRichard Lowe.Bd -literal -offset 2n
678bbf21555SRichard Loweenable->vc_set |= DKV_ABR_SET;
679bbf21555SRichard Loweretval = ioctl(filedes, DKIOSETVOLCAP, enable);
680bbf21555SRichard Loweif (retval != EINVAL || retval != ENOTSUP) {
681bbf21555SRichard Lowe        if (info->vc_set & DKV_DMR_SET) {
682bbf21555SRichard Lowe                dr->vdr_flags |= DKV_DMR_NEXT_SIDE;
683bbf21555SRichard Lowe                dr->vdr_side = DKV_SIDE_INIT;
684bbf21555SRichard Lowe                dr->vdr_nbytes = 1024;
685bbf21555SRichard Lowe                dr->vdr_offset = 0xff00;
686bbf21555SRichard Lowe                do {
687bbf21555SRichard Lowe                        rval = ioctl(fildes, DKIODMR, dr);
688bbf21555SRichard Lowe                        if (rval != EINVAL) {
689bbf21555SRichard Lowe                                /* Process data */
690bbf21555SRichard Lowe                        }
691bbf21555SRichard Lowe                } while (rval != EINVAL || dr->vdr_flags &
692bbf21555SRichard Lowe                    (DKV_DMR_DONE | DKV_DMR_ERROR | DKV_DMR_SHORT)
693bbf21555SRichard Lowe        }
694bbf21555SRichard Lowe}
695bbf21555SRichard Lowe.Ed
696bbf21555SRichard Lowe.El
697bbf21555SRichard Lowe.Ss "RETURN VALUES"
698bbf21555SRichard LoweUpon successful completion, the value returned is
699bbf21555SRichard Lowe.Sy 0 .
700bbf21555SRichard LoweOtherwise,
701bbf21555SRichard Lowe.Sy -1
702bbf21555SRichard Loweis returned and
703bbf21555SRichard Lowe.Va errno
704bbf21555SRichard Loweis set to indicate the error.
705bbf21555SRichard Lowe.Ss "x86 Only"
706bbf21555SRichard LoweThe following
707bbf21555SRichard Lowe.Xr ioctl 2
708bbf21555SRichard Lowerequests set and/or retrieve the current disk
709bbf21555SRichard Lowecontroller, partitions, or geometry information on the x86 architecture.
710bbf21555SRichard Lowe.Bl -tag -width 1n
711bbf21555SRichard Lowe.It Dv DKIOCG_PHYGEOM
712bbf21555SRichard Lowe.Pp
713bbf21555SRichard LoweThe argument is a pointer to a
714bbf21555SRichard Lowe.Vt dk_geom
715bbf21555SRichard Lowestructure (described below).
716bbf21555SRichard LoweThis
717bbf21555SRichard Lowe.Xr ioctl 2
718bbf21555SRichard Lowegets the driver's notion of the physical geometry of the disk drive.
719bbf21555SRichard LoweIt is functionally identical to the
720bbf21555SRichard Lowe.Dv DKIOCGGEOM
721bbf21555SRichard Lowe.Xr ioctl 2 .
722bbf21555SRichard Lowe.It Dv DKIOCG_VIRTGEOM
723bbf21555SRichard Lowe.Pp
724bbf21555SRichard LoweThe argument is a pointer to a
725bbf21555SRichard Lowe.Vt dk_geom
726bbf21555SRichard Lowestructure (described below).
727bbf21555SRichard LoweThis
728bbf21555SRichard Lowe.Xr ioctl 2
729bbf21555SRichard Lowegets the controller's (and hence the driver's) notion of the
730bbf21555SRichard Lowevirtual geometry of the disk drive.
731bbf21555SRichard LoweVirtual geometry is a view of the disk
732bbf21555SRichard Lowegeometry maintained by the firmware in a host bus adapter or disk controller.
733bbf21555SRichard LoweIf the disk is larger than 8 Gbytes, this ioctl fails because a CHS-based
734bbf21555SRichard Lowegeometry is not relevant or useful for this drive.
735bbf21555SRichard Lowe.Bd -literal -offset 2n
736bbf21555SRichard Lowe/*
737bbf21555SRichard Lowe * Definition of a disk's geometry
738bbf21555SRichard Lowe */
739bbf21555SRichard Lowestruct dk_geom {
740bbf21555SRichard Lowe    unsigned shor    dkg_ncyl;   /* # of data cylinders */
741bbf21555SRichard Lowe    unsigned shor    dkg_acyl;   /* # of alternate cylinders */
742bbf21555SRichard Lowe    unsigned short   dkg_bcyl;   /* cyl offset (for fixed head */
743bbf21555SRichard Lowe                                 /* area) */
744bbf21555SRichard Lowe    unsigned short   dkg_nhead;  /* # of heads */
745bbf21555SRichard Lowe    unsigned short   dkg_obs1;   /* obsolete */
746bbf21555SRichard Lowe    unsigned short   dkg_nsect;  /* # of sectors per track */
747bbf21555SRichard Lowe    unsigned short   dkg_intrlv; /* interleave factor */
748bbf21555SRichard Lowe    unsigned short   dkg_obs2;   /* obsolete */
749bbf21555SRichard Lowe    unsigned short   dkg_obs3;   /* obsolete */
750bbf21555SRichard Lowe    unsigned short   dkg_apc;    /* alternates per cylinder */
751bbf21555SRichard Lowe                                 /* (SCSI only) */
752bbf21555SRichard Lowe    unsigned short   dkg_rpm;    /* revolutions per min */
753bbf21555SRichard Lowe    unsigned short   dkg_pcyl;   /* # of physical cylinders */
754bbf21555SRichard Lowe    unsigned short   dkg_write_reinstruct; /* # sectors to skip, */
755bbf21555SRichard Lowe                                           /* writes */
756bbf21555SRichard Lowe    unsigned short   dkg_read_reinstruct;  /* # sectors to skip ,*/
757bbf21555SRichard Lowe                                           /* reads */
758bbf21555SRichard Lowe    unsigned short   dkg_extra[7]; /* for compatible expansion */
759bbf21555SRichard Lowe};
760bbf21555SRichard Lowe.Ed
761bbf21555SRichard Lowe.It Dv DKIOCADDBAD
762bbf21555SRichard Lowe.Pp
763bbf21555SRichard LoweThis
764bbf21555SRichard Lowe.Xr ioctl 2
765bbf21555SRichard Loweforces the driver to re-examine the alternates slice and
766bbf21555SRichard Lowerebuild the internal bad block map accordingly.
767bbf21555SRichard LoweIt should be used whenever the
768bbf21555SRichard Lowealternates slice is changed by any method other than the
769bbf21555SRichard Lowe.Xr addbadsec 8
770bbf21555SRichard Loweor
771bbf21555SRichard Lowe.Xr format 8
772bbf21555SRichard Loweutilities.
773bbf21555SRichard Lowe.Dv DKIOCADDBAD
774bbf21555SRichard Lowecan only be used for software
775bbf21555SRichard Loweremapping on
776bbf21555SRichard Lowe.Sy IDE
777bbf21555SRichard Lowedrives;
778bbf21555SRichard Lowe.Sy SCSI
779bbf21555SRichard Lowedrives use hardware remapping of alternate sectors.
780bbf21555SRichard Lowe.It Dv DKIOCPARTINFO
781bbf21555SRichard Lowe.Pp
782bbf21555SRichard LoweThe argument is a pointer to a
783bbf21555SRichard Lowe.Vt part_info
784bbf21555SRichard Lowestructure (described below).
785bbf21555SRichard LoweThis
786bbf21555SRichard Lowe.Xr ioctl 2
787bbf21555SRichard Lowegets the driver's notion of the size and extent of the
788bbf21555SRichard Lowepartition or slice indicated by the file descriptor argument.
789bbf21555SRichard Lowe.Bd -literal -offset 2n
790bbf21555SRichard Lowe/*
791bbf21555SRichard Lowe * Used by applications to get partition or slice information
792bbf21555SRichard Lowe */
793bbf21555SRichard Lowestruct part_info {
794bbf21555SRichard Lowe    daddr_t    p_start;
795bbf21555SRichard Lowe    int        p_length;
796bbf21555SRichard Lowe};
797bbf21555SRichard Lowe.Ed
798bbf21555SRichard Lowe.It Dv DKIOCEXTPARTINFO
799bbf21555SRichard Lowe.Pp
800bbf21555SRichard LoweThe argument is a pointer to an
801bbf21555SRichard Lowe.Vt extpart_info
802bbf21555SRichard Lowestructure (described below).
803bbf21555SRichard LoweThis ioctl gets the driver's notion of the size and extent of the partition or
804bbf21555SRichard Loweslice indicated by the file descriptor argument.
805bbf21555SRichard LoweOn disks larger than 1TB, this ioctl must be used instead of
806bbf21555SRichard Lowe.Dv DKIOCPARTINFO .
807bbf21555SRichard Lowe.Bd -literal -offset 2n
808bbf21555SRichard Lowe/*
809bbf21555SRichard Lowe * Used by applications to get partition or slice information
810bbf21555SRichard Lowe */
811bbf21555SRichard Lowestruct extpart_info {
812*899b7fc7SPeter Tribble    diskaddr_t       p_start;
813bbf21555SRichard Lowe    diskaddr_t       p_length;
814bbf21555SRichard Lowe};
815bbf21555SRichard Lowe.Ed
816bbf21555SRichard Lowe.It Dv DKIOCSETEXTPART
817bbf21555SRichard Lowe.Pp
818bbf21555SRichard LoweThis ioctl is used to update the in-memory copy of the logical drive
819bbf21555SRichard Loweinformation maintained by the driver.
820bbf21555SRichard LoweThe ioctl takes no arguments.
821bbf21555SRichard LoweIt causes a re-read of the partition information and recreation of minor nodes
822bbf21555SRichard Loweif required.
823bbf21555SRichard LowePrior to updating the data structures, the ioctl ensures that the partitions do
824bbf21555SRichard Lowenot overlap.
825bbf21555SRichard LoweDevice nodes are created only for valid partition entries.
826bbf21555SRichard LoweIf there is any change in the partition offset, size or ID from the previous
827bbf21555SRichard Loweread, the partition is deemed to have been changed and hence the device nodes
828bbf21555SRichard Loweare recreated.
829bbf21555SRichard LoweAny modification to any of the logical partitions results in the
830bbf21555SRichard Lowerecreation of all logical device nodes.
831bbf21555SRichard Lowe.El
832bbf21555SRichard Lowe.Sh SEE ALSO
833bbf21555SRichard Lowe.Xr ioctl 2 ,
834bbf21555SRichard Lowe.Xr cmdk 4D ,
835bbf21555SRichard Lowe.Xr sd 4D ,
836bbf21555SRichard Lowe.Xr cdio 4I ,
837bbf21555SRichard Lowe.Xr fdio 4I ,
838bbf21555SRichard Lowe.Xr hdio 4I ,
839bbf21555SRichard Lowe.Xr addbadsec 8 ,
840bbf21555SRichard Lowe.Xr fdisk 8 ,
841bbf21555SRichard Lowe.Xr format 8
842bbf21555SRichard Lowe.Sh NOTES
843bbf21555SRichard LoweBlocksize information provided in
844bbf21555SRichard Lowe.Dv DKIOCGMEDIAINFO
845bbf21555SRichard Loweis the size (in bytes) of the device's basic unit of operation and can differ
846bbf21555SRichard Lowefrom the blocksize that the Solaris operating environment exports to the user.
847bbf21555SRichard LoweCapacity information provided in the
848bbf21555SRichard Lowe.Dv DKIOCGMEDIAINFO
849bbf21555SRichard Loweare for reference only and you are advised to use the values returned by
850bbf21555SRichard Lowe.Dv DKIOCGGEOM
851bbf21555SRichard Loweor other appropriate
852bbf21555SRichard Lowe.Xr ioctl 2
853bbf21555SRichard Lowefor accessing data using the standard interfaces.
854bbf21555SRichard Lowe.Pp
855bbf21555SRichard LoweFor x86 only: If the
856bbf21555SRichard Lowe.Dv DKIOCSMBOOT
857bbf21555SRichard Lowecommand is used to modify the Solaris partitions, the VTOC information should
858bbf21555SRichard Lowealso be set appropriately to reflect the changes to partition.
859bbf21555SRichard LoweFailure to do so leads to unexpected results when the
860bbf21555SRichard Lowedevice is closed and reopened fresh at a later time.
861bbf21555SRichard LoweThis is because a default VTOC is assumed by driver when a Solaris partition
862bbf21555SRichard Loweis changed.
863bbf21555SRichard LoweThe default VTOC persists until the ioctl
864bbf21555SRichard Lowe.Dv DKIOCSVTOC
865bbf21555SRichard Loweis called to modify VTOC or the device is closed and reopened.
866bbf21555SRichard LoweAt that point, the old valid VTOC is read from
867bbf21555SRichard Lowethe disk if it is still available.
868