The Device Database

Although block and character devices can and do behave very differently from each other, the databases employed to keep track of all available devices are identical. This is natural since both block and character devices are identified by a unique device number. Nevertheless, the database keeps track of different objects dependent on whether block or character devices are managed.

□ Each character device is represented by an instance of struct cdev.

□ struct genhd is used to manage partitions of block devices and plays a role similar to that of cdev for character devices. This is reasonable since a block device without partitions can also be seen as a block device with a single, large partition!

For now, it is sufficient to know that each block and character device is represented by an instance of the respective data structure. Their contents do not matter here as we will have a closer look at them below. Instead, it is important to see how the kernel keeps track of all available cdev and genhd instances. Figure 6-5 summarizes the situation graphically.

dev_

-*]

dev_

-n

dev_

range

range

range

data

data

data

struct cdev on

struct genhd jjj»

Continue reading here: Figure 65 Device database to keep track of all block and character devices

Was this article helpful?

0 0