traverse all the disks or get hd_struct by device name in kernel module
hi.
I'm writing a kernel module(on linux 2.6.32), to get the disk_stats of all the disks(not partition) in use. In other words, I'm getting the data just like what /sys/block/sda/stat shows, but in kernel module.
(NOTE: By 'not partition', I mean we just handle sda and ignore sda1/sda2/etc, for example.)
Is there anything like for_each_netdev or for_each_possible_cpu for block device? Beacuse there may be multiple disks and I need a way to traverse them. Or at the latest, how can I get the related data structure with the block device's name(like sda)?
I know we can get a disk's disk_stats from the disk's hd_struct, but how could I get this hd_struct?
I have read linux2.6.32/block/genhd.c, and I know the content of file /sys/block/sda/stat is generated by diskstats_show. But how does the second argument come?
Please help me. thanks.
|