Print this page
document DKIOCFREE
   1 .\"
   2 .\" The contents of this file are subject to the terms of the
   3 .\" Common Development and Distribution License (the "License").
   4 .\" You may not use this file except in compliance with the License.
   5 .\"
   6 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   7 .\" or http://www.opensolaris.org/os/licensing.
   8 .\" See the License for the specific language governing permissions
   9 .\" and limitations under the License.
  10 .\"
  11 .\" When distributing Covered Code, include this CDDL HEADER in each
  12 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  13 .\" If applicable, add the following below this CDDL HEADER, with the
  14 .\" fields enclosed by brackets "[]" replaced with your own identifying
  15 .\" information: Portions Copyright [yyyy] [name of copyright owner]
  16 .\"
  17 .\"
  18 .\" Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved.
  19 .\" Copyright 2016 Nexenta Systems, Inc.
  20 .\" Copyright (c) 2017, Joyent, Inc.
  21 .\"
  22 .Dd October 23, 2017
  23 .Dt DKIO 7I
  24 .Os
  25 .Sh NAME
  26 .Nm dkio
  27 .Nd disk control operations
  28 .Sh SYNOPSIS
  29 .In sys/dkio.h
  30 .In sys/vtoc.h
  31 .Sh DESCRIPTION
  32 Disk drivers support a set of
  33 .Xr ioctl 2
  34 requests for disk controller, geometry, and partition information.
  35 Basic to these
  36 .Xr ioctl 2
  37 requests are the definitions in
  38 .In sys/dkio.h .
  39 .Sh IOCTLS
  40 The following
  41 .Xr ioctl 2
  42 requests set and/or retrieve the current disk


 676 Typical code fragment:
 677 .Bd -literal -offset 2n
 678 enable->vc_set |= DKV_ABR_SET;
 679 retval = ioctl(filedes, DKIOSETVOLCAP, enable);
 680 if (retval != EINVAL || retval != ENOTSUP) {
 681         if (info->vc_set & DKV_DMR_SET) {
 682                 dr->vdr_flags |= DKV_DMR_NEXT_SIDE;
 683                 dr->vdr_side = DKV_SIDE_INIT;
 684                 dr->vdr_nbytes = 1024;
 685                 dr->vdr_offset = 0xff00;
 686                 do {
 687                         rval = ioctl(fildes, DKIODMR, dr);
 688                         if (rval != EINVAL) {
 689                                 /* Process data */
 690                         }
 691                 } while (rval != EINVAL || dr->vdr_flags &
 692                     (DKV_DMR_DONE | DKV_DMR_ERROR | DKV_DMR_SHORT)
 693         }
 694 }
 695 .Ed



































 696 .El





















































 697 .Ss "RETURN VALUES"
 698 Upon successful completion, the value returned is
 699 .Sy 0 .
 700 Otherwise,
 701 .Sy -1
 702 is returned and
 703 .Va errno
 704 is set to indicate the error.
 705 .Ss "x86 Only"
 706 The following
 707 .Xr ioctl 2
 708 requests set and/or retrieve the current disk
 709 controller, partitions, or geometry information on the x86 architecture.
 710 .Bl -tag -width 1n
 711 .It Dv DKIOCG_PHYGEOM
 712 .Pp
 713 The argument is a pointer to a
 714 .Vt dk_geom
 715 structure (described below).
 716 This


   1 .\"
   2 .\" The contents of this file are subject to the terms of the
   3 .\" Common Development and Distribution License (the "License").
   4 .\" You may not use this file except in compliance with the License.
   5 .\"
   6 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   7 .\" or http://www.opensolaris.org/os/licensing.
   8 .\" See the License for the specific language governing permissions
   9 .\" and limitations under the License.
  10 .\"
  11 .\" When distributing Covered Code, include this CDDL HEADER in each
  12 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  13 .\" If applicable, add the following below this CDDL HEADER, with the
  14 .\" fields enclosed by brackets "[]" replaced with your own identifying
  15 .\" information: Portions Copyright [yyyy] [name of copyright owner]
  16 .\"
  17 .\"
  18 .\" Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved.
  19 .\" Copyright 2016 Nexenta Systems, Inc.
  20 .\" Copyright 2020 Joyent, Inc.
  21 .\"
  22 .Dd February 14, 2020
  23 .Dt DKIO 7I
  24 .Os
  25 .Sh NAME
  26 .Nm dkio
  27 .Nd disk control operations
  28 .Sh SYNOPSIS
  29 .In sys/dkio.h
  30 .In sys/vtoc.h
  31 .Sh DESCRIPTION
  32 Disk drivers support a set of
  33 .Xr ioctl 2
  34 requests for disk controller, geometry, and partition information.
  35 Basic to these
  36 .Xr ioctl 2
  37 requests are the definitions in
  38 .In sys/dkio.h .
  39 .Sh IOCTLS
  40 The following
  41 .Xr ioctl 2
  42 requests set and/or retrieve the current disk


 676 Typical code fragment:
 677 .Bd -literal -offset 2n
 678 enable->vc_set |= DKV_ABR_SET;
 679 retval = ioctl(filedes, DKIOSETVOLCAP, enable);
 680 if (retval != EINVAL || retval != ENOTSUP) {
 681         if (info->vc_set & DKV_DMR_SET) {
 682                 dr->vdr_flags |= DKV_DMR_NEXT_SIDE;
 683                 dr->vdr_side = DKV_SIDE_INIT;
 684                 dr->vdr_nbytes = 1024;
 685                 dr->vdr_offset = 0xff00;
 686                 do {
 687                         rval = ioctl(fildes, DKIODMR, dr);
 688                         if (rval != EINVAL) {
 689                                 /* Process data */
 690                         }
 691                 } while (rval != EINVAL || dr->vdr_flags &
 692                     (DKV_DMR_DONE | DKV_DMR_ERROR | DKV_DMR_SHORT)
 693         }
 694 }
 695 .Ed
 696 .It Dv DKIOCFREE
 697 .Pp
 698 The argument is a pointer to a
 699 .Vt dkioc_free_list_t
 700 structure (described below).
 701 The structure consists of a header followed by one or more
 702 .Vt dkioc_free_list_ext_t
 703 strctures (described below) that list the extents that the device should free.
 704 .Bd -literal -offset 2n
 705 typedef struct dkioc_free_list_ext_s {
 706         uint64_t                dfle_start;
 707         uint64_t                dfle_length;
 708 } dkioc_free_list_ext_t;
 709 
 710 typedef struct dkioc_free_list_s {
 711         uint64_t                dfl_flags;
 712         uint64_t                dfl_num_exts;
 713         uint64_t                dfl_offset;
 714         dkioc_free_list_ext_t   dfl_exts[1];
 715 } dkioc_free_list_t;
 716 .Ed
 717 .Pp
 718 The
 719 .Fa dfle_start ,
 720 .Fa dfle_length ,
 721 and
 722 .Fa dfl_offset
 723 fields are in units of bytes (not blocks).
 724 .Pp
 725 The values for
 726 .Fa dfl_flags
 727 are:
 728 .Bl -tag -width Dv
 729 .It Dv DF_WAIT_SYNC
 730 Wait for the device to complete freeing the space before returning.
 731 .El
 732 .Pp
 733 The
 734 .Fa dfl_num_exts
 735 field indicates the number of
 736 .Vt dkioc_free_list_ext_t
 737 structures follow the
 738 .Vt dkioc_free_list_t
 739 structure (including the first entry in
 740 .Fa dfl_exts ) .
 741 There must be at least one
 742 .Vt dkioc_free_list_ext_t
 743 in the
 744 .Xr ioctl 2
 745 request (i.e\&.
 746 .Fa dfl_num_exts
 747 must be \(>= 1).
 748 .Pp
 749 The
 750 .Fa dfl_offset
 751 field is added to all of the values of
 752 .Fa dfle_start
 753 when processed by the device.
 754 .Pp
 755 The
 756 .Fa dfl_exts
 757 field contains the first extent to free, immediately followed by any
 758 additional
 759 .Vt dkioc_free_list_ext_t
 760 structures if there are more than one extent to free.
 761 .Pp
 762 The
 763 .Dv DFL_SZ(num_exts)
 764 macro can be used to calculate the amount of memory required to hold
 765 .Fa num_exts
 766 extents.
 767 .It Dv DKIOC_CANFREE
 768 The argument is a pointer to an
 769 .Vt int
 770 that is populated by the
 771 .Xr ioctl 2
 772 request.
 773 Upon a successful return, if a non-zero value has been set in the
 774 .Vt int
 775 parameter, it indicates that the device supports the
 776 .Dv DKIOCFREE
 777 .Xr ioctl 2 .
 778 If the
 779 .Vt int
 780 parameter has been set to zero, the
 781 .Dv DKIOCFREE
 782 .Xr ioctl 2
 783 is not supported by the device.
 784 .El
 785 .Ss "RETURN VALUES"
 786 Upon successful completion, the value returned is
 787 .Sy 0 .
 788 Otherwise,
 789 .Sy -1
 790 is returned and
 791 .Va errno
 792 is set to indicate the error.
 793 .Ss "x86 Only"
 794 The following
 795 .Xr ioctl 2
 796 requests set and/or retrieve the current disk
 797 controller, partitions, or geometry information on the x86 architecture.
 798 .Bl -tag -width 1n
 799 .It Dv DKIOCG_PHYGEOM
 800 .Pp
 801 The argument is a pointer to a
 802 .Vt dk_geom
 803 structure (described below).
 804 This