1139825Simp/*-
250565Sphk * ----------------------------------------------------------------------------
350565Sphk * "THE BEER-WARE LICENSE" (Revision 42):
450565Sphk * <phk@FreeBSD.ORG> wrote this file.  As long as you retain this notice you
550565Sphk * can do whatever you want with this stuff. If we meet some day, and you think
650565Sphk * this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
750565Sphk * ----------------------------------------------------------------------------
850565Sphk *
950565Sphk * $FreeBSD$
1050565Sphk *
1150565Sphk */
1250565Sphk
1350565Sphk#ifndef _SYS_DISK_H_
1450565Sphk#define	_SYS_DISK_H_
1550565Sphk
1694182Sphk#include <sys/ioccom.h>
1794182Sphk
1894182Sphk#ifdef _KERNEL
1950565Sphk
20110119Sphk#ifndef _SYS_CONF_H_
21110119Sphk#include <sys/conf.h>	/* XXX: temporary to avoid breakage */
22110119Sphk#endif
23110119Sphk
24103675Sphkvoid disk_err(struct bio *bp, const char *what, int blkdone, int nl);
2550565Sphk
2694182Sphk#endif
2794182Sphk
28210365Strasz#define	DIOCGSECTORSIZE	_IOR('d', 128, u_int)
29210365Strasz	/*
30210365Strasz	 * Get the sector size of the device in bytes.  The sector size is the
31210365Strasz	 * smallest unit of data which can be transferred from this device.
32210365Strasz	 * Usually this is a power of 2 but it might not be (i.e. CDROM audio).
3394282Sphk	 */
3494282Sphk
35210365Strasz#define	DIOCGMEDIASIZE	_IOR('d', 129, off_t)	/* Get media size in bytes */
36210365Strasz	/*
3794282Sphk	 * Get the size of the entire device in bytes.  This should be a
38210365Strasz	 * multiple of the sector size.
3994282Sphk	 */
4094282Sphk
41210365Strasz#define	DIOCGFWSECTORS	_IOR('d', 130, u_int)	/* Get firmware's sectorcount */
42210365Strasz	/*
43210365Strasz	 * Get the firmware's notion of number of sectors per track.  This
4494282Sphk	 * value is mostly used for compatibility with various ill designed
4594282Sphk	 * disk label formats.  Don't use it unless you have to.
4694282Sphk	 */
4794282Sphk
48210365Strasz#define	DIOCGFWHEADS	_IOR('d', 131, u_int)	/* Get firmware's headcount */
49210365Strasz	/*
5094282Sphk	 * Get the firmwares notion of number of heads per cylinder.  This
5194282Sphk	 * value is mostly used for compatibility with various ill designed
5294282Sphk	 * disk label formats.  Don't use it unless you have to.
5394282Sphk	 */
5494282Sphk
55210365Strasz#define	DIOCSKERNELDUMP _IOW('d', 133, u_int)	/* Set/Clear kernel dumps */
56210365Strasz	/*
5794282Sphk	 * Enable/Disable (the argument is boolean) the device for kernel
5894282Sphk	 * core dumps.
5994282Sphk	 */
6094282Sphk
61210365Strasz#define	DIOCGFRONTSTUFF _IOR('d', 134, off_t)
62210365Strasz	/*
6394287Sphk	 * Many disk formats have some amount of space reserved at the
6494287Sphk	 * start of the disk to hold bootblocks, various disklabels and
6594287Sphk	 * similar stuff.  This ioctl returns the number of such bytes
6694287Sphk	 * which may apply to the device.
6794287Sphk	 */
6894287Sphk
69169284Spjd#define	DIOCGFLUSH _IO('d', 135)		/* Flush write cache */
70210365Strasz	/*
71169284Spjd	 * Flush write cache of the device.
72169284Spjd	 */
73169284Spjd
74169284Spjd#define	DIOCGDELETE _IOW('d', 136, off_t[2])	/* Delete data */
75210365Strasz	/*
76169284Spjd	 * Mark data on the device as unused.
77169284Spjd	 */
78169284Spjd
79169284Spjd#define	DISK_IDENT_SIZE	256
80169284Spjd#define	DIOCGIDENT _IOR('d', 137, char[DISK_IDENT_SIZE])
81210226Strasz	/*-
82169284Spjd	 * Get the ident of the given provider. Ident is (most of the time)
83169284Spjd	 * a uniqe and fixed provider's identifier. Ident's properties are as
84169284Spjd	 * follow:
85169284Spjd	 * - ident value is preserved between reboots,
86169284Spjd	 * - provider can be detached/attached and ident is preserved,
87169284Spjd	 * - provider's name can change - ident can't,
88169284Spjd	 * - ident value should not be based on on-disk metadata; in other
89169284Spjd	 *   words copying whole data from one disk to another should not
90169284Spjd	 *   yield the same ident for the other disk,
91169284Spjd	 * - there could be more than one provider with the same ident, but
92169284Spjd	 *   only if they point at exactly the same physical storage, this is
93169284Spjd	 *   the case for multipathing for example,
94169284Spjd	 * - GEOM classes that consumes single providers and provide single
95169284Spjd	 *   providers, like geli, gbde, should just attach class name to the
96169284Spjd	 *   ident of the underlying provider,
97169284Spjd	 * - ident is an ASCII string (is printable),
98169284Spjd	 * - ident is optional and applications can't relay on its presence.
99169284Spjd	 */
100169284Spjd
101210365Strasz#define	DIOCGPROVIDERNAME _IOR('d', 138, char[MAXPATHLEN])
102210365Strasz	/*
103182843Slulf	 * Store the provider name, given a device path, in a buffer. The buffer
104182843Slulf	 * must be at least MAXPATHLEN bytes long.
105182843Slulf	 */
106182843Slulf
107210365Strasz#define	DIOCGSTRIPESIZE	_IOR('d', 139, off_t)	/* Get stripe size in bytes */
108210365Strasz	/*
109200934Smav	 * Get the size of the device's optimal access block in bytes.
110210365Strasz	 * This should be a multiple of the sector size.
111200934Smav	 */
112200934Smav
113210365Strasz#define	DIOCGSTRIPEOFFSET _IOR('d', 140, off_t)	/* Get stripe offset in bytes */
114210365Strasz	/*
115200934Smav	 * Get the offset of the first device's optimal access block in bytes.
116210365Strasz	 * This should be a multiple of the sector size.
117200934Smav	 */
118200934Smav
119223089Sgibbs#define	DIOCGPHYSPATH _IOR('d', 141, char[MAXPATHLEN])
120223089Sgibbs	/*
121223089Sgibbs	 * Get a string defining the physical path for a given provider.
122223089Sgibbs	 * This has similar rules to ident, but is intended to uniquely
123223089Sgibbs	 * identify the physical location of the device, not the current
124223089Sgibbs	 * occupant of that location.
125223089Sgibbs	 */
126223089Sgibbs
12750565Sphk#endif /* _SYS_DISK_H_ */
128