1 /*- 2 * SPDX-License-Identifier: Beerware 3 * 4 * ---------------------------------------------------------------------------- 5 * "THE BEER-WARE LICENSE" (Revision 42): 6 * <phk@FreeBSD.ORG> wrote this file. As long as you retain this notice you 7 * can do whatever you want with this stuff. If we meet some day, and you think 8 * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp 9 * ---------------------------------------------------------------------------- 10 * 11 * $FreeBSD$ 12 * 13 */ 14 15 #ifndef _SYS_DISK_H_ 16 #define _SYS_DISK_H_ 17 18 #include <sys/ioccom.h> 19 #include <sys/kerneldump.h> 20 #include <sys/types.h> 21 #include <sys/disk_zone.h> 22 23 #ifdef _KERNEL 24 25 #ifndef _SYS_CONF_H_ 26 #include <sys/conf.h> /* XXX: temporary to avoid breakage */ 27 #endif 28 29 void disk_err(struct bio *bp, const char *what, int blkdone, int nl); 30 31 #endif 32 33 #define DIOCGSECTORSIZE _IOR('d', 128, u_int) 34 /* 35 * Get the sector size of the device in bytes. The sector size is the 36 * smallest unit of data which can be transferred from this device. 37 * Usually this is a power of 2 but it might not be (i.e. CDROM audio). 38 */ 39 40 #define DIOCGMEDIASIZE _IOR('d', 129, off_t) /* Get media size in bytes */ 41 /* 42 * Get the size of the entire device in bytes. This should be a 43 * multiple of the sector size. 44 */ 45 46 #define DIOCGFWSECTORS _IOR('d', 130, u_int) /* Get firmware's sectorcount */ 47 /* 48 * Get the firmware's notion of number of sectors per track. This 49 * value is mostly used for compatibility with various ill designed 50 * disk label formats. Don't use it unless you have to. 51 */ 52 53 #define DIOCGFWHEADS _IOR('d', 131, u_int) /* Get firmware's headcount */ 54 /* 55 * Get the firmwares notion of number of heads per cylinder. This 56 * value is mostly used for compatibility with various ill designed 57 * disk label formats. Don't use it unless you have to. 58 */ 59 60 #define DIOCSKERNELDUMP_FREEBSD11 _IOW('d', 133, u_int) 61 /* 62 * Enable/Disable (the argument is boolean) the device for kernel 63 * core dumps. 64 */ 65 66 #define DIOCGFRONTSTUFF _IOR('d', 134, off_t) 67 /* 68 * Many disk formats have some amount of space reserved at the 69 * start of the disk to hold bootblocks, various disklabels and 70 * similar stuff. This ioctl returns the number of such bytes 71 * which may apply to the device. 72 */ 73 74 #define DIOCGFLUSH _IO('d', 135) /* Flush write cache */ 75 /* 76 * Flush write cache of the device. 77 */ 78 79 #define DIOCGDELETE _IOW('d', 136, off_t[2]) /* Delete data */ 80 /* 81 * Mark data on the device as unused. 82 */ 83 84 #define DISK_IDENT_SIZE 256 85 #define DIOCGIDENT _IOR('d', 137, char[DISK_IDENT_SIZE]) 86 /*- 87 * Get the ident of the given provider. Ident is (most of the time) 88 * a uniqe and fixed provider's identifier. Ident's properties are as 89 * follow: 90 * - ident value is preserved between reboots, 91 * - provider can be detached/attached and ident is preserved, 92 * - provider's name can change - ident can't, 93 * - ident value should not be based on on-disk metadata; in other 94 * words copying whole data from one disk to another should not 95 * yield the same ident for the other disk, 96 * - there could be more than one provider with the same ident, but 97 * only if they point at exactly the same physical storage, this is 98 * the case for multipathing for example, 99 * - GEOM classes that consumes single providers and provide single 100 * providers, like geli, gbde, should just attach class name to the 101 * ident of the underlying provider, 102 * - ident is an ASCII string (is printable), 103 * - ident is optional and applications can't relay on its presence. 104 */ 105 106 #define DIOCGPROVIDERNAME _IOR('d', 138, char[MAXPATHLEN]) 107 /* 108 * Store the provider name, given a device path, in a buffer. The buffer 109 * must be at least MAXPATHLEN bytes long. 110 */ 111 112 #define DIOCGSTRIPESIZE _IOR('d', 139, off_t) /* Get stripe size in bytes */ 113 /* 114 * Get the size of the device's optimal access block in bytes. 115 * This should be a multiple of the sector size. 116 */ 117 118 #define DIOCGSTRIPEOFFSET _IOR('d', 140, off_t) /* Get stripe offset in bytes */ 119 /* 120 * Get the offset of the first device's optimal access block in bytes. 121 * This should be a multiple of the sector size. 122 */ 123 124 #define DIOCGPHYSPATH _IOR('d', 141, char[MAXPATHLEN]) 125 /* 126 * Get a string defining the physical path for a given provider. 127 * This has similar rules to ident, but is intended to uniquely 128 * identify the physical location of the device, not the current 129 * occupant of that location. 130 */ 131 132 struct diocgattr_arg { 133 char name[64]; 134 int len; 135 union { 136 char str[DISK_IDENT_SIZE]; 137 off_t off; 138 int i; 139 uint16_t u16; 140 } value; 141 }; 142 #define DIOCGATTR _IOWR('d', 142, struct diocgattr_arg) 143 144 #define DIOCZONECMD _IOWR('d', 143, struct disk_zone_args) 145 146 struct diocskerneldump_arg { 147 uint8_t kda_enable; 148 uint8_t kda_compression; 149 uint8_t kda_encryption; 150 uint8_t kda_key[KERNELDUMP_KEY_MAX_SIZE]; 151 uint32_t kda_encryptedkeysize; 152 uint8_t *kda_encryptedkey; 153 }; 154 #define DIOCSKERNELDUMP _IOW('d', 144, struct diocskerneldump_arg) 155 /* 156 * Enable/Disable the device for kernel core dumps. 157 */ 158 159 #endif /* _SYS_DISK_H_ */ 160