199767f8919635c4928607450d9e0abb932109ceToomas Soome/*-
199767f8919635c4928607450d9e0abb932109ceToomas Soome * ----------------------------------------------------------------------------
199767f8919635c4928607450d9e0abb932109ceToomas Soome * "THE BEER-WARE LICENSE" (Revision 42):
199767f8919635c4928607450d9e0abb932109ceToomas Soome * <phk@FreeBSD.ORG> wrote this file. As long as you retain this notice you
199767f8919635c4928607450d9e0abb932109ceToomas Soome * can do whatever you want with this stuff. If we meet some day, and you think
199767f8919635c4928607450d9e0abb932109ceToomas Soome * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
199767f8919635c4928607450d9e0abb932109ceToomas Soome * ----------------------------------------------------------------------------
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * $FreeBSD$
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _SYS_DISK_H_
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define _SYS_DISK_H_
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include <sys/ioccom.h>
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include <sys/types.h>
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifdef _KERNEL
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _SYS_CONF_H_
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include <sys/conf.h> /* XXX: temporary to avoid breakage */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid disk_err(struct bio *bp, const char *what, int blkdone, int nl);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define DIOCGSECTORSIZE _IOR('d', 128, u_int)
199767f8919635c4928607450d9e0abb932109ceToomas Soome /*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Get the sector size of the device in bytes. The sector size is the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * smallest unit of data which can be transferred from this device.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Usually this is a power of 2 but it might not be (i.e. CDROM audio).
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define DIOCGMEDIASIZE _IOR('d', 129, off_t) /* Get media size in bytes */
199767f8919635c4928607450d9e0abb932109ceToomas Soome /*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Get the size of the entire device in bytes. This should be a
199767f8919635c4928607450d9e0abb932109ceToomas Soome * multiple of the sector size.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define DIOCGFWSECTORS _IOR('d', 130, u_int) /* Get firmware's sectorcount */
199767f8919635c4928607450d9e0abb932109ceToomas Soome /*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Get the firmware's notion of number of sectors per track. This
199767f8919635c4928607450d9e0abb932109ceToomas Soome * value is mostly used for compatibility with various ill designed
199767f8919635c4928607450d9e0abb932109ceToomas Soome * disk label formats. Don't use it unless you have to.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define DIOCGFWHEADS _IOR('d', 131, u_int) /* Get firmware's headcount */
199767f8919635c4928607450d9e0abb932109ceToomas Soome /*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Get the firmwares notion of number of heads per cylinder. This
199767f8919635c4928607450d9e0abb932109ceToomas Soome * value is mostly used for compatibility with various ill designed
199767f8919635c4928607450d9e0abb932109ceToomas Soome * disk label formats. Don't use it unless you have to.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define DIOCSKERNELDUMP _IOW('d', 133, u_int) /* Set/Clear kernel dumps */
199767f8919635c4928607450d9e0abb932109ceToomas Soome /*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Enable/Disable (the argument is boolean) the device for kernel
199767f8919635c4928607450d9e0abb932109ceToomas Soome * core dumps.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define DIOCGFRONTSTUFF _IOR('d', 134, off_t)
199767f8919635c4928607450d9e0abb932109ceToomas Soome /*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Many disk formats have some amount of space reserved at the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * start of the disk to hold bootblocks, various disklabels and
199767f8919635c4928607450d9e0abb932109ceToomas Soome * similar stuff. This ioctl returns the number of such bytes
199767f8919635c4928607450d9e0abb932109ceToomas Soome * which may apply to the device.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define DIOCGFLUSH _IO('d', 135) /* Flush write cache */
199767f8919635c4928607450d9e0abb932109ceToomas Soome /*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Flush write cache of the device.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define DIOCGDELETE _IOW('d', 136, off_t[2]) /* Delete data */
199767f8919635c4928607450d9e0abb932109ceToomas Soome /*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Mark data on the device as unused.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define DISK_IDENT_SIZE 256
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define DIOCGIDENT _IOR('d', 137, char[DISK_IDENT_SIZE])
199767f8919635c4928607450d9e0abb932109ceToomas Soome /*-
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Get the ident of the given provider. Ident is (most of the time)
199767f8919635c4928607450d9e0abb932109ceToomas Soome * a uniqe and fixed provider's identifier. Ident's properties are as
199767f8919635c4928607450d9e0abb932109ceToomas Soome * follow:
199767f8919635c4928607450d9e0abb932109ceToomas Soome * - ident value is preserved between reboots,
199767f8919635c4928607450d9e0abb932109ceToomas Soome * - provider can be detached/attached and ident is preserved,
199767f8919635c4928607450d9e0abb932109ceToomas Soome * - provider's name can change - ident can't,
199767f8919635c4928607450d9e0abb932109ceToomas Soome * - ident value should not be based on on-disk metadata; in other
199767f8919635c4928607450d9e0abb932109ceToomas Soome * words copying whole data from one disk to another should not
199767f8919635c4928607450d9e0abb932109ceToomas Soome * yield the same ident for the other disk,
199767f8919635c4928607450d9e0abb932109ceToomas Soome * - there could be more than one provider with the same ident, but
199767f8919635c4928607450d9e0abb932109ceToomas Soome * only if they point at exactly the same physical storage, this is
199767f8919635c4928607450d9e0abb932109ceToomas Soome * the case for multipathing for example,
199767f8919635c4928607450d9e0abb932109ceToomas Soome * - GEOM classes that consumes single providers and provide single
199767f8919635c4928607450d9e0abb932109ceToomas Soome * providers, like geli, gbde, should just attach class name to the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * ident of the underlying provider,
199767f8919635c4928607450d9e0abb932109ceToomas Soome * - ident is an ASCII string (is printable),
199767f8919635c4928607450d9e0abb932109ceToomas Soome * - ident is optional and applications can't relay on its presence.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define DIOCGPROVIDERNAME _IOR('d', 138, char[MAXPATHLEN])
199767f8919635c4928607450d9e0abb932109ceToomas Soome /*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Store the provider name, given a device path, in a buffer. The buffer
199767f8919635c4928607450d9e0abb932109ceToomas Soome * must be at least MAXPATHLEN bytes long.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define DIOCGSTRIPESIZE _IOR('d', 139, off_t) /* Get stripe size in bytes */
199767f8919635c4928607450d9e0abb932109ceToomas Soome /*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Get the size of the device's optimal access block in bytes.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * This should be a multiple of the sector size.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define DIOCGSTRIPEOFFSET _IOR('d', 140, off_t) /* Get stripe offset in bytes */
199767f8919635c4928607450d9e0abb932109ceToomas Soome /*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Get the offset of the first device's optimal access block in bytes.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * This should be a multiple of the sector size.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define DIOCGPHYSPATH _IOR('d', 141, char[MAXPATHLEN])
199767f8919635c4928607450d9e0abb932109ceToomas Soome /*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Get a string defining the physical path for a given provider.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * This has similar rules to ident, but is intended to uniquely
199767f8919635c4928607450d9e0abb932109ceToomas Soome * identify the physical location of the device, not the current
199767f8919635c4928607450d9e0abb932109ceToomas Soome * occupant of that location.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomestruct diocgattr_arg {
199767f8919635c4928607450d9e0abb932109ceToomas Soome char name[64];
199767f8919635c4928607450d9e0abb932109ceToomas Soome int len;
199767f8919635c4928607450d9e0abb932109ceToomas Soome union {
199767f8919635c4928607450d9e0abb932109ceToomas Soome char str[DISK_IDENT_SIZE];
199767f8919635c4928607450d9e0abb932109ceToomas Soome off_t off;
199767f8919635c4928607450d9e0abb932109ceToomas Soome int i;
199767f8919635c4928607450d9e0abb932109ceToomas Soome } value;
199767f8919635c4928607450d9e0abb932109ceToomas Soome};
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define DIOCGATTR _IOWR('d', 142, struct diocgattr_arg)
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* _SYS_DISK_H_ */