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