Полезная информация

next up previous contents
Next: Initialization Up: Device Drivers Previous: TTY drivers

Block Device Drivers

To mount a filesystem on a device, it must be a block device driven by a block device driver. This means that the device must be a random access device, not a stream device. In other words, you must be able to seek to any location on the physical device at any time.

You do not provide read() and write() routines for a block device. Instead, your driver uses block_read() and block_write(), which are generic functions, provided by the VFS, which will call the strategy routine, or request() function, which you write in place of read() and write() for your driver. This strategy routine is also called by the buffer cache (See section ??), which is called by the VFS routines (See chapter ??) which is how normal files on normal filesystems are read and written.

Requests for I/O are given by the buffer cache to a routine called ll_rw_block(), which constructs lists of requests ordered by an elevator algorithm, which sorts the lists to make accesses faster and more efficient. It, in turn, calls your request() function to actually do the I/O.

Note that although SCSI disks and CDROMs are considered block devices, they are handled specially (as are all SCSI devices). Refer to section gif, Writing a SCSI Driver, for details.gif

Converted on:
Mon Apr 1 10:20:16 EST 1996