# Interfaces used by disk devices
The classical UNIX device interface
- implement bdevsw
- implement cdevsw
- other methods not used by disk drivers
Layering is possible, the dk_lookup function is used to get
a handle (a vnode) a child device.
- call each other using vnode layer
- dk_lookup to find vnode
- vn_close to release vnode
Disk drivers use the kernel disk interface to provide information
for iostat and property lists. There are also helper routines
to handle partitions and to get a disklabel.
- kernel disk interface
- driver calls disk_init() to register
- instrumentation (iostat)
- partition support (bounds_check_..)
- disklabel routines
- low-level routines polluting namespace (disk_read_sectors)
- registers a callback to strategy and minphys functions,
currently there are only one user, dk(4) calls the minphys
Almost all disk drivers have a regular driver structure that
is created by the autoconf framework. An exception is the ccd(4)
driver that hand-crafts its private data without autoconf.
- autoconf device building
- generic for all device drivers, not only disk drivers
- provides common data including a proplib dictionary
- the dictionary is used to register unit data, for example
a drive geometry.
The disklabel routines are mostly MD, the sun/sparc routines are
not in arch/* but in dev/sun/*, the i386/amd64 routines (also used
by other archs) are in kern/subr_disk_mbr.c
- disklabel routines
- really MD, implement readdisklabel, writedisklabel, setdisklabel
- more disklabel routines, MBR, ISO9660
- like subr_disk_mbr.c but different for sun3/sparc/sparc64
- like subr_disk_mbr.c but different
A wedge is a layered device on top of the RAW_PART of a standard
disk device. All disk drivers need to implement ioctls to manually
attach wedge devices (using dkctl(8)) and need to call dkwedge_discover
to implement autodetect
- wedge routines
- implement dk device
- implement scan routines for various labels (MBR,BSD,GPT)
- IOCTLs to attach dk devices
- scan routines called by each disk driver
The attempt to refactor disk drivers by collecting common functionality.
Hardly used, the dk_lookup routine doesn't really belong here (it's
more a vnode routine).
- dksubr interface
- dk_lookup helper to find vnodes
- dk_intf switch implements common parts of
- dk_getdisklabel, dk_makedisklabel. fallback routines ?.
- used only by cgd, xbd
CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb