IBM 10 SP1 EAL4 Server User Manual


 
This extra level of indirection is needed for character devices, but not for block devices, because of the large
variety of character devices and the operations they support. The following diagram illustrates how the kernel
maps the file operations vector of the device file object to the correct set of operations routines for that device.
5.9.3 Block device driver
Block drivers provide access to the block-oriented devices that transfer data in randomly accessible, fixed-size
blocks, such as a disk drive. All I/O-to-block devices are normally buffered by the system (the only exception
is with raw devices); user processes do not perform direct I/O to these devices.
Programs operate on block devices by opening their file system entries. The file system entry contains a
major and a minor number by which the kernel identifies the device. The kernel maintains a hash table,
indexed by major and minor number, of block-device descriptors. One of the fields of the block device
descriptor is bd_op, which is pointer to the block_device_operations structure. The
block_device_operations structure contains methods to open, release, llseek, read, write,
mmap, fsync, and ioctl that control the block device. Each block device driver needs to implement these
block device operations for the device being driven.
The Virtual File System sets up the file object for the device and points the file operations vector to the
appropriate block device operations as follows.
155
Figure 5-77: Setup of f_op for character device specific file operations