disk -- Kernel disk storage API
#include <geom/geom_disk.h>
void
disk_create(int unit, struct disk *disk, int flags, void *unused,
void *unused2);
void
disk_destroy(struct disk *disk);
The disk storage API permits kernel device drivers providing access to
disk-like storage devices to advertise the device to other kernel components,
including GEOM(4), and devfs(5).
Each disk device is described by a struct disk structure, which contains
a variety of parameters for the disk device, function pointers for various
methods that may be performed on the device, as well as private data
storage for the device driver. In addition, some fields are reserved for
use by GEOM in managing access to the device and its statistics. Because
of storage driver framework private data stored in struct disk, instances
of the structure should be allocated out of writable, pre-zero'd memory.
Public fields in the structure will generally be assumed not to change
once the structure is submitted to disk_create(), and so no explicit
locking is employed; drivers that change the values of any of these
fields do so at their own risk.
Memory associated with the struct disk is owned by the device driver, but
should not be released until after the completion of a call to
disk_destroy().
Descriptive Fields [Toc] [Back]
The following fields identify the disk device described by the structure
instance, and must be filled in prior to submitting the structure to
disk_create():
u_int d_flags
Optional flags indicating to the storage framework what optional
features or descriptions the storage device driver supports. Currently
supported flags are DISKFLAG_NOGIANT (maintained by device
driver), DISKFLAG_OPEN (maintained by storage framework), and
DISKFLAG_CANDELETE (maintained by device driver).
const char * d_name
Holds the name of the storage device class, e.g., ``ahd''. This
value typically uniquely identifies a particular driver device, and
must not conflict with devices serviced by other device drivers.
u_int d_unit
Holds the instance of the storage device class, e.g., ``4''. This
namespace is managed by the device driver, and assignment of unit
numbers might be a property of probe order, or in some cases topology.
Together, the d_name and d_unit values will uniquely identify
a disk storage device.
Disk Device Methods [Toc] [Back]
The following fields identify various disk device methods, if implemented:
disk_open_t * d_open
Invoked when the disk device is opened.
disk_close_t * d_close
Invoked when the disk device is closed.
disk_strategy_t * d_strategy
Invoked when a new struct bio is to be initiated on the disk device.
disk_ioctl_t * d_ioctl
Invoked when a I/O control operation is initiated on the disk
device.
dumper_t * d_dump
Invoked when a kernel crash dump is performed on the disk device.
Media Properties [Toc] [Back]
The following fields identify the size, layout, and other media properties
of the disk device.
u_int d_sectorsize
The sectorsize of the disk device.
off_t d_mediasize
The size of the disk device in bytes.
u_int d_fwsectors
The number of sectors advertised on the disk device by the firmware
or BIOS.
u_int d_fwheads
The number of heads advertised on the disk device by the firmeware
or BIOS.
u_int d_maxsize
The maximum I/O request the disk device supports.
u_int d_stripeoffset
If the disk device supports an optimal stripe size and offset, such
as a RAID device, it may advertise that offset using this field.
u_int d_stripesize
If the disk device supports an optimal stripe size and offset, such
as a RAID device, it may advertise that size using this field.
Driver Private Data [Toc] [Back]
This field may be used by the device driver to store a pointer to private
data to implement the disk service.
void * d_drv1
Private data pointer.
GEOM(4), devfs(5)
This manual page was written by Robert Watson.
FreeBSD 5.2.1 September 26, 2003 FreeBSD 5.2.1 [ Back ] |