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