Print this page
10517 Convert dkio(7I) to mandoc
   1 DKIO(7I)                        Ioctl Requests                        DKIO(7I)
   2 
   3 
   4 
   5 NAME
   6        dkio - disk control operations
   7 
   8 SYNOPSIS
   9        #include <sys/dkio.h>
  10        #include <sys/vtoc.h>
  11 
  12 
  13 
  14 
  15 
  16 DESCRIPTION
  17        Disk drivers support a set of ioctl(2) requests for disk controller,
  18        geometry, and partition information. Basic to these ioctl() requests
  19        are the definitions in <sys/dkio.h>.
  20 
  21 IOCTLS
  22        The following ioctl() requests set and/or retrieve the current disk
  23        controller, partitions, or geometry information on all architectures:
  24 
  25        DKIOCINFO
  26 
  27            The argument is a pointer to a dk_cinfo structure (described
  28            below). This structure tells the controller-type and attributes
  29            regarding bad-block processing done on the controller.
  30 
  31 
  32          /*
  33           * Structures and definitions for disk I/O control commands
  34           */
  35          #define DK_DEVLEN 16   /* device name max length, */
  36                                 /* including unit # and NULL */

  37                                 /* Used for controller info */
  38          struct dk_cinfo {
  39               char      dki_cname[DK_DEVLEN];    /* controller name */
  40                                                  /* (no unit #) */
  41               ushort_t  dki_ctype;               /* controller type */
  42               ushort_t  dki_flags;               /* flags */
  43               ushort_t  dki_cnum;                /* controller number */
  44               uint_t    dki_addr;                /* controller address */
  45               uint_t    dki_space;               /* controller bus type */
  46               uint_t    dki_prio;                /* interrupt priority */
  47               uint_t    dki_vec;                 /* interrupt vector */
  48               char      dki_dname[DK_DEVLEN];    /* drive name (no unit #) */
  49               uint_t    dki_unit;                /* unit number */
  50               uint_t    dki_slave;               /* slave number */
  51               ushort_t  dki_partition;           /* partition number */
  52               ushort_t  dki_maxtransfer;         /* maximum transfer size */
  53                                                  /* in DEV_BSIZE */
  54 
  55               };

  56               /*
  57                * Controller types
  58                */
  59 
  60               #define DKC_UNKNOWN      0
  61               #define DKC_CDROM        1         /* CD-ROM, SCSI or other */
  62               #define DKC_WDC2880      2
  63               #define DKC_XXX_0        3         /* unassigned */
  64               #define DKC_XXX_1        4         /* unassigned */
  65               #define DKC_DSD5215      5
  66               #define DKC_ACB4000      7
  67               #define DKC_XXX_2        9         /* unassigned */
  68               #define DKC_NCRFLOPPY    10
  69               #define DKC_SMSFLOPPY    12
  70               #define DKC_SCSI_CCS     13        /* SCSI CCS compatible */
  71               #define DKC_INTEL82072   14        /* native floppy chip */
  72               #define DKC_INTEL82077   19        /* 82077 floppy disk */
  73                                                  /* controller */
  74               #define DKC_DIRECT       20        /* Intel direct attached */
  75                                                  /* device (IDE) */
  76               #define DKC_PCMCIA_MEM   21        /* PCMCIA memory disk-like */
  77                                                  /* type */
  78               #define DKC_PCMCIA_ATA   22        /* PCMCIA AT Attached type */
  79 
  80               /*
  81                * Sun reserves up through 1023
  82                */
  83 
  84               #define DKC_CUSTOMER_BASE  1024
  85 
  86               /*
  87                * Flags
  88                */
  89 
  90               #define DKI_BAD144       0x01          /* use  DEC  std  144  */
  91                                                      /* bad  sector fwding */
  92               #define DKI_MAPTRK       0x02          /* controller does */
  93                                                      /* track mapping */
  94               #define DKI_FMTTRK       0x04          /* formats only  full
  95                                                      /* track at a time*/
  96               #define DKI_FMTVOL       0x08          /* formats only full */
  97                                                      /* volume at a time*/
  98               #define DKI_FMTCYL       0x10          /* formats only full */
  99                                                      /* cylinders at a time*/
 100               #define DKI_HEXUNIT      0x20          /* unit number printed as */
 101                                                      /* 3 hexdigits */
 102               #define DKI_PCMCIA_PFD   0x40          /* PCMCIA pseudo-floppy */
 103                                                      /* memory card */
 104 
 105 
 106        DKIOCGAPART
 107 
 108            The argument is a pointer to a dk_allmap structure (described
 109            below).  This ioctl() gets the controller's notion of the current
 110            partition table for disk drive.
 111 
 112 
 113        DKIOCSAPART
 114 
 115            The argument is a pointer to a dk_allmap structure (described
 116            below).  This ioctl() sets the controller's notion of the partition
 117            table without changing the disk itself.
 118 
 119 
 120          /*
 121           * Partition map (part of dk_label)
 122           */ struct dk_map {

 123               daddr_t dkl_cylno;     /* starting cylinder */
 124               daddr_t dkl_nblk;      /* number of blocks */
 125               };

 126          /*
 127           * Used for all partitions
 128           */
 129          struct dk_allmap {
 130              struct dk_map    dka_map[NDKMAP];
 131          };
 132 
 133 
 134        DKIOCGGEOM
 135                      The argument is a pointer to a dk_geom structure
 136                      (described below). This ioctl() gets the controller's
 137                      notion of the current geometry of the disk drive.
 138 



 139 
 140        DKIOCSGEOM
 141                      The argument is a pointer to a dk_geom structure
 142                      (described below). This ioctl() sets the controller's
 143                      notion of the geometry without changing the disk itself.
 144 



 145 
 146        DKIOCGVTOC
 147                      The argument is a pointer to a vtoc structure (described
 148                      below). This ioctl() returns the device's current volume
 149                      table of contents (VTOC.) For disks larger than 1TB,
 150                      DKIOCGEXTVTOC must be used instead.
 151 



 152 
 153        DKIOCSVTOC
 154                      The argument is a pointer to a vtoc structure (described
 155                      below). This ioctl() changes the VTOC associated with the
 156                      device. For disks larger than 1TB, DKIOCSEXTVTOC must be
 157                      used instead.
 158 



 159 
 160          struct partition {
 161          ushort_t      p_tag;         /* ID tag of partition */
 162          ushort_t      p_flag;        /* permission flags */
 163          daddr_t       p_start;       /* start sector of partition */
 164          long          p_size;        /* # of blocks in partition */
 165          };
 166 




 167 
 168 
 169        If DKIOCSVTOC is used with a floppy diskette, the p_start field must be
 170        the first sector of a cylinder. To compute the number of sectors per
 171        cylinder, multiply the number of heads by the number of sectors per
 172        track.
 173 
 174          struct vtoc {
 175          unsigned long     v_bootinfo[3];               /* info needed by mboot
 176                                                         /* (unsupported)*/
 177          unsigned long     v_sanity;                    /* to verify vtoc */
 178                                                         /* sanity */
 179          unsigned long     v_version;                   /* layout version */
 180          char              v_volume[LEN_DKL_VVOL];      /* volume name */
 181          ushort_t          v_sectorsz;                  /* sector size in bytes*/
 182          ushort_t          v_nparts;                    /* number of partitions*/
 183          unsigned long     v_reserved[10];              /* free space */
 184          struct partition  v_part[V_NUMPAR];            /* partition headers */
 185          time_t            timestamp[V_NUMPAR];         /* partition timestamp */
 186                                                         /* (unsupported) */
 187          char              v_asciilabel[LEN_DKL_ASCII]; /* compatibility */
 188          };
 189 
 190          /*
 191          * Partition permission flags
 192          */
 193 
 194          #define V_UNMNT      0x01    /* Unmountable partition */
 195          #define V_RONLY      0x10    /* Read only */
 196 
 197          /*
 198          * Partition identification tags
 199          */
 200 
 201          #define V_UNASSIGNED   0x00  /* unassigned partition */
 202          #define V_BOOT         0x01  /* Boot partition */
 203          #define V_ROOT         0x02  /* Root filesystem */
 204          #define V_SWAP         0x03  /* Swap filesystem */
 205          #define V_USR          0x04  /* Usr filesystem */
 206          #define V_BACKUP       0x05  /* full disk */
 207          #define V_VAR          0x07  /* Var partition */
 208          #define V_HOME         0x08  /* Home partition */
 209          #define V_ALTSCTR      0x09  /* Alternate sector partition */
 210 
 211 
 212        DKIOCGEXTVTOC
 213 
 214            The argument is a pointer to an extvtoc structure (described
 215            below). This ioctl returns the device's current volume table of
 216            contents (VTOC). VTOC is extended to support a disk up to 2TB in
 217            size. For disks larger than 1TB this ioctl must be used instead of
 218            DKIOCGVTOC.
 219 
 220 
 221        DKIOCSEXTVTOC
 222 
 223            The argument is a pointer to an extvtoc structure (described
 224            below). This ioctl changes the VTOC associated with the device.
 225            VTOC is extended to support a disk up to 2TB in size. For disks
 226            larger than 1TB this ioctl must be used instead of DKIOCSVTOC.
 227 
 228              struct extpartition {
 229              ushort_t p_tag;         /* ID tag of partition */
 230              ushort_t p_flag;        /* permission flags */
 231              ushort_t p_pad[2];       /* reserved */
 232              diskaddr_t p_start;      /* start sector no of partition */
 233              diskaddr_t p_size;       /* # of blocks in partition */
 234              };
 235 
 236 
 237              struct extvtoc {
 238              uint64_t   v_bootinfo[3]; /* info needed by mboot (unsupported) */
 239              uint64_t   v_sanity;     /* to verify vtoc sanity */
 240              uint64_t   v_version;    /* layout version */
 241              char    v_volume[LEN_DKL_VVOL]; /* volume name */
 242              ushort_t   v_sectorsz;   /* sector size in bytes */
 243              ushort_t   v_nparts;     /* number of partitions */
 244              ushort_t   pad[2];
 245              uint64_t   v_reserved[10];
 246              struct extpartition v_part[V_NUMPAR]; /* partition headers */
 247              uint64_t timestamp[V_NUMPAR]; /* partition timestamp (unsupported)*/

 248              char    v_asciilabel[LEN_DKL_ASCII];    /* for compatibility */
 249              };
 250 
 251              Partition permissions flags and identification tags
 252              are defined the same as vtoc structure.
 253 
 254 
 255 
 256        DKIOCEJECT
 257 
 258            If the drive supports removable media, this ioctl() requests the
 259            disk drive to eject its disk.
 260 
 261 
 262        DKIOCREMOVABLE
 263 
 264            The argument to this ioctl() is an integer. After successful
 265            completion, this ioctl() sets that integer to a non-zero value if
 266            the drive in question has removable media. If the media is not
 267            removable, the integer is set to 0.
 268 
 269 
 270        DKIOCHOTPLUGGABLE
 271 
 272            The argument to this ioctl() is an integer. After successful
 273            completion, this ioctl() sets that integer to a non-zero value if
 274            the drive in question is hotpluggable. If the media is not
 275            hotpluggable, the integer is set to 0.
 276 
 277 
 278        DKIOCSTATE
 279 
 280            This ioctl() blocks until the state of the drive, inserted or
 281            ejected, is changed. The argument is a pointer to a dkio_state,
 282            enum, whose possible enumerations are listed below. The initial
 283            value should be either the last reported state of the drive, or
 284            DKIO_NONE. Upon return, the enum pointed to by the argument is
 285            updated with the current state of the drive.
 286 
 287              enum dkio_state {
 288              DKIO_NONE,          /* Return disk's current state */
 289              DKIO_EJECTED,       /* Disk state is 'ejected' */
 290              DKIO_INSERTED       /* Disk state is 'inserted' */
 291              };
 292 
 293 
 294 
 295        DKIOCLOCK
 296 
 297            For devices with removable media, this ioctl() requests the disk
 298            drive to lock the door.
 299 
 300 
 301        DKIOCUNLOCK
 302 
 303            For devices with removable media, this ioctl() requests the disk
 304            drive to unlock the door.
 305 
 306 
 307        DKIOCGMEDIAINFO
 308 
 309            The argument to this ioctl() is a pointer to a dk_minfo structure.
 310            The structure indicates the type of media or the command set
 311            profile used by the drive to operate on the media. The dk_minfo
 312            structure also indicates the logical media block size the drive
 313            uses as the basic unit block size of operation and the raw
 314            formatted capacity of the media in number of logical blocks.
 315 
 316 
 317        DKIOCGMEDIAINFOEXT
 318 
 319            The argument to this ioctl() is a pointer to a dk_minfo_ext
 320            structure. The structure indicates the type of media or the command
 321            set profile used by the drive to operate on the media. The
 322            dk_minfo_ext structure also indicates the logical media block size
 323            the drive uses as the basic unit block size of operation, the raw
 324            formatted capacity of the media in number of logical blocks and the
 325            physical block size of the media.
 326 
 327 
 328          /*
 329          * Used for media info or profile info
 330          */
 331          struct dk_minfo {
 332          uint_t dki_media_type; /* Media type or profile info */
 333          uint_t dki_lbsize; /* Logical blocksize of media */
 334          diskaddr_t dki_capacity; /* Capacity as # of dki_lbsize blks */
 335          };
 336 
 337          /*
 338          * Used for media info or profile info and physical blocksize
 339          */
 340          struct dk_minfo_ext {
 341          uint_t dki_media_type; /* Media type or profile info */
 342          uint_t dki_lbsize; /* Logical blocksize of media */
 343          diskaddr_t dki_capacity; /* Capacity as # of dki_lbsize blks */
 344          uint_t dki_pbsize; /* Physical blocksize of media */
 345          };
 346 
 347 


 356          * define the optical media type.
 357          */
 358          #define DK_MO_ERASABLE     0x03 /* MO Erasable */
 359          #define DK_MO_WRITEONCE    0x04 /* MO Write once */
 360          #define DK_AS_MO           0x05 /* AS MO */
 361          #define DK_CDROM           0x08 /* CDROM */
 362          #define DK_CDR             0x09 /* CD-R */
 363          #define DK_CDRW            0x0A /* CD-RW */
 364          #define DK_DVDROM          0x10 /* DVD-ROM */
 365          #define DK_DVDR            0x11 /* DVD-R */
 366          #define DK_DVDRAM          0x12 /* DVD_RAM or DVD-RW */
 367 
 368          /*
 369          * Media types for other rewritable magnetic media
 370          */
 371          #define DK_FIXED_DISK      0x10001 /* Fixed disk SCSI or otherwise */
 372          #define DK_FLOPPY          0x10002 /* Floppy media */
 373          #define DK_ZIP             0x10003 /* IOMEGA ZIP media */
 374          #define DK_JAZ             0x10004 /* IOMEGA JAZ media */
 375 
 376 
 377 
 378        If the media exists and the host can obtain a current profile list, the
 379        command succeeds and returns the dk_minfo structure with data
 380        representing that media.
 381 
 382 
 383        If there is no media in the drive, the command fails and the host
 384        returns an ENXIO error, indicating that it cannot gather the
 385        information requested.
 386 


 387 
 388        If the profile list is not available, the host attempts to identify the
 389        media-type based on the available information.
 390 
 391 
 392        If identification is not possible, the host returns media type
 393        DK_UNKNOWN. See NOTES for blocksize usage and capacity information.
 394 
 395        DKIOCSMBOOT
 396 
 397            The argument is a pointer to struct mboot.
 398 
 399            Copies the mboot information supplied in the argument to the
 400            absolute sector 0 of the device. Prior to copying the information,
 401            this ioctl() performs the following checks on the mboot data:
 402 
 403                o      Ensures that the signature field is set to 0xAA55.
 404 
 405                o      Ensures that partitions do not overlap.
 406 
 407                o      On SPARC platforms, determines if the device is a
 408                       removable media.

 409            If the above verification fails, errno is set to EINVAL and the
 410            ioctl() command fails.
 411 
 412            x86 Platforms -- Upon successful write of mboot, the partition map
 413            structure maintained in the driver is updated. If the new Solaris
 414            partition is different from the previous one, the internal VTOC
 415            table maintained in the driver is set as follows:
 416 
 417            If _SUNOS_VTOC_8 is defined:
 418 
 419            Partition: 0. Start: 0. Capacity = Capacity of device.

 420 
 421            Partition: 2. Start: 0. Capacity = Capacity of device.
 422 
 423            If _SUNOS_VTOC_16 is defined:
 424 
 425            Partition: 2. Start: 0. Size = Size specified in mboot - 2
 426            cylinders.

 427 
 428            Partition: 8. Start: 0. Size = Sectors/cylinder.
 429 
 430            Partition: 9. Start: Sectors/cylinder. Size = 2 * sectors/cylinder
 431 
 432            To determine if the Solaris partition has changed:
 433 
 434            If either offset or the size of the Solaris partition is different
 435            from the previous one then it shall be deemed to have changed. In
 436            all other cases, the internal VTOC info remains as before.
 437 
 438            SPARC Platforms -- The VTOC label and mboot both occupy the same
 439            location, namely sector 0. As a result, following the successful
 440            write of mboot info, the internal VTOC table maintained in the
 441            driver is set as follows:
 442 
 443            Partition: 0. Start: 0. Size = Capacity of device.

 444 
 445            Partition: 2. Start: 0. Size = Capacity of device.

 446 
 447            See the NOTES section for usage of DKIOCSMBOOT when modifying
 448            Solaris partitions.
 449 
 450 
 451        DKIOCGETVOLCAP
 452 
 453            This ioctl provides information and status of available
 454            capabilities.
 455 
 456            vc_info is a bitmap and the valid flag values are:
 457 
 458              DKV_ABR_CAP -  Capable of application-based recovery
 459              DKV_DMR_CAP -  Ability to read specific copy of data when
 460                             multiple copies exist. For example, in a two
 461                             way mirror, this ioctl is used to read each
 462                             side of the mirror.
 463 
 464            vc_set is a bitmap and the valid flag values are:
 465 
 466              DKV_ABR_CAP - This flag is set if ABR has been set on a device
 467                            that supports ABR functionality.
 468              DKV_DMR_CAP - Directed read has been enabled.
 469 
 470            These capabilities are not required to be persistent across a
 471            system reboot and their persistence depends upon the
 472            implementation. For example, if the ABR capability for a DRL mirror
 473            simply clears the dirty-region list and subsequently stops updating
 474            this list, there is no reason for persistence because the VM
 475            recovery is a no-op. Conversely, if the ABR capability is applied
 476            to a non-DRL mirror to indicate that the VM should not perform a
 477            full recovery of the mirror following a system crash, the
 478            capability must be persistent so that the VM know whether or not to
 479            perform recovery.
 480 
 481            Return Errors:
 482 
 483            EINVAL
 484                       Invalid device for this operation.
 485 
 486 
 487            ENOTSUP
 488                       Functionality that is attempted to be set is not
 489                       supported.
 490 
 491 
 492 
 493        DKIOCSETVOLCAP
 494 
 495            This ioctl sets the available capabilities for the device. If a
 496            capability flag is not set in vc_set, that capability is cleared.
 497 
 498            vc_info flags are ignored
 499 
 500            vc_set valid flags are:
 501 
 502              DKV_ABR_CAP - Flag to set application-based recovery. A device can
 503                            successfully support ABR only if it is capable.
 504              DKV_DMR_CAP - Flag to set directed read.
 505 
 506 
 507              int
 508              ioctl(int , DKIODMR, vol_directed_rd *);
 509 
 510 
 511 
 512        DKIODMR
 513 
 514            This ioctl allows highly available applications to perform round-
 515            robin reads from the underlying devices of a replicated device.
 516 
 517              vdr_offset      - offset at which the read should occur.
 518              vdr_nbytes      - number of bytes to be read
 519              vdr_bytesread   - number of bytes successfully read by the kernel.
 520              vdr_data        - pointer to a user allocated buffer to return the
 521                                data read
 522              vdr_side        - side to be read. Initialized to DKV_SIDE_INIT
 523              vdr_side_name   - The volume name that has been read.
 524 








 525              Valid vdr_flags are:
 526                    DKV_DMR_NEXT_SIDE (set by user)
 527                    DKV_DMR_DONE (return value)
 528                    DKV_DMR_ERROR (return value)
 529                    DKV_DMR_SUCCESS(return value)
 530                    DKV_DMR_SHORT(return value)
 531 
 532            The calling sequence is as follows: The caller sets the vdr_flags
 533            to DK_DMR_NEXT_SIDE and vdr_side to DKV_SIDE_INIT at the start.
 534            Subsequent calls should be made without any changes to these
 535            values. If they are changed the results of the ioctl are
 536            indeterminate.
 537 
 538            When DKV_SIDE_INIT is set, the call results in the kernel reading
 539            from the first side. The kernel updates vdr_side to indicate the
 540            side that was read, and vdr_side_name to contain the name of that
 541            side. vdr_data contains the data that was read. Therefore to
 542            perform a round-robin read all of the valid sides, there is no need
 543            for the caller to change the contents of vdr_side.
 544 
 545            Subsequent ioctl calls result in reads from the next valid side







 546            until all valid sides have been read. On success, the kernel sets
 547            DKV_DMR_SUCCESS. The following table shows the values of vdr_flags
 548            that are returned when an error occurs:
 549 
 550              vdr_flags    |   vdr_side        |       Notes
 551              -------------|-------------------|----------------------------
 552              DKV_DMR_ERROR|   DKV_SIDE_INIT   |   No valid side to read
 553              DKV_DMR_DONE |   Not Init side   |   All valid sides read
 554              DKV_DMR_SHORT|   Any value       |   Bytes requested cannot
 555                                                   be read. vdr_bytesread
 556                                                   set to bytes actually
 557                                                   read.
 558 
 559 
 560              Typical code fragment:
 561 
 562              enable->vc_set |= DKV_ABR_SET;
 563              retval = ioctl(filedes, DKIOSETVOLCAP, enable);
 564              if (retval != EINVAL || retval != ENOTSUP) {
 565                      if (info->vc_set &  DKV_DMR_SET) {
 566                              dr->vdr_flags |= DKV_DMR_NEXT_SIDE;
 567                              dr->vdr_side = DKV_SIDE_INIT;
 568                              dr->vdr_nbytes = 1024;
 569                              dr->vdr_offset = 0xff00;
 570                              do {
 571                                      rval =ioctl(fildes, DKIODMR, dr);
 572                                      if (rval != EINVAL) {
 573                                              /* Process data */
 574                                      }
 575                              } while (rval != EINVAL || dr->vdr_flags &
 576                                  (DKV_DMR_DONE | DKV_DMR_ERROR | DKV_DMR_SHORT)
 577                      }
 578              }
 579 
 580 
 581 
 582    RETURN VALUES
 583        Upon successful completion, the value returned is 0. Otherwise, -1 is
 584        returned and errno is set to indicate the error.
 585 
 586    x86 Only
 587        The following ioctl() requests set and/or retrieve the current disk
 588        controller, partitions, or geometry information on the x86
 589        architecture.
 590 
 591        DKIOCG_PHYGEOM
 592 
 593            The argument is a pointer to a dk_geom structure (described below).
 594            This ioctl() gets the driver's notion of the physical geometry of
 595            the disk drive. It is functionally identical to the DKIOCGGEOM
 596            ioctl().
 597 
 598 
 599        DKIOCG_VIRTGEOM
 600 
 601            The argument is a pointer to a dk_geom structure (described below).
 602            This ioctl() gets the controller's (and hence the driver's) notion
 603            of the virtual geometry of the disk drive. Virtual geometry is a
 604            view of the disk geometry maintained by the firmware in a host bus
 605            adapter or disk controller.  If the disk is larger than 8 Gbytes,
 606            this ioctl fails because a CHS-based geometry is not relevant or
 607            useful for this drive.
 608 
 609 
 610          /*
 611          * Definition of a disk's geometry
 612          */
 613          */struct dk_geom {
 614          unsigned shor    dkg_ncyl;             /* # of data cylinders */
 615          unsigned shor    dkg_acyl;             /* # of alternate cylinders */
 616          unsigned short   dkg_bcyl;             /* cyl offset (for fixed head */
 617                                                 /* area) */
 618          unsigned short   dkg_nhead;            /* # of heads */
 619          unsigned short   dkg_obs1;             /* obsolete */
 620          unsigned short   dkg_nsect;            /* # of sectors per track*/
 621          unsigned short   dkg_intrlv;           /* interleave factor */
 622          unsigned short   dkg_obs2;             /* obsolete */
 623          unsigned short   dkg_obs3;             /* obsolete */
 624          unsigned short   dkg_apc;              /* alternates per cylinder */
 625                                                 /* (SCSI only) */
 626          unsigned short   dkg_rpm;              /* revolutions per min*/
 627          unsigned short   dkg_pcyl;             /* # of physical cylinders */
 628          unsigned short   dkg_write_reinstruct; /* # sectors to skip, writes*/
 629          unsigned short   dkg_read_reinstruct;  /* # sectors to skip, reads*/
 630          unsigned short   dkg_extra[7];         /* for compatible expansion*/


 631          };
 632 
 633 
 634        DKIOCADDBAD
 635 
 636            This ioctl() forces the driver to re-examine the alternates slice
 637            and rebuild the internal bad block map accordingly. It should be
 638            used whenever the alternates slice is changed by any method other
 639            than the addbadsec(1M) or format(1M) utilities. DKIOCADDBAD can
 640            only be used for software remapping on  IDE drives; SCSI drives use
 641            hardware remapping of alternate sectors.
 642 
 643 
 644        DKIOCPARTINFO
 645 
 646            The argument is a pointer to a part_info structure (described
 647            below).  This ioctl() gets the driver's notion of the size and
 648            extent of the partition or slice indicated by the file descriptor
 649            argument.
 650 
 651              /*
 652               * Used by applications to get partition or slice information
 653               */
 654              struct part_info {
 655              daddr_t    p_start;
 656              int        p_length;
 657                    };
 658 
 659 
 660 
 661        DKIOCEXTPARTINFO
 662 
 663            The argument is a pointer to an extpart_info structure (described
 664            below).  This ioctl gets the driver's notion of the size and extent
 665            of the partition or slice indicated by the file descriptor
 666            argument. On disks larger than 1TB, this ioctl must be used instead
 667            of DKIOCPARTINFO.
 668 
 669              /*
 670              * Used by applications to get partition or slice information
 671              */
 672              struct extpart_info {
 673              diskkaddr_t      p_start;
 674              diskaddr_t       p_length;
 675              };
 676 
 677 
 678 
 679        DKIOCSETEXTPART
 680 
 681            This ioctl is used to update the in-memory copy of the logical
 682            drive information maintained by the driver. The ioctl takes no
 683            arguments. It causes a re-read of the partition information and
 684            recreation of minor nodes if required.  Prior to updating the data
 685            structures, the ioctl ensures that the partitions do not overlap.
 686            Device nodes are created only for valid partition entries. If there
 687            is any change in the partition offset, size or ID from the previous
 688            read, the partition is deemed to have been changed and hence the
 689            device nodes are recreated. Any modification to any of the logical
 690            partitions results in the recreation of all logical device nodes.
 691 
 692 
 693 SEE ALSO
 694        addbadsec(1M), fdisk(1M), format(1M), ioctl(2), cdio(7I), cmdk(7D),
 695        fdio(7I), hdio(7I), sd(7D)
 696 
 697 NOTES
 698        Blocksize information provided in DKIOCGMEDIAINFO is the size (in
 699        bytes) of the device's basic unit of operation and can differ from the
 700        blocksize that the Solaris operating environment exports to the user.
 701        Capacity information provided in the DKIOCGMEDIAINFO are for reference
 702        only and you are advised to use the values returned by DKIOCGGEOM or
 703        other appropriate ioctl for accessing data using the standard
 704        interfaces.
 705 
 706 
 707        For x86 only: If the DKIOCSMBOOT command is used to modify the Solaris
 708        partitions, the VTOC information should also be set appropriately to
 709        reflect the changes to partition. Failure to do so leads to unexpected
 710        results when the device is closed and reopened fresh at a later time.
 711        This is because a default VTOC is assumed by driver when a Solaris
 712        partition is changed. The default VTOC persists until the ioctl
 713        DKIOCSVTOC is called to modify VTOC or the device is closed and
 714        reopened. At that point, the old valid VTOC is read from the disk if it
 715        is still available.
 716 
 717 
 718 
 719                                 October 8, 2016                       DKIO(7I)
   1 DKIO(7I)                        Ioctl Requests                        DKIO(7I)
   2 


   3 NAME
   4      dkio - disk control operations
   5 
   6 SYNOPSIS
   7      #include <sys/dkio.h>
   8      #include <sys/vtoc.h>
   9 




  10 DESCRIPTION
  11      Disk drivers support a set of ioctl(2) requests for disk controller,
  12      geometry, and partition information.  Basic to these ioctl(2) requests
  13      are the definitions in <sys/dkio.h>.
  14 
  15 IOCTLS
  16      The following ioctl(2) requests set and/or retrieve the current disk
  17      controller, partitions, or geometry information on all architectures:
  18 
  19      DKIOCINFO
  20 
  21         The argument is a pointer to a dk_cinfo structure (described below).
  22         This structure tells the controller-type and attributes regarding bad-
  23         block processing done on the controller.
  24 

  25           /*
  26            * Structures and definitions for disk I/O control commands
  27            */
  28           #define DK_DEVLEN 16   /* device name max length, */
  29                                  /* including unit # and NULL */
  30 
  31           /* Used for controller info */
  32           struct dk_cinfo {
  33                char      dki_cname[DK_DEVLEN];    /* controller name */
  34                                                   /* (no unit #) */
  35                ushort_t  dki_ctype;               /* controller type */
  36                ushort_t  dki_flags;               /* flags */
  37                ushort_t  dki_cnum;                /* controller number */
  38                uint_t    dki_addr;                /* controller address */
  39                uint_t    dki_space;               /* controller bus type */
  40                uint_t    dki_prio;                /* interrupt priority */
  41                uint_t    dki_vec;                 /* interrupt vector */
  42                char      dki_dname[DK_DEVLEN];    /* drive name (no unit #) */
  43                uint_t    dki_unit;                /* unit number */
  44                uint_t    dki_slave;               /* slave number */
  45                ushort_t  dki_partition;           /* partition number */
  46                ushort_t  dki_maxtransfer;         /* maximum transfer size */
  47                                                   /* in DEV_BSIZE */

  48                };
  49 
  50                /*
  51                 * Controller types
  52                 */

  53                #define DKC_UNKNOWN      0
  54                #define DKC_CDROM        1         /* CD-ROM, SCSI or other */
  55                #define DKC_WDC2880      2
  56                #define DKC_XXX_0        3         /* unassigned */
  57                #define DKC_XXX_1        4         /* unassigned */
  58                #define DKC_DSD5215      5
  59                #define DKC_ACB4000      7
  60                #define DKC_XXX_2        9         /* unassigned */
  61                #define DKC_NCRFLOPPY    10
  62                #define DKC_SMSFLOPPY    12
  63                #define DKC_SCSI_CCS     13        /* SCSI CCS compatible */
  64                #define DKC_INTEL82072   14        /* native floppy chip */
  65                #define DKC_INTEL82077   19        /* 82077 floppy disk */
  66                                                   /* controller */
  67                #define DKC_DIRECT       20        /* Intel direct attached */
  68                                                   /* device (IDE) */
  69                #define DKC_PCMCIA_MEM   21        /* PCMCIA memory disk-like */
  70                                                   /* type */
  71                #define DKC_PCMCIA_ATA   22        /* PCMCIA AT Attached type */
  72 
  73                /*
  74                 * Sun reserves up through 1023
  75                 */
  76 
  77                #define DKC_CUSTOMER_BASE  1024
  78 
  79                /*
  80                 * Flags
  81                 */

  82                #define DKI_BAD144       0x01          /* use  DEC  std  144  */
  83                                                       /* bad  sector fwding */
  84                #define DKI_MAPTRK       0x02          /* controller does */
  85                                                       /* track mapping */
  86                #define DKI_FMTTRK       0x04          /* formats only  full
  87                                                       /* track at a time */
  88                #define DKI_FMTVOL       0x08          /* formats only full */
  89                                                       /* volume at a time */
  90                #define DKI_FMTCYL       0x10          /* formats only full */
  91                                                       /* cylinders at a time */
  92                #define DKI_HEXUNIT      0x20          /* unit number printed */
  93                                                       /* as 3 hexdigits */
  94                #define DKI_PCMCIA_PFD   0x40          /* PCMCIA pseudo-floppy */
  95                                                       /* memory card */
  96 

  97      DKIOCGAPART
  98 
  99         The argument is a pointer to a dk_allmap structure (described below).
 100         This ioctl(2) gets the controller's notion of the current partition
 101         table for disk drive.
 102 

 103      DKIOCSAPART
 104 
 105         The argument is a pointer to a dk_allmap structure (described below).
 106         This ioctl(2) sets the controller's notion of the partition table
 107         without changing the disk itself.
 108 

 109           /*
 110            * Partition map (part of dk_label)
 111            */
 112           struct dk_map {
 113                daddr_t dkl_cylno;     /* starting cylinder */
 114                daddr_t dkl_nblk;      /* number of blocks */
 115           };
 116 
 117           /*
 118            * Used for all partitions
 119            */
 120           struct dk_allmap {
 121               struct dk_map    dka_map[NDKMAP];
 122           };
 123 

 124      DKIOCGGEOM



 125 
 126         The argument is a pointer to a dk_geom structure (described below).
 127         This ioctl(2) gets the controller's notion of the current geometry of
 128         the disk drive.
 129 
 130      DKIOCSGEOM



 131 
 132         The argument is a pointer to a dk_geom structure (described below).
 133         This ioctl(2) sets the controller's notion of the geometry without
 134         changing the disk itself.
 135 
 136      DKIOCGVTOC




 137 
 138         The argument is a pointer to a vtoc structure (described below).  This
 139         ioctl(2) returns the device's current volume table of contents (VTOC).
 140         For disks larger than 1TB, DKIOCGEXTVTOC must be used instead.
 141 
 142      DKIOCSVTOC




 143 
 144         The argument is a pointer to a vtoc structure (described below).  This
 145         ioctl(2) changes the VTOC associated with the device.  For disks
 146         larger than 1TB, DKIOCSEXTVTOC must be used instead.
 147 
 148           struct partition {
 149               ushort_t      p_tag;         /* ID tag of partition */
 150               ushort_t      p_flag;        /* permission flags */
 151               daddr_t       p_start;       /* start sector of partition */
 152               long          p_size;        /* # of blocks in partition */
 153           };
 154 
 155         If DKIOCSVTOC is used with a floppy diskette, the p_start field must
 156         be the first sector of a cylinder.  To compute the number of sectors
 157         per cylinder, multiply the number of heads by the number of sectors
 158         per track.
 159 






 160           struct vtoc {
 161               unsigned long     v_bootinfo[3];        /* info needed by mboot */
 162                                                       /* (unsupported) */
 163               unsigned long     v_sanity;             /* to verify vtoc */
 164                                                       /* sanity */
 165               unsigned long     v_version;            /* layout version */
 166               char              v_volume[LEN_DKL_VVOL]; /* volume name */
 167               ushort_t          v_sectorsz;           /* sector size in bytes */
 168               ushort_t          v_nparts;             /* number of partitions */
 169               unsigned long     v_reserved[10];       /* free space */
 170               struct partition  v_part[V_NUMPAR];     /* partition headers */
 171               time_t            timestamp[V_NUMPAR];  /* partition timestamp */
 172                                                       /* (unsupported) */
 173               char              v_asciilabel[LEN_DKL_ASCII]; /* compatibility */
 174           };
 175 
 176           /*
 177            * Partition permission flags
 178            */

 179           #define V_UNMNT      0x01    /* Unmountable partition */
 180           #define V_RONLY      0x10    /* Read only */
 181 
 182           /*
 183            * Partition identification tags
 184            */

 185           #define V_UNASSIGNED   0x00  /* unassigned partition */
 186           #define V_BOOT         0x01  /* Boot partition */
 187           #define V_ROOT         0x02  /* Root filesystem */
 188           #define V_SWAP         0x03  /* Swap filesystem */
 189           #define V_USR          0x04  /* Usr filesystem */
 190           #define V_BACKUP       0x05  /* full disk */
 191           #define V_VAR          0x07  /* Var partition */
 192           #define V_HOME         0x08  /* Home partition */
 193           #define V_ALTSCTR      0x09  /* Alternate sector partition */
 194 

 195      DKIOCGEXTVTOC
 196 
 197         The argument is a pointer to an extvtoc structure (described below).
 198         This ioctl returns the device's current volume table of contents
 199         (VTOC).  VTOC is extended to support a disk up to 2TB in size.  For
 200         disks larger than 1TB this ioctl must be used instead of DKIOCGVTOC.

 201 

 202      DKIOCSEXTVTOC
 203 
 204         The argument is a pointer to an extvtoc structure (described below).
 205         This ioctl changes the VTOC associated with the device.  VTOC is
 206         extended to support a disk up to 2TB in size.  For disks larger than
 207         1TB this ioctl must be used instead of DKIOCSVTOC.
 208 
 209           struct extpartition {
 210               ushort_t p_tag;         /* ID tag of partition */
 211               ushort_t p_flag;        /* permission flags */
 212               ushort_t p_pad[2];      /* reserved */
 213               diskaddr_t p_start;     /* start sector no of partition */
 214               diskaddr_t p_size;      /* # of blocks in partition */
 215           };
 216 

 217           struct extvtoc {
 218               uint64_t   v_bootinfo[3]; /* info needed by mboot (unsupported) */
 219               uint64_t   v_sanity;      /* to verify vtoc sanity */
 220               uint64_t   v_version;     /* layout version */
 221               char    v_volume[LEN_DKL_VVOL]; /* volume name */
 222               ushort_t   v_sectorsz;    /* sector size in bytes */
 223               ushort_t   v_nparts;      /* number of partitions */
 224               ushort_t   pad[2];
 225               uint64_t   v_reserved[10];
 226               struct extpartition v_part[V_NUMPAR]; /* partition headers */
 227               uint64_t timestamp[V_NUMPAR]; /* partition timestamp */
 228                                             /* (unsupported) */
 229               char    v_asciilabel[LEN_DKL_ASCII];    /* for compatibility */
 230           };
 231 
 232         Partition permissions flags and identification tags are defined the
 233         same as vtoc structure.
 234 


 235      DKIOCEJECT
 236 
 237         If the drive supports removable media, this ioctl(2) requests the disk
 238         drive to eject its disk.
 239 

 240      DKIOCREMOVABLE
 241 
 242         The argument to this ioctl(2) is an integer.  After successful
 243         completion, this ioctl(2) sets that integer to a non-zero value if the
 244         drive in question has removable media.  If the media is not removable,
 245         the integer is set to 0.
 246 

 247      DKIOCHOTPLUGGABLE
 248 
 249         The argument to this ioctl(2) is an integer.  After successful
 250         completion, this ioctl(2) sets that integer to a non-zero value if the
 251         drive in question is hotpluggable.  If the media is not hotpluggable,
 252         the integer is set to 0.
 253 

 254      DKIOCSTATE
 255 
 256         This ioctl(2) blocks until the state of the drive, inserted or
 257         ejected, is changed.  The argument is a pointer to a dkio_state, enum,
 258         whose possible enumerations are listed below.  The initial value
 259         should be either the last reported state of the drive, or DKIO_NONE.
 260         Upon return, the enum pointed to by the argument is updated with the
 261         current state of the drive.
 262 
 263           enum dkio_state {
 264               DKIO_NONE,          /* Return disk's current state */
 265               DKIO_EJECTED,       /* Disk state is 'ejected' */
 266               DKIO_INSERTED       /* Disk state is 'inserted' */
 267           };
 268 


 269      DKIOCLOCK
 270 
 271         For devices with removable media, this ioctl(2) requests the disk
 272         drive to lock the door.
 273 

 274      DKIOCUNLOCK
 275 
 276         For devices with removable media, this ioctl(2) requests the disk
 277         drive to unlock the door.
 278 

 279      DKIOCGMEDIAINFO
 280 
 281         The argument to this ioctl(2) is a pointer to a dk_minfo structure.
 282         The structure indicates the type of media or the command set profile
 283         used by the drive to operate on the media.  The dk_minfo structure
 284         also indicates the logical media block size the drive uses as the
 285         basic unit block size of operation and the raw formatted capacity of
 286         the media in number of logical blocks.
 287 

 288      DKIOCGMEDIAINFOEXT
 289 
 290         The argument to this ioctl(2) is a pointer to a dk_minfo_ext
 291         structure.  The structure indicates the type of media or the command
 292         set profile used by the drive to operate on the media.  The
 293         dk_minfo_ext structure also indicates the logical media block size the
 294         drive uses as the basic unit block size of operation, the raw
 295         formatted capacity of the media in number of logical blocks and the
 296         physical block size of the media.
 297 

 298           /*
 299            * Used for media info or profile info
 300            */
 301           struct dk_minfo {
 302               uint_t dki_media_type;   /* Media type or profile info */
 303               uint_t dki_lbsize;       /* Logical blocksize of media */
 304               diskaddr_t dki_capacity; /* Capacity as # of dki_lbsize blks */
 305           };
 306 
 307           /*
 308            * Used for media info or profile info and physical blocksize
 309            */
 310           struct dk_minfo_ext {
 311               uint_t dki_media_type; /* Media type or profile info */
 312               uint_t dki_lbsize; /* Logical blocksize of media */
 313               diskaddr_t dki_capacity; /* Capacity as # of dki_lbsize blks */
 314               uint_t dki_pbsize; /* Physical blocksize of media */
 315           };
 316 
 317 


 326            * define the optical media type.
 327            */
 328           #define DK_MO_ERASABLE     0x03 /* MO Erasable */
 329           #define DK_MO_WRITEONCE    0x04 /* MO Write once */
 330           #define DK_AS_MO           0x05 /* AS MO */
 331           #define DK_CDROM           0x08 /* CDROM */
 332           #define DK_CDR             0x09 /* CD-R */
 333           #define DK_CDRW            0x0A /* CD-RW */
 334           #define DK_DVDROM          0x10 /* DVD-ROM */
 335           #define DK_DVDR            0x11 /* DVD-R */
 336           #define DK_DVDRAM          0x12 /* DVD_RAM or DVD-RW */
 337 
 338           /*
 339            * Media types for other rewritable magnetic media
 340            */
 341           #define DK_FIXED_DISK      0x10001 /* Fixed disk SCSI or otherwise */
 342           #define DK_FLOPPY          0x10002 /* Floppy media */
 343           #define DK_ZIP             0x10003 /* IOMEGA ZIP media */
 344           #define DK_JAZ             0x10004 /* IOMEGA JAZ media */
 345 
 346         If the media exists and the host can obtain a current profile list,
 347         the command succeeds and returns the dk_minfo structure with data


 348         representing that media.
 349 

 350         If there is no media in the drive, the command fails and the host
 351         returns an ENXIO error, indicating that it cannot gather the
 352         information requested.
 353 
 354         If the profile list is not available, the host attempts to identify
 355         the media-type based on the available information.
 356 




 357         If identification is not possible, the host returns media type
 358         DK_UNKNOWN.  See NOTES for blocksize usage and capacity information.
 359 
 360      DKIOCSMBOOT
 361 
 362         The argument is a pointer to struct mboot.
 363 
 364         Copies the mboot information supplied in the argument to the absolute
 365         sector 0 of the device.  Prior to copying the information, this
 366         ioctl(2) performs the following checks on the mboot data:
 367 
 368               o   Ensures that the signature field is set to 0xAA55.
 369 
 370               o   Ensures that partitions do not overlap.
 371 
 372               o   On SPARC platforms, determines if the device is a removable
 373                   media.
 374 
 375         If the above verification fails, errno is set to EINVAL and the
 376         ioctl(2) command fails.
 377 
 378         x86 Platforms -- Upon successful write of mboot, the partition map
 379         structure maintained in the driver is updated.  If the new Solaris
 380         partition is different from the previous one, the internal VTOC table
 381         maintained in the driver is set as follows:
 382 
 383         If _SUNOS_VTOC_8 is defined:
 384 
 385             Partition: 0 Start: 0 Capacity = Capacity of device.
 386             Partition: 2 Start: 0 Capacity = Capacity of device.
 387 


 388         If _SUNOS_VTOC_16 is defined:
 389 
 390             Partition: 2 Start: 0 Size = Size specified in mboot - 2 cylinders.
 391             Partition: 8 Start: 0 Size = Sectors/cylinder.
 392             Partition: 9 Start: Sectors/cylinder  Size = 2 * sectors/cylinder
 393 




 394         To determine if the Solaris partition has changed:
 395 
 396             If either offset or the size of the Solaris partition is different
 397             from the previous one then it shall be deemed to have changed.  In
 398             all other cases, the internal VTOC info remains as before.
 399 
 400         SPARC Platforms -- The VTOC label and mboot both occupy the same
 401         location, namely sector 0.  As a result, following the successful
 402         write of mboot info, the internal VTOC table maintained in the driver
 403         is set as follows:
 404 
 405             Partition: 0  Start: 0  Size = Capacity of device.
 406             Partition: 2  Start: 0  Size = Capacity of device.
 407 
 408         See the NOTES section for usage of DKIOCSMBOOT when modifying Solaris
 409         partitions.
 410 




 411      DKIOCGETVOLCAP
 412 
 413         This ioctl provides information and status of available capabilities.


 414         vc_info is a bitmap and the valid flag values are:
 415 
 416           DKV_ABR_CAP  Capable of application-based recovery
 417           DKV_DMR_CAP  Ability to read specific copy of data when multiple
 418                        copies exist.  For example, in a two way mirror, this
 419                        ioctl is used to read each side of the mirror.

 420 
 421         vc_set is a bitmap and the valid flag values are:
 422 
 423           DKV_ABR_CAP  This flag is set if ABR has been set on a device that
 424                        supports ABR functionality.
 425           DKV_DMR_CAP  Directed read has been enabled.
 426 
 427         These capabilities are not required to be persistent across a system
 428         reboot and their persistence depends upon the implementation.  For
 429         example, if the ABR capability for a DRL mirror simply clears the
 430         dirty-region list and subsequently stops updating this list, there is
 431         no reason for persistence because the VM recovery is a no-op.
 432         Conversely, if the ABR capability is applied to a non-DRL mirror to
 433         indicate that the VM should not perform a full recovery of the mirror
 434         following a system crash, the capability must be persistent so that
 435         the VM know whether or not to perform recovery.

 436 
 437         Return Errors:
 438 
 439           EINVAL   Invalid device for this operation.
 440           ENOTSUP  Functionality that is attempted to be set is not supported.
 441 







 442      DKIOCSETVOLCAP
 443 
 444         This ioctl sets the available capabilities for the device.  If a
 445         capability flag is not set in vc_set, that capability is cleared.
 446 
 447         vc_info flags are ignored.
 448 
 449         vc_set valid flags are:
 450 
 451           DKV_ABR_CAP  Flag to set application-based recovery.  A device can
 452                        successfully support ABR only if it is capable.
 453           DKV_DMR_CAP  Flag to set directed read.
 454 






 455      DKIODMR
 456 
 457         int ioctl(int, DKIODMR, vol_directed_rd *)

 458 
 459         This ioctl allows highly available applications to perform round-robin
 460         reads from the underlying devices of a replicated device.





 461 
 462           vdr_offset     Offset at which the read should occur.
 463           vdr_nbytes     Number of bytes to be read
 464           vdr_bytesread  Number of bytes successfully read by the kernel.
 465           vdr_data       Pointer to a user allocated buffer to return the data
 466                          read
 467           vdr_side       Side to be read.  Initialized to DKV_SIDE_INIT
 468           vdr_side_name  The volume name that has been read.
 469 
 470         Valid vdr_flags are:





 471 
 472           DKV_DMR_NEXT_SIDE  Set by user
 473           DKV_DMR_DONE       Return value
 474           DKV_DMR_ERROR      Return value
 475           DKV_DMR_SUCCESS    Return value
 476           DKV_DMR_SHORT      Return value
 477 
 478         The calling sequence is as follows: The caller sets the vdr_flags to
 479         DK_DMR_NEXT_SIDE and vdr_side to DKV_SIDE_INIT at the start.
 480         Subsequent calls should be made without any changes to these values.
 481         If they are changed the results of the ioctl are indeterminate.


 482 
 483         When DKV_SIDE_INIT is set, the call results in the kernel reading from
 484         the first side.  The kernel updates vdr_side to indicate the side that
 485         was read, and vdr_side_name to contain the name of that side.
 486         vdr_data contains the data that was read.  Therefore to perform a
 487         round-robin read all of the valid sides, there is no need for the
 488         caller to change the contents of vdr_side.
 489 
 490         Subsequent ioctl(2) calls result in reads from the next valid side
 491         until all valid sides have been read.  On success, the kernel sets
 492         DKV_DMR_SUCCESS.  The following table shows the values of vdr_flags
 493         that are returned when an error occurs:
 494 
 495           vda_flags        vdr_side         Notes
 496           DKV_DMR_ERROR    DKV_SIDE_INIT    No valid side to read
 497           DKV_DMR_DONE     Not Init side    All valid sides read
 498           DKV_DMR_SHORT    Any value        Bytes requested cannot be read
 499                                             vdr_bytesread set to bytes
 500                                             actually read




 501         Typical code fragment:
 502 
 503           enable->vc_set |= DKV_ABR_SET;
 504           retval = ioctl(filedes, DKIOSETVOLCAP, enable);
 505           if (retval != EINVAL || retval != ENOTSUP) {
 506                   if (info->vc_set & DKV_DMR_SET) {
 507                           dr->vdr_flags      |= DKV_DMR_NEXT_SIDE;
 508                           dr->vdr_side = DKV_SIDE_INIT;
 509                           dr->vdr_nbytes = 1024;
 510                           dr->vdr_offset = 0xff00;
 511                           do {
 512                                   rval = ioctl(fildes, DKIODMR, dr);
 513                                   if (rval != EINVAL) {
 514                                           /* Process data */
 515                                   }
 516                           } while (rval != EINVAL || dr->vdr_flags &
 517                               (DKV_DMR_DONE | DKV_DMR_ERROR | DKV_DMR_SHORT)
 518                   }
 519           }
 520 


 521    RETURN VALUES
 522      Upon successful completion, the value returned is 0.  Otherwise, -1 is
 523      returned and errno is set to indicate the error.
 524 
 525    x86 Only
 526      The following ioctl(2) requests set and/or retrieve the current disk
 527      controller, partitions, or geometry information on the x86 architecture.

 528 
 529      DKIOCG_PHYGEOM
 530 
 531         The argument is a pointer to a dk_geom structure (described below).
 532         This ioctl(2) gets the driver's notion of the physical geometry of the
 533         disk drive.  It is functionally identical to the DKIOCGGEOM ioctl(2).

 534 

 535      DKIOCG_VIRTGEOM
 536 
 537         The argument is a pointer to a dk_geom structure (described below).
 538         This ioctl(2) gets the controller's (and hence the driver's) notion of
 539         the virtual geometry of the disk drive.  Virtual geometry is a view of
 540         the disk geometry maintained by the firmware in a host bus adapter or
 541         disk controller.  If the disk is larger than 8 Gbytes, this ioctl
 542         fails because a CHS-based geometry is not relevant or useful for this
 543         drive.
 544 

 545           /*
 546            * Definition of a disk's geometry
 547            */
 548           struct dk_geom {
 549               unsigned shor    dkg_ncyl;   /* # of data cylinders */
 550               unsigned shor    dkg_acyl;   /* # of alternate cylinders */
 551               unsigned short   dkg_bcyl;   /* cyl offset (for fixed head */
 552                                            /* area) */
 553               unsigned short   dkg_nhead;  /* # of heads */
 554               unsigned short   dkg_obs1;   /* obsolete */
 555               unsigned short   dkg_nsect;  /* # of sectors per track */
 556               unsigned short   dkg_intrlv; /* interleave factor */
 557               unsigned short   dkg_obs2;   /* obsolete */
 558               unsigned short   dkg_obs3;   /* obsolete */
 559               unsigned short   dkg_apc;    /* alternates per cylinder */
 560                                            /* (SCSI only) */
 561               unsigned short   dkg_rpm;    /* revolutions per min */
 562               unsigned short   dkg_pcyl;   /* # of physical cylinders */
 563               unsigned short   dkg_write_reinstruct; /* # sectors to skip, */
 564                                                      /* writes */
 565               unsigned short   dkg_read_reinstruct;  /* # sectors to skip ,*/
 566                                                      /* reads */
 567               unsigned short   dkg_extra[7]; /* for compatible expansion */
 568           };
 569 

 570      DKIOCADDBAD
 571 
 572         This ioctl(2) forces the driver to re-examine the alternates slice and
 573         rebuild the internal bad block map accordingly.  It should be used
 574         whenever the alternates slice is changed by any method other than the
 575         addbadsec(1M) or format(1M) utilities.  DKIOCADDBAD can only be used
 576         for software remapping on IDE drives; SCSI drives use hardware
 577         remapping of alternate sectors.
 578 

 579      DKIOCPARTINFO
 580 
 581         The argument is a pointer to a part_info structure (described below).
 582         This ioctl(2) gets the driver's notion of the size and extent of the
 583         partition or slice indicated by the file descriptor argument.

 584 
 585           /*
 586            * Used by applications to get partition or slice information
 587            */
 588           struct part_info {
 589               daddr_t    p_start;
 590               int        p_length;
 591           };
 592 


 593      DKIOCEXTPARTINFO
 594 
 595         The argument is a pointer to an extpart_info structure (described
 596         below).  This ioctl gets the driver's notion of the size and extent of
 597         the partition or slice indicated by the file descriptor argument.  On
 598         disks larger than 1TB, this ioctl must be used instead of
 599         DKIOCPARTINFO.
 600 
 601           /*
 602            * Used by applications to get partition or slice information
 603            */
 604           struct extpart_info {
 605               diskkaddr_t      p_start;
 606               diskaddr_t       p_length;
 607           };
 608 


 609      DKIOCSETEXTPART
 610 
 611         This ioctl is used to update the in-memory copy of the logical drive
 612         information maintained by the driver.  The ioctl takes no arguments.
 613         It causes a re-read of the partition information and recreation of
 614         minor nodes if required.  Prior to updating the data structures, the
 615         ioctl ensures that the partitions do not overlap.  Device nodes are
 616         created only for valid partition entries.  If there is any change in
 617         the partition offset, size or ID from the previous read, the partition
 618         is deemed to have been changed and hence the device nodes are
 619         recreated.  Any modification to any of the logical partitions results
 620         in the recreation of all logical device nodes.
 621 

 622 SEE ALSO
 623      addbadsec(1M), fdisk(1M), format(1M), ioctl(2), cmdk(7D), sd(7D),
 624      cdio(7I), fdio(7I), hdio(7I)
 625 
 626 NOTES
 627      Blocksize information provided in DKIOCGMEDIAINFO is the size (in bytes)
 628      of the device's basic unit of operation and can differ from the blocksize
 629      that the Solaris operating environment exports to the user.  Capacity
 630      information provided in the DKIOCGMEDIAINFO are for reference only and
 631      you are advised to use the values returned by DKIOCGGEOM or other
 632      appropriate ioctl(2) for accessing data using the standard interfaces.

 633 

 634      For x86 only: If the DKIOCSMBOOT command is used to modify the Solaris
 635      partitions, the VTOC information should also be set appropriately to
 636      reflect the changes to partition.  Failure to do so leads to unexpected
 637      results when the device is closed and reopened fresh at a later time.
 638      This is because a default VTOC is assumed by driver when a Solaris
 639      partition is changed.  The default VTOC persists until the ioctl
 640      DKIOCSVTOC is called to modify VTOC or the device is closed and reopened.
 641      At that point, the old valid VTOC is read from the disk if it is still
 642      available.
 643 
 644 illumos                        October 23, 2017                        illumos