Linux内核3.13:如何列出gendisk' s?

时间:2015-05-07 22:13:05

标签: linux linux-kernel linux-device-driver

我正在阅读有关Linux内核驱动程序的online book,这对我来说已经过时了。例如,Linux Cross Reference无法找到变量gendisk_head(在内核3.13中),它应该指向gendisk结构列表,内部 < / strong>内核。

如何从内核3.13中列出所有当前分配的gendisk结构?

1 个答案:

答案 0 :(得分:1)

看看下面的代码:

void __init printk_all_partitions(void)
{
        struct class_dev_iter iter;
        struct device *dev; 

        class_dev_iter_init(&iter, &block_class, NULL, &disk_type);
        while ((dev = class_dev_iter_next(&iter))) {
                struct gendisk *disk = dev_to_disk(dev);