xref: /illumos-gate/usr/src/boot/sys/sys/disk.h (revision 55fea89d)
1199767f8SToomas Soome /*-
2199767f8SToomas Soome  * ----------------------------------------------------------------------------
3199767f8SToomas Soome  * "THE BEER-WARE LICENSE" (Revision 42):
4199767f8SToomas Soome  * <phk@FreeBSD.ORG> wrote this file.  As long as you retain this notice you
5199767f8SToomas Soome  * can do whatever you want with this stuff. If we meet some day, and you think
6199767f8SToomas Soome  * this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
7199767f8SToomas Soome  * ----------------------------------------------------------------------------
8199767f8SToomas Soome  *
9199767f8SToomas Soome  * $FreeBSD$
10199767f8SToomas Soome  *
11199767f8SToomas Soome  */
12199767f8SToomas Soome 
13199767f8SToomas Soome #ifndef _SYS_DISK_H_
14199767f8SToomas Soome #define	_SYS_DISK_H_
15199767f8SToomas Soome 
16199767f8SToomas Soome #include <sys/ioccom.h>
17199767f8SToomas Soome #include <sys/types.h>
18199767f8SToomas Soome 
19199767f8SToomas Soome #ifdef _KERNEL
20199767f8SToomas Soome 
21199767f8SToomas Soome #ifndef _SYS_CONF_H_
22199767f8SToomas Soome #include <sys/conf.h>	/* XXX: temporary to avoid breakage */
23199767f8SToomas Soome #endif
24199767f8SToomas Soome 
25199767f8SToomas Soome void disk_err(struct bio *bp, const char *what, int blkdone, int nl);
26199767f8SToomas Soome 
27199767f8SToomas Soome #endif
28199767f8SToomas Soome 
29199767f8SToomas Soome #define	DIOCGSECTORSIZE	_IOR('d', 128, u_int)
30199767f8SToomas Soome 	/*
31199767f8SToomas Soome 	 * Get the sector size of the device in bytes.  The sector size is the
32199767f8SToomas Soome 	 * smallest unit of data which can be transferred from this device.
33199767f8SToomas Soome 	 * Usually this is a power of 2 but it might not be (i.e. CDROM audio).
34199767f8SToomas Soome 	 */
35199767f8SToomas Soome 
3679bea51bSToomas Soome #define	DIOCGMEDIASIZE	_IOR('d', 129, uint64_t) /* Get media size in bytes */
37199767f8SToomas Soome 	/*
38199767f8SToomas Soome 	 * Get the size of the entire device in bytes.  This should be a
39199767f8SToomas Soome 	 * multiple of the sector size.
40199767f8SToomas Soome 	 */
41199767f8SToomas Soome 
42199767f8SToomas Soome #define	DIOCGFWSECTORS	_IOR('d', 130, u_int)	/* Get firmware's sectorcount */
43199767f8SToomas Soome 	/*
44199767f8SToomas Soome 	 * Get the firmware's notion of number of sectors per track.  This
45199767f8SToomas Soome 	 * value is mostly used for compatibility with various ill designed
46199767f8SToomas Soome 	 * disk label formats.  Don't use it unless you have to.
47199767f8SToomas Soome 	 */
48199767f8SToomas Soome 
49199767f8SToomas Soome #define	DIOCGFWHEADS	_IOR('d', 131, u_int)	/* Get firmware's headcount */
50199767f8SToomas Soome 	/*
51199767f8SToomas Soome 	 * Get the firmwares notion of number of heads per cylinder.  This
52199767f8SToomas Soome 	 * value is mostly used for compatibility with various ill designed
53199767f8SToomas Soome 	 * disk label formats.  Don't use it unless you have to.
54199767f8SToomas Soome 	 */
55199767f8SToomas Soome 
56199767f8SToomas Soome #define	DIOCSKERNELDUMP _IOW('d', 133, u_int)	/* Set/Clear kernel dumps */
57199767f8SToomas Soome 	/*
58199767f8SToomas Soome 	 * Enable/Disable (the argument is boolean) the device for kernel
59199767f8SToomas Soome 	 * core dumps.
60199767f8SToomas Soome 	 */
61*55fea89dSDan Cross 
62199767f8SToomas Soome #define	DIOCGFRONTSTUFF _IOR('d', 134, off_t)
63199767f8SToomas Soome 	/*
64199767f8SToomas Soome 	 * Many disk formats have some amount of space reserved at the
65199767f8SToomas Soome 	 * start of the disk to hold bootblocks, various disklabels and
66199767f8SToomas Soome 	 * similar stuff.  This ioctl returns the number of such bytes
67199767f8SToomas Soome 	 * which may apply to the device.
68199767f8SToomas Soome 	 */
69199767f8SToomas Soome 
70199767f8SToomas Soome #define	DIOCGFLUSH _IO('d', 135)		/* Flush write cache */
71199767f8SToomas Soome 	/*
72199767f8SToomas Soome 	 * Flush write cache of the device.
73199767f8SToomas Soome 	 */
74199767f8SToomas Soome 
75199767f8SToomas Soome #define	DIOCGDELETE _IOW('d', 136, off_t[2])	/* Delete data */
76199767f8SToomas Soome 	/*
77199767f8SToomas Soome 	 * Mark data on the device as unused.
78199767f8SToomas Soome 	 */
79199767f8SToomas Soome 
80199767f8SToomas Soome #define	DISK_IDENT_SIZE	256
81199767f8SToomas Soome #define	DIOCGIDENT _IOR('d', 137, char[DISK_IDENT_SIZE])
82199767f8SToomas Soome 	/*-
83199767f8SToomas Soome 	 * Get the ident of the given provider. Ident is (most of the time)
84199767f8SToomas Soome 	 * a uniqe and fixed provider's identifier. Ident's properties are as
85199767f8SToomas Soome 	 * follow:
86199767f8SToomas Soome 	 * - ident value is preserved between reboots,
87199767f8SToomas Soome 	 * - provider can be detached/attached and ident is preserved,
88199767f8SToomas Soome 	 * - provider's name can change - ident can't,
89199767f8SToomas Soome 	 * - ident value should not be based on on-disk metadata; in other
90199767f8SToomas Soome 	 *   words copying whole data from one disk to another should not
91199767f8SToomas Soome 	 *   yield the same ident for the other disk,
92199767f8SToomas Soome 	 * - there could be more than one provider with the same ident, but
93199767f8SToomas Soome 	 *   only if they point at exactly the same physical storage, this is
94199767f8SToomas Soome 	 *   the case for multipathing for example,
95199767f8SToomas Soome 	 * - GEOM classes that consumes single providers and provide single
96199767f8SToomas Soome 	 *   providers, like geli, gbde, should just attach class name to the
97199767f8SToomas Soome 	 *   ident of the underlying provider,
98199767f8SToomas Soome 	 * - ident is an ASCII string (is printable),
99199767f8SToomas Soome 	 * - ident is optional and applications can't relay on its presence.
100199767f8SToomas Soome 	 */
101199767f8SToomas Soome 
102199767f8SToomas Soome #define	DIOCGPROVIDERNAME _IOR('d', 138, char[MAXPATHLEN])
103199767f8SToomas Soome 	/*
104199767f8SToomas Soome 	 * Store the provider name, given a device path, in a buffer. The buffer
105199767f8SToomas Soome 	 * must be at least MAXPATHLEN bytes long.
106199767f8SToomas Soome 	 */
107199767f8SToomas Soome 
108199767f8SToomas Soome #define	DIOCGSTRIPESIZE	_IOR('d', 139, off_t)	/* Get stripe size in bytes */
109199767f8SToomas Soome 	/*
110199767f8SToomas Soome 	 * Get the size of the device's optimal access block in bytes.
111199767f8SToomas Soome 	 * This should be a multiple of the sector size.
112199767f8SToomas Soome 	 */
113199767f8SToomas Soome 
114199767f8SToomas Soome #define	DIOCGSTRIPEOFFSET _IOR('d', 140, off_t)	/* Get stripe offset in bytes */
115199767f8SToomas Soome 	/*
116199767f8SToomas Soome 	 * Get the offset of the first device's optimal access block in bytes.
117199767f8SToomas Soome 	 * This should be a multiple of the sector size.
118199767f8SToomas Soome 	 */
119199767f8SToomas Soome 
120199767f8SToomas Soome #define	DIOCGPHYSPATH _IOR('d', 141, char[MAXPATHLEN])
121199767f8SToomas Soome 	/*
122199767f8SToomas Soome 	 * Get a string defining the physical path for a given provider.
123199767f8SToomas Soome 	 * This has similar rules to ident, but is intended to uniquely
124199767f8SToomas Soome 	 * identify the physical location of the device, not the current
125199767f8SToomas Soome 	 * occupant of that location.
126199767f8SToomas Soome 	 */
127199767f8SToomas Soome 
128199767f8SToomas Soome struct diocgattr_arg {
129199767f8SToomas Soome 	char name[64];
130199767f8SToomas Soome 	int len;
131199767f8SToomas Soome 	union {
132199767f8SToomas Soome 		char str[DISK_IDENT_SIZE];
133199767f8SToomas Soome 		off_t off;
134199767f8SToomas Soome 		int i;
135199767f8SToomas Soome 	} value;
136199767f8SToomas Soome };
137199767f8SToomas Soome #define	DIOCGATTR _IOWR('d', 142, struct diocgattr_arg)
138199767f8SToomas Soome 
139199767f8SToomas Soome #endif /* _SYS_DISK_H_ */
140