提交 5c6f35c5 编写于 作者: G Greg Kroah-Hartman

block: make printk_partition use the class iterator function

Use the proper class iterator function instead of mucking around in the
internals of the class structures.

Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 6ffeea77
...@@ -227,58 +227,65 @@ struct gendisk *get_gendisk(dev_t devt, int *part) ...@@ -227,58 +227,65 @@ struct gendisk *get_gendisk(dev_t devt, int *part)
} }
/* /*
* print a full list of all partitions - intended for places where the root * print a partitions - intended for places where the root filesystem can't be
* filesystem can't be mounted and thus to give the victim some idea of what * mounted and thus to give the victim some idea of what went wrong
* went wrong
*/ */
void __init printk_all_partitions(void) static int printk_partition(struct device *dev, void *data)
{ {
struct device *dev;
struct gendisk *sgp; struct gendisk *sgp;
char buf[BDEVNAME_SIZE]; char buf[BDEVNAME_SIZE];
int n; int n;
mutex_lock(&block_class_lock); if (dev->type != &disk_type)
/* For each block device... */ goto exit;
list_for_each_entry(dev, &block_class.devices, node) {
if (dev->type != &disk_type)
continue;
sgp = dev_to_disk(dev);
/*
* Don't show empty devices or things that have been surpressed
*/
if (get_capacity(sgp) == 0 ||
(sgp->flags & GENHD_FL_SUPPRESS_PARTITION_INFO))
continue;
/* sgp = dev_to_disk(dev);
* Note, unlike /proc/partitions, I am showing the numbers in /*
* hex - the same format as the root= option takes. * Don't show empty devices or things that have been surpressed
*/ */
printk("%02x%02x %10llu %s", if (get_capacity(sgp) == 0 ||
sgp->major, sgp->first_minor, (sgp->flags & GENHD_FL_SUPPRESS_PARTITION_INFO))
(unsigned long long)get_capacity(sgp) >> 1, goto exit;
disk_name(sgp, 0, buf));
if (sgp->driverfs_dev != NULL && /*
sgp->driverfs_dev->driver != NULL) * Note, unlike /proc/partitions, I am showing the numbers in
printk(" driver: %s\n", * hex - the same format as the root= option takes.
sgp->driverfs_dev->driver->name); */
else printk("%02x%02x %10llu %s",
printk(" (driver?)\n"); sgp->major, sgp->first_minor,
(unsigned long long)get_capacity(sgp) >> 1,
/* now show the partitions */ disk_name(sgp, 0, buf));
for (n = 0; n < sgp->minors - 1; ++n) { if (sgp->driverfs_dev != NULL &&
if (sgp->part[n] == NULL) sgp->driverfs_dev->driver != NULL)
continue; printk(" driver: %s\n",
if (sgp->part[n]->nr_sects == 0) sgp->driverfs_dev->driver->name);
continue; else
printk(" %02x%02x %10llu %s\n", printk(" (driver?)\n");
sgp->major, n + 1 + sgp->first_minor,
(unsigned long long)sgp->part[n]->nr_sects >> 1, /* now show the partitions */
disk_name(sgp, n + 1, buf)); for (n = 0; n < sgp->minors - 1; ++n) {
} if (sgp->part[n] == NULL)
goto exit;
if (sgp->part[n]->nr_sects == 0)
goto exit;
printk(" %02x%02x %10llu %s\n",
sgp->major, n + 1 + sgp->first_minor,
(unsigned long long)sgp->part[n]->nr_sects >> 1,
disk_name(sgp, n + 1, buf));
} }
exit:
return 0;
}
/*
* print a full list of all partitions - intended for places where the root
* filesystem can't be mounted and thus to give the victim some idea of what
* went wrong
*/
void __init printk_all_partitions(void)
{
mutex_lock(&block_class_lock);
class_for_each_device(&block_class, NULL, NULL, printk_partition);
mutex_unlock(&block_class_lock); mutex_unlock(&block_class_lock);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册