diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2008-05-22 17:21:08 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-07-22 00:54:48 -0400 |
commit | 5c6f35c5ece8f130cd8ec9ba0d71dc146b46a0f1 (patch) | |
tree | f1e109f09aff9ecfb57b25bc14e5a07e91a2286a | |
parent | 6ffeea77ff014f1456fcd0564eac84b34e9535ca (diff) |
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: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | block/genhd.c | 93 |
1 files changed, 50 insertions, 43 deletions
diff --git a/block/genhd.c b/block/genhd.c index 3ccf5c017565..10b9ac46c2da 100644 --- a/block/genhd.c +++ b/block/genhd.c | |||
@@ -227,58 +227,65 @@ struct gendisk *get_gendisk(dev_t devt, int *part) | |||
227 | } | 227 | } |
228 | 228 | ||
229 | /* | 229 | /* |
230 | * print a full list of all partitions - intended for places where the root | 230 | * print a partitions - intended for places where the root filesystem can't be |
231 | * filesystem can't be mounted and thus to give the victim some idea of what | 231 | * mounted and thus to give the victim some idea of what went wrong |
232 | * went wrong | ||
233 | */ | 232 | */ |
234 | void __init printk_all_partitions(void) | 233 | static int printk_partition(struct device *dev, void *data) |
235 | { | 234 | { |
236 | struct device *dev; | ||
237 | struct gendisk *sgp; | 235 | struct gendisk *sgp; |
238 | char buf[BDEVNAME_SIZE]; | 236 | char buf[BDEVNAME_SIZE]; |
239 | int n; | 237 | int n; |
240 | 238 | ||
241 | mutex_lock(&block_class_lock); | 239 | if (dev->type != &disk_type) |
242 | /* For each block device... */ | 240 | goto exit; |
243 | list_for_each_entry(dev, &block_class.devices, node) { | ||
244 | if (dev->type != &disk_type) | ||
245 | continue; | ||
246 | sgp = dev_to_disk(dev); | ||
247 | /* | ||
248 | * Don't show empty devices or things that have been surpressed | ||
249 | */ | ||
250 | if (get_capacity(sgp) == 0 || | ||
251 | (sgp->flags & GENHD_FL_SUPPRESS_PARTITION_INFO)) | ||
252 | continue; | ||
253 | 241 | ||
254 | /* | 242 | sgp = dev_to_disk(dev); |
255 | * Note, unlike /proc/partitions, I am showing the numbers in | 243 | /* |
256 | * hex - the same format as the root= option takes. | 244 | * Don't show empty devices or things that have been surpressed |
257 | */ | 245 | */ |
258 | printk("%02x%02x %10llu %s", | 246 | if (get_capacity(sgp) == 0 || |
259 | sgp->major, sgp->first_minor, | 247 | (sgp->flags & GENHD_FL_SUPPRESS_PARTITION_INFO)) |
260 | (unsigned long long)get_capacity(sgp) >> 1, | 248 | goto exit; |
261 | disk_name(sgp, 0, buf)); | 249 | |
262 | if (sgp->driverfs_dev != NULL && | 250 | /* |
263 | sgp->driverfs_dev->driver != NULL) | 251 | * Note, unlike /proc/partitions, I am showing the numbers in |
264 | printk(" driver: %s\n", | 252 | * hex - the same format as the root= option takes. |
265 | sgp->driverfs_dev->driver->name); | 253 | */ |
266 | else | 254 | printk("%02x%02x %10llu %s", |
267 | printk(" (driver?)\n"); | 255 | sgp->major, sgp->first_minor, |
268 | 256 | (unsigned long long)get_capacity(sgp) >> 1, | |
269 | /* now show the partitions */ | 257 | disk_name(sgp, 0, buf)); |
270 | for (n = 0; n < sgp->minors - 1; ++n) { | 258 | if (sgp->driverfs_dev != NULL && |
271 | if (sgp->part[n] == NULL) | 259 | sgp->driverfs_dev->driver != NULL) |
272 | continue; | 260 | printk(" driver: %s\n", |
273 | if (sgp->part[n]->nr_sects == 0) | 261 | sgp->driverfs_dev->driver->name); |
274 | continue; | 262 | else |
275 | printk(" %02x%02x %10llu %s\n", | 263 | printk(" (driver?)\n"); |
276 | sgp->major, n + 1 + sgp->first_minor, | 264 | |
277 | (unsigned long long)sgp->part[n]->nr_sects >> 1, | 265 | /* now show the partitions */ |
278 | disk_name(sgp, n + 1, buf)); | 266 | for (n = 0; n < sgp->minors - 1; ++n) { |
279 | } | 267 | if (sgp->part[n] == NULL) |
268 | goto exit; | ||
269 | if (sgp->part[n]->nr_sects == 0) | ||
270 | goto exit; | ||
271 | printk(" %02x%02x %10llu %s\n", | ||
272 | sgp->major, n + 1 + sgp->first_minor, | ||
273 | (unsigned long long)sgp->part[n]->nr_sects >> 1, | ||
274 | disk_name(sgp, n + 1, buf)); | ||
280 | } | 275 | } |
276 | exit: | ||
277 | return 0; | ||
278 | } | ||
281 | 279 | ||
280 | /* | ||
281 | * print a full list of all partitions - intended for places where the root | ||
282 | * filesystem can't be mounted and thus to give the victim some idea of what | ||
283 | * went wrong | ||
284 | */ | ||
285 | void __init printk_all_partitions(void) | ||
286 | { | ||
287 | mutex_lock(&block_class_lock); | ||
288 | class_for_each_device(&block_class, NULL, NULL, printk_partition); | ||
282 | mutex_unlock(&block_class_lock); | 289 | mutex_unlock(&block_class_lock); |
283 | } | 290 | } |
284 | 291 | ||