1*24d79e9bSWarner Losh.\" Copyright (c) 2020 M. Warner Losh <imp@FreeBSD.org> 2*24d79e9bSWarner Losh.\" 3*24d79e9bSWarner Losh.\" Redistribution and use in source and binary forms, with or without 4*24d79e9bSWarner Losh.\" modification, are permitted provided that the following conditions 5*24d79e9bSWarner Losh.\" are met: 6*24d79e9bSWarner Losh.\" 1. Redistributions of source code must retain the above copyright 7*24d79e9bSWarner Losh.\" notice, this list of conditions and the following disclaimer. 8*24d79e9bSWarner Losh.\" 9*24d79e9bSWarner Losh.\" 2. Redistributions in binary form must reproduce the above copyright 10*24d79e9bSWarner Losh.\" notice, this list of conditions and the following disclaimer in the 11*24d79e9bSWarner Losh.\" documentation and/or other materials provided with the distribution. 12*24d79e9bSWarner Losh.\" 13*24d79e9bSWarner Losh.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14*24d79e9bSWarner Losh.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15*24d79e9bSWarner Losh.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16*24d79e9bSWarner Losh.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17*24d79e9bSWarner Losh.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18*24d79e9bSWarner Losh.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19*24d79e9bSWarner Losh.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20*24d79e9bSWarner Losh.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21*24d79e9bSWarner Losh.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22*24d79e9bSWarner Losh.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23*24d79e9bSWarner Losh.\" SUCH DAMAGE. 24*24d79e9bSWarner Losh.\" 25*24d79e9bSWarner Losh.\" $FreeBSD$ 26*24d79e9bSWarner Losh.\" 27*24d79e9bSWarner Losh.Dd November 20, 2020 28*24d79e9bSWarner Losh.Dt disk 4 29*24d79e9bSWarner Losh.Os 30*24d79e9bSWarner Losh.Sh NAME 31*24d79e9bSWarner Losh.Nm disk 32*24d79e9bSWarner Losh.Nd common disk interfaces 33*24d79e9bSWarner Losh.Sh SYNOPSIS 34*24d79e9bSWarner Losh.Cd device cd 35*24d79e9bSWarner Losh.Sh DESCRIPTION 36*24d79e9bSWarner LoshCommon block device IOCTLs 37*24d79e9bSWarner Losh.Pp 38*24d79e9bSWarner LoshAll the block devices in the system should support these disk 39*24d79e9bSWarner Losh.Xr ioctl 2 40*24d79e9bSWarner Loshcommands defined here. 41*24d79e9bSWarner LoshMuch of this information is also available via the 42*24d79e9bSWarner Losh.Xr geom 2 43*24d79e9bSWarner Loshattributes. 44*24d79e9bSWarner Losh.Sh IOCTLS 45*24d79e9bSWarner LoshThe following 46*24d79e9bSWarner Losh.Xr ioctl 2 47*24d79e9bSWarner Loshcalls apply to disk drives, and are defined 48*24d79e9bSWarner Loshin the 49*24d79e9bSWarner Losh.In sys/disk.h 50*24d79e9bSWarner Loshheader file. 51*24d79e9bSWarner Losh.Bl -tag -width DIOCGPROVIDERNAME 52*24d79e9bSWarner Losh.It Dv DIOCGSECTORSIZE 53*24d79e9bSWarner Losh.Pq Li "u_int" 54*24d79e9bSWarner LoshGet the sector or block size of the device in bytes. 55*24d79e9bSWarner LoshThe sector size is the smallest unit of data which can be transferred 56*24d79e9bSWarner Loshfrom this device. 57*24d79e9bSWarner LoshThis is usually a power of 2 but it might not be (e.g. CDROM audio). 58*24d79e9bSWarner LoshOperations to block devices such as 59*24d79e9bSWarner Losh.Xr lseek 2 , 60*24d79e9bSWarner Losh.Xr read 2 , 61*24d79e9bSWarner Loshand 62*24d79e9bSWarner Losh.Xr write 63*24d79e9bSWarner Loshmay only be performed at file offsets that are integral multiple of 64*24d79e9bSWarner Loshthis size. 65*24d79e9bSWarner Losh.It Dv DIOCGMEDIASIZE 66*24d79e9bSWarner Losh.Pq Li "off_t" 67*24d79e9bSWarner LoshGet the size of the entire device in bytes. 68*24d79e9bSWarner LoshThis should be a multiple of the sector size. 69*24d79e9bSWarner Losh.It Dv DIOCGFWSECTORS 70*24d79e9bSWarner Losh.Pq Li "u_int" 71*24d79e9bSWarner LoshReturn the firmware's notion of number of sectors per track. 72*24d79e9bSWarner LoshThis value is mostly used for compatibility with various ill designed 73*24d79e9bSWarner Loshdisk label formats. 74*24d79e9bSWarner LoshUse this value only when absolutely required. 75*24d79e9bSWarner LoshIts interpretation and use is largely obsolete. 76*24d79e9bSWarner Losh.It Dv DIOCGFWHEADS 77*24d79e9bSWarner Losh.Pq Li "u_int" 78*24d79e9bSWarner LoshReturn the firmware's notion of number of heads per cylinder. 79*24d79e9bSWarner LoshThis value is mostly used for compatibility with various ill designed 80*24d79e9bSWarner Loshdisk label formats. 81*24d79e9bSWarner LoshUse this value only when absolutely required. 82*24d79e9bSWarner LoshIts interpretation and use is largely obsolete. 83*24d79e9bSWarner Losh.It Dv DIOCGFLUSH 84*24d79e9bSWarner LoshFlush write cache of the device. 85*24d79e9bSWarner Losh.It Dv DIOCGDELETE 86*24d79e9bSWarner Losh.Pq Li "off_t[2]" 87*24d79e9bSWarner LoshMark data on the device as unused. 88*24d79e9bSWarner LoshThe first element is the offset to start deleting. 89*24d79e9bSWarner LoshThe second element is the length to delete. 90*24d79e9bSWarner LoshProviders may use this information to free storage or instruct storage 91*24d79e9bSWarner Loshdevices the contents can be discarded. 92*24d79e9bSWarner Losh.It Dv DIOCGIDENT 93*24d79e9bSWarner Losh.Pq Li "char[DISK_IDENT_SIZE]" 94*24d79e9bSWarner LoshGet the ident for this provider. 95*24d79e9bSWarner LoshIdent is a unique and fixed identifier for this provider. 96*24d79e9bSWarner LoshIdent's properties are as follow: 97*24d79e9bSWarner Losh.Bl -bullet 98*24d79e9bSWarner Losh.It 99*24d79e9bSWarner Loshpreserved between reboots, 100*24d79e9bSWarner Losh.It 101*24d79e9bSWarner Loshpreserved across a provider being detached/attached, 102*24d79e9bSWarner Losh.It 103*24d79e9bSWarner Loshprovider's name can change - ident can't, 104*24d79e9bSWarner Losh.It 105*24d79e9bSWarner Loshident value should not be based on on-disk metadata; in other 106*24d79e9bSWarner Loshwords, copying whole data from one disk to another should not 107*24d79e9bSWarner Loshyield the same ident for the other disk, 108*24d79e9bSWarner Losh.It 109*24d79e9bSWarner Loshthere can be more than one provider with the same ident, but 110*24d79e9bSWarner Loshonly if they point at exactly the same physical storage, this is 111*24d79e9bSWarner Loshthe case for multipathing for example, 112*24d79e9bSWarner Losh.It 113*24d79e9bSWarner LoshGEOM classes that consume a single provider and provide single 114*24d79e9bSWarner Loshprovider, like 115*24d79e9bSWarner Losh.Xr geli 8 , 116*24d79e9bSWarner Loshand 117*24d79e9bSWarner Losh.Xr gbde 8 , 118*24d79e9bSWarner Loshthe identifier should be formed by attaching that provider's class 119*24d79e9bSWarner Loshname to the ident of the underlying provider, 120*24d79e9bSWarner Losh.It 121*24d79e9bSWarner Loshident is an NUL-terminated ASCII string (is printable), 122*24d79e9bSWarner Losh.It 123*24d79e9bSWarner Loshident is optional and applications can't relay on its presence. 124*24d79e9bSWarner Losh.El 125*24d79e9bSWarner Losh.It Dv DIOCGPROVIDERNAME 126*24d79e9bSWarner Losh.Pq Li "char[MAXPATHLEN]" 127*24d79e9bSWarner LoshStore the provider name for the device in a buffer. 128*24d79e9bSWarner LoshThe buffer must be at least MAXPATHLEN bytes long. 129*24d79e9bSWarner Losh.It Dv DIOCGSTRIPESIZE 130*24d79e9bSWarner Losh.Pq Li "off_t" 131*24d79e9bSWarner LoshGet the size of the device's optimal access block in bytes. 132*24d79e9bSWarner LoshThis should be a multiple of the sector size. 133*24d79e9bSWarner Losh.It Dv DIOCGSTRIPEOFFSET 134*24d79e9bSWarner Losh.Pq Li "off_t" 135*24d79e9bSWarner LoshGet the offset of the first device's optimal access block in bytes. 136*24d79e9bSWarner LoshThis should be a multiple of the sector size. 137*24d79e9bSWarner Losh.It Dv DIOCGPHYSPATH 138*24d79e9bSWarner Losh.Pq Li "char[MAXPATHLEN]" 139*24d79e9bSWarner LoshGet a string defining the physical path for a given provider. 140*24d79e9bSWarner LoshThis has similar rules to ident, but is intended to uniquely 141*24d79e9bSWarner Loshidentify the physical location of the device, not the current 142*24d79e9bSWarner Loshoccupant of that location. 143*24d79e9bSWarner LoshThe buffer must be at least MAXPATHLEN bytes long. 144*24d79e9bSWarner Losh.It Dv DIOCGATTR 145*24d79e9bSWarner Losh.Pq Li "struct diocgattr_arg" 146*24d79e9bSWarner Losh.Bd -literal -offset indent 147*24d79e9bSWarner Loshstruct diocgattr_arg { 148*24d79e9bSWarner Losh char name[64]; 149*24d79e9bSWarner Losh int len; 150*24d79e9bSWarner Losh union { 151*24d79e9bSWarner Losh char str[DISK_IDENT_SIZE]; 152*24d79e9bSWarner Losh off_t off; 153*24d79e9bSWarner Losh int i; 154*24d79e9bSWarner Losh uint16_t u16; 155*24d79e9bSWarner Losh } value; 156*24d79e9bSWarner Losh}; 157*24d79e9bSWarner Losh.Ed 158*24d79e9bSWarner LoshGet a geom attribute from the provider. 159*24d79e9bSWarner LoshFormat of the returned data is specific to the attribute. 160*24d79e9bSWarner Losh.It Dv DIOCZONECMD 161*24d79e9bSWarner Losh.Pq Li "struct disk_zone_arg" 162*24d79e9bSWarner LoshSend disk zone commands. 163*24d79e9bSWarner Losh.It Dv DIOCSKERNELDUMP 164*24d79e9bSWarner Losh.Pq Li "struct diocskerneldump_arg" 165*24d79e9bSWarner LoshEnable/Disable the device for kernel core dumps. 166*24d79e9bSWarner Losh.It Dv DIOCGKERNELDUMP 167*24d79e9bSWarner Losh.Pq Li "struct diocskerneldump_arg" 168*24d79e9bSWarner LoshGet current kernel netdump configuration details for a given index. 169*24d79e9bSWarner Losh.Bd -literal -offset indent 170*24d79e9bSWarner Losh/* 171*24d79e9bSWarner Losh * Sentinel values for kda_index. 172*24d79e9bSWarner Losh * 173*24d79e9bSWarner Losh * If kda_index is KDA_REMOVE_ALL, all dump configurations are cleared. 174*24d79e9bSWarner Losh * 175*24d79e9bSWarner Losh * If kda_index is KDA_REMOVE_DEV, all dump configurations for the specified 176*24d79e9bSWarner Losh * device are cleared. 177*24d79e9bSWarner Losh * 178*24d79e9bSWarner Losh * If kda_index is KDA_REMOVE, only the specified dump configuration for the 179*24d79e9bSWarner Losh * given device is removed from the list of fallback dump configurations. 180*24d79e9bSWarner Losh * 181*24d79e9bSWarner Losh * If kda_index is KDA_APPEND, the dump configuration is added after all 182*24d79e9bSWarner Losh * existing dump configurations. 183*24d79e9bSWarner Losh * 184*24d79e9bSWarner Losh * Otherwise, the new configuration is inserted into the fallback dump list at 185*24d79e9bSWarner Losh * index 'kda_index'. 186*24d79e9bSWarner Losh */ 187*24d79e9bSWarner Losh#define KDA_REMOVE UINT8_MAX 188*24d79e9bSWarner Losh#define KDA_REMOVE_ALL (UINT8_MAX - 1) 189*24d79e9bSWarner Losh#define KDA_REMOVE_DEV (UINT8_MAX - 2) 190*24d79e9bSWarner Losh#define KDA_APPEND (UINT8_MAX - 3) 191*24d79e9bSWarner Loshstruct diocskerneldump_arg { 192*24d79e9bSWarner Losh uint8_t kda_index; 193*24d79e9bSWarner Losh uint8_t kda_compression; 194*24d79e9bSWarner Losh uint8_t kda_encryption; 195*24d79e9bSWarner Losh uint8_t kda_key[KERNELDUMP_KEY_MAX_SIZE]; 196*24d79e9bSWarner Losh uint32_t kda_encryptedkeysize; 197*24d79e9bSWarner Losh uint8_t *kda_encryptedkey; 198*24d79e9bSWarner Losh char kda_iface[IFNAMSIZ]; 199*24d79e9bSWarner Losh union kd_ip kda_server; 200*24d79e9bSWarner Losh union kd_ip kda_client; 201*24d79e9bSWarner Losh union kd_ip kda_gateway; 202*24d79e9bSWarner Losh uint8_t kda_af; 203*24d79e9bSWarner Losh}; 204*24d79e9bSWarner Losh.Ed 205*24d79e9bSWarner Losh.El 206*24d79e9bSWarner Losh.Sh HISTORY 207*24d79e9bSWarner LoshThe manual page was written by 208*24d79e9bSWarner Losh.An M Warner Losh Aq Mt imp@FreeBSD.org 209*24d79e9bSWarner Loshfrom text largely derived from 210*24d79e9bSWarner Losh.In sys/disk.h . 211