Partitionable Devices
If you try to create partitions with fdisk, you’ll find out that
there’s something wrong with them. The
fdisk program calls the partitions /dev/sbull01
,
/dev/sbull02
, and so on, but those names don’t exist on the
filesystem. Indeed, the base sbull device is a byte array
with no entry points to provide access to subregions of the data
area, so partitioning sbull doesn’t work.
In order to be able to partition 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 our next block driver.
The device I’m going to introduce in this section is called
spull, because it is a ``Simple Partitionable Utility.'' The
device resides in the spull
directory and is completely
detached from sbull, even though they share a lot of code.
In the char driver scull, different minor numbers were able to implement different behaviors, so that a single driver could show several different implementations. Differentiating according to the minor number is not possible with block devices, and that’s why sbull and spull are kept separate. The inability to differentiate devices according to the minor number is a basic feature of block drivers, as several of the data structures and macros ...
Get Linux Device Drivers now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.