Partitionable Devices
Most block devices are not used in one large chunk. Instead, the
system administrator expects to be able to
partition the device—to split it into
several independent pseudodevices. If you try to create partitions on
an sbull device with
fdisk, you’ll run into problems. The
fdisk program calls the partitions
/dev/sbull01, /dev/sbull02,
and so on, but those names don’t exist on the filesystem. More to the
point, there is no mechanism in place for binding those names to
partitions in the sbull device. Something
more must be done before a block device can be partitioned.
To demonstrate how partitions are supported, we introduce a new device called spull, a “Simple Partitionable Utility.” It is far simpler than sbull, lacking the request queue management and some flexibility (like the ability to change the hard-sector size). The device resides in the spull directory and is completely detached from sbull, even though they share some code.
To be able to support partitions on a device, we must assign several
minor numbers to each physical device. One number is used to access
the whole device (for example, /dev/hda), and the
others are used to access the various partitions (such as
/dev/hda1). Since
fdisk creates partition names by adding a
numerical suffix to the whole-disk device name, we’ll follow the same
naming convention in the spull driver.
The device nodes implemented by spull are
called pd, for “partitionable disk.” The four whole devices (also called ...