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