124d79e9bSWarner Losh.\" Copyright (c) 2020 M. Warner Losh <imp@FreeBSD.org> 224d79e9bSWarner Losh.\" 324d79e9bSWarner Losh.\" Redistribution and use in source and binary forms, with or without 424d79e9bSWarner Losh.\" modification, are permitted provided that the following conditions 524d79e9bSWarner Losh.\" are met: 624d79e9bSWarner Losh.\" 1. Redistributions of source code must retain the above copyright 724d79e9bSWarner Losh.\" notice, this list of conditions and the following disclaimer. 824d79e9bSWarner Losh.\" 924d79e9bSWarner Losh.\" 2. Redistributions in binary form must reproduce the above copyright 1024d79e9bSWarner Losh.\" notice, this list of conditions and the following disclaimer in the 1124d79e9bSWarner Losh.\" documentation and/or other materials provided with the distribution. 1224d79e9bSWarner Losh.\" 1324d79e9bSWarner Losh.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1424d79e9bSWarner Losh.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1524d79e9bSWarner Losh.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1624d79e9bSWarner Losh.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1724d79e9bSWarner Losh.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1824d79e9bSWarner Losh.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 1924d79e9bSWarner Losh.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2024d79e9bSWarner Losh.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2124d79e9bSWarner Losh.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2224d79e9bSWarner Losh.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2324d79e9bSWarner Losh.\" SUCH DAMAGE. 2424d79e9bSWarner Losh.\" 2524d79e9bSWarner Losh.Dd November 20, 2020 2624d79e9bSWarner Losh.Dt disk 4 2724d79e9bSWarner Losh.Os 2824d79e9bSWarner Losh.Sh NAME 2924d79e9bSWarner Losh.Nm disk 3024d79e9bSWarner Losh.Nd common disk interfaces 3124d79e9bSWarner Losh.Sh SYNOPSIS 3224d79e9bSWarner Losh.Cd device cd 3324d79e9bSWarner Losh.Sh DESCRIPTION 3424d79e9bSWarner LoshCommon block device IOCTLs 3524d79e9bSWarner Losh.Pp 3624d79e9bSWarner LoshAll the block devices in the system should support these disk 3724d79e9bSWarner Losh.Xr ioctl 2 3824d79e9bSWarner Loshcommands defined here. 3924d79e9bSWarner LoshMuch of this information is also available via the 4024d79e9bSWarner Losh.Xr geom 2 4124d79e9bSWarner Loshattributes. 4224d79e9bSWarner Losh.Sh IOCTLS 4324d79e9bSWarner LoshThe following 4424d79e9bSWarner Losh.Xr ioctl 2 4524d79e9bSWarner Loshcalls apply to disk drives, and are defined 4624d79e9bSWarner Loshin the 4724d79e9bSWarner Losh.In sys/disk.h 4824d79e9bSWarner Loshheader file. 4924d79e9bSWarner Losh.Bl -tag -width DIOCGPROVIDERNAME 5024d79e9bSWarner Losh.It Dv DIOCGSECTORSIZE 5124d79e9bSWarner Losh.Pq Li "u_int" 5224d79e9bSWarner LoshGet the sector or block size of the device in bytes. 5324d79e9bSWarner LoshThe sector size is the smallest unit of data which can be transferred 5424d79e9bSWarner Loshfrom this device. 5524d79e9bSWarner LoshThis is usually a power of 2 but it might not be (e.g. CDROM audio). 5624d79e9bSWarner LoshOperations to block devices such as 5724d79e9bSWarner Losh.Xr lseek 2 , 5824d79e9bSWarner Losh.Xr read 2 , 5924d79e9bSWarner Loshand 60*a51584a2SGraham Percival.Xr write 2 6124d79e9bSWarner Loshmay only be performed at file offsets that are integral multiple of 6224d79e9bSWarner Loshthis size. 6324d79e9bSWarner Losh.It Dv DIOCGMEDIASIZE 6424d79e9bSWarner Losh.Pq Li "off_t" 6524d79e9bSWarner LoshGet the size of the entire device in bytes. 6624d79e9bSWarner LoshThis should be a multiple of the sector size. 6724d79e9bSWarner Losh.It Dv DIOCGFWSECTORS 6824d79e9bSWarner Losh.Pq Li "u_int" 6924d79e9bSWarner LoshReturn the firmware's notion of number of sectors per track. 7024d79e9bSWarner LoshThis value is mostly used for compatibility with various ill designed 7124d79e9bSWarner Loshdisk label formats. 7224d79e9bSWarner LoshUse this value only when absolutely required. 7324d79e9bSWarner LoshIts interpretation and use is largely obsolete. 7424d79e9bSWarner Losh.It Dv DIOCGFWHEADS 7524d79e9bSWarner Losh.Pq Li "u_int" 7624d79e9bSWarner LoshReturn the firmware's notion of number of heads per cylinder. 7724d79e9bSWarner LoshThis value is mostly used for compatibility with various ill designed 7824d79e9bSWarner Loshdisk label formats. 7924d79e9bSWarner LoshUse this value only when absolutely required. 8024d79e9bSWarner LoshIts interpretation and use is largely obsolete. 8124d79e9bSWarner Losh.It Dv DIOCGFLUSH 8224d79e9bSWarner LoshFlush write cache of the device. 8324d79e9bSWarner Losh.It Dv DIOCGDELETE 8424d79e9bSWarner Losh.Pq Li "off_t[2]" 8524d79e9bSWarner LoshMark data on the device as unused. 8624d79e9bSWarner LoshThe first element is the offset to start deleting. 8724d79e9bSWarner LoshThe second element is the length to delete. 8824d79e9bSWarner LoshProviders may use this information to free storage or instruct storage 8924d79e9bSWarner Loshdevices the contents can be discarded. 9024d79e9bSWarner Losh.It Dv DIOCGIDENT 9124d79e9bSWarner Losh.Pq Li "char[DISK_IDENT_SIZE]" 9224d79e9bSWarner LoshGet the ident for this provider. 9324d79e9bSWarner LoshIdent is a unique and fixed identifier for this provider. 9424d79e9bSWarner LoshIdent's properties are as follow: 9524d79e9bSWarner Losh.Bl -bullet 9624d79e9bSWarner Losh.It 9724d79e9bSWarner Loshpreserved between reboots, 9824d79e9bSWarner Losh.It 9924d79e9bSWarner Loshpreserved across a provider being detached/attached, 10024d79e9bSWarner Losh.It 10124d79e9bSWarner Loshprovider's name can change - ident can't, 10224d79e9bSWarner Losh.It 10324d79e9bSWarner Loshident value should not be based on on-disk metadata; in other 10424d79e9bSWarner Loshwords, copying whole data from one disk to another should not 10524d79e9bSWarner Loshyield the same ident for the other disk, 10624d79e9bSWarner Losh.It 10724d79e9bSWarner Loshthere can be more than one provider with the same ident, but 10824d79e9bSWarner Loshonly if they point at exactly the same physical storage, this is 10924d79e9bSWarner Loshthe case for multipathing for example, 11024d79e9bSWarner Losh.It 11124d79e9bSWarner LoshGEOM classes that consume a single provider and provide single 11224d79e9bSWarner Loshprovider, like 11324d79e9bSWarner Losh.Xr geli 8 , 11424d79e9bSWarner Loshthe identifier should be formed by attaching that provider's class 11524d79e9bSWarner Loshname to the ident of the underlying provider, 11624d79e9bSWarner Losh.It 11724d79e9bSWarner Loshident is an NUL-terminated ASCII string (is printable), 11824d79e9bSWarner Losh.It 11924d79e9bSWarner Loshident is optional and applications can't relay on its presence. 12024d79e9bSWarner Losh.El 12124d79e9bSWarner Losh.It Dv DIOCGPROVIDERNAME 12224d79e9bSWarner Losh.Pq Li "char[MAXPATHLEN]" 12324d79e9bSWarner LoshStore the provider name for the device in a buffer. 12424d79e9bSWarner LoshThe buffer must be at least MAXPATHLEN bytes long. 12524d79e9bSWarner Losh.It Dv DIOCGSTRIPESIZE 12624d79e9bSWarner Losh.Pq Li "off_t" 12724d79e9bSWarner LoshGet the size of the device's optimal access block in bytes. 12824d79e9bSWarner LoshThis should be a multiple of the sector size. 12924d79e9bSWarner Losh.It Dv DIOCGSTRIPEOFFSET 13024d79e9bSWarner Losh.Pq Li "off_t" 13124d79e9bSWarner LoshGet the offset of the first device's optimal access block in bytes. 13224d79e9bSWarner LoshThis should be a multiple of the sector size. 13324d79e9bSWarner Losh.It Dv DIOCGPHYSPATH 13424d79e9bSWarner Losh.Pq Li "char[MAXPATHLEN]" 13524d79e9bSWarner LoshGet a string defining the physical path for a given provider. 13624d79e9bSWarner LoshThis has similar rules to ident, but is intended to uniquely 13724d79e9bSWarner Loshidentify the physical location of the device, not the current 13824d79e9bSWarner Loshoccupant of that location. 13924d79e9bSWarner LoshThe buffer must be at least MAXPATHLEN bytes long. 14024d79e9bSWarner Losh.It Dv DIOCGATTR 14124d79e9bSWarner Losh.Pq Li "struct diocgattr_arg" 14224d79e9bSWarner Losh.Bd -literal -offset indent 14324d79e9bSWarner Loshstruct diocgattr_arg { 14424d79e9bSWarner Losh char name[64]; 14524d79e9bSWarner Losh int len; 14624d79e9bSWarner Losh union { 14724d79e9bSWarner Losh char str[DISK_IDENT_SIZE]; 14824d79e9bSWarner Losh off_t off; 14924d79e9bSWarner Losh int i; 15024d79e9bSWarner Losh uint16_t u16; 15124d79e9bSWarner Losh } value; 15224d79e9bSWarner Losh}; 15324d79e9bSWarner Losh.Ed 15424d79e9bSWarner LoshGet a geom attribute from the provider. 15524d79e9bSWarner LoshFormat of the returned data is specific to the attribute. 15624d79e9bSWarner Losh.It Dv DIOCZONECMD 15724d79e9bSWarner Losh.Pq Li "struct disk_zone_arg" 15824d79e9bSWarner LoshSend disk zone commands. 15924d79e9bSWarner Losh.It Dv DIOCSKERNELDUMP 16024d79e9bSWarner Losh.Pq Li "struct diocskerneldump_arg" 16124d79e9bSWarner LoshEnable/Disable the device for kernel core dumps. 16224d79e9bSWarner Losh.It Dv DIOCGKERNELDUMP 16324d79e9bSWarner Losh.Pq Li "struct diocskerneldump_arg" 16424d79e9bSWarner LoshGet current kernel netdump configuration details for a given index. 16524d79e9bSWarner Losh.Bd -literal -offset indent 16624d79e9bSWarner Losh/* 16724d79e9bSWarner Losh * Sentinel values for kda_index. 16824d79e9bSWarner Losh * 16924d79e9bSWarner Losh * If kda_index is KDA_REMOVE_ALL, all dump configurations are cleared. 17024d79e9bSWarner Losh * 17124d79e9bSWarner Losh * If kda_index is KDA_REMOVE_DEV, all dump configurations for the specified 17224d79e9bSWarner Losh * device are cleared. 17324d79e9bSWarner Losh * 17424d79e9bSWarner Losh * If kda_index is KDA_REMOVE, only the specified dump configuration for the 17524d79e9bSWarner Losh * given device is removed from the list of fallback dump configurations. 17624d79e9bSWarner Losh * 17724d79e9bSWarner Losh * If kda_index is KDA_APPEND, the dump configuration is added after all 17824d79e9bSWarner Losh * existing dump configurations. 17924d79e9bSWarner Losh * 18024d79e9bSWarner Losh * Otherwise, the new configuration is inserted into the fallback dump list at 18124d79e9bSWarner Losh * index 'kda_index'. 18224d79e9bSWarner Losh */ 18324d79e9bSWarner Losh#define KDA_REMOVE UINT8_MAX 18424d79e9bSWarner Losh#define KDA_REMOVE_ALL (UINT8_MAX - 1) 18524d79e9bSWarner Losh#define KDA_REMOVE_DEV (UINT8_MAX - 2) 18624d79e9bSWarner Losh#define KDA_APPEND (UINT8_MAX - 3) 18724d79e9bSWarner Loshstruct diocskerneldump_arg { 18824d79e9bSWarner Losh uint8_t kda_index; 18924d79e9bSWarner Losh uint8_t kda_compression; 19024d79e9bSWarner Losh uint8_t kda_encryption; 19124d79e9bSWarner Losh uint8_t kda_key[KERNELDUMP_KEY_MAX_SIZE]; 19224d79e9bSWarner Losh uint32_t kda_encryptedkeysize; 19324d79e9bSWarner Losh uint8_t *kda_encryptedkey; 19424d79e9bSWarner Losh char kda_iface[IFNAMSIZ]; 19524d79e9bSWarner Losh union kd_ip kda_server; 19624d79e9bSWarner Losh union kd_ip kda_client; 19724d79e9bSWarner Losh union kd_ip kda_gateway; 19824d79e9bSWarner Losh uint8_t kda_af; 19924d79e9bSWarner Losh}; 20024d79e9bSWarner Losh.Ed 20124d79e9bSWarner Losh.El 20224d79e9bSWarner Losh.Sh HISTORY 20324d79e9bSWarner LoshThe manual page was written by 20424d79e9bSWarner Losh.An M Warner Losh Aq Mt imp@FreeBSD.org 20524d79e9bSWarner Loshfrom text largely derived from 20624d79e9bSWarner Losh.In sys/disk.h . 207