aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--block/genhd.c45
-rw-r--r--include/linux/fs.h1
2 files changed, 35 insertions, 11 deletions
diff --git a/block/genhd.c b/block/genhd.c
index 7bbfed05cecb..ee4b13520e59 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -366,6 +366,18 @@ void blk_free_devt(dev_t devt)
366 } 366 }
367} 367}
368 368
369static char *bdevt_str(dev_t devt, char *buf)
370{
371 if (MAJOR(devt) <= 0xff && MINOR(devt) <= 0xff) {
372 char tbuf[BDEVT_SIZE];
373 snprintf(tbuf, BDEVT_SIZE, "%02x%02x", MAJOR(devt), MINOR(devt));
374 snprintf(buf, BDEVT_SIZE, "%-9s", tbuf);
375 } else
376 snprintf(buf, BDEVT_SIZE, "%03x:%05x", MAJOR(devt), MINOR(devt));
377
378 return buf;
379}
380
369/* 381/*
370 * Register device numbers dev..(dev+range-1) 382 * Register device numbers dev..(dev+range-1)
371 * range must be nonzero 383 * range must be nonzero
@@ -521,7 +533,8 @@ void __init printk_all_partitions(void)
521 struct gendisk *disk = dev_to_disk(dev); 533 struct gendisk *disk = dev_to_disk(dev);
522 struct disk_part_iter piter; 534 struct disk_part_iter piter;
523 struct hd_struct *part; 535 struct hd_struct *part;
524 char buf[BDEVNAME_SIZE]; 536 char name_buf[BDEVNAME_SIZE];
537 char devt_buf[BDEVT_SIZE];
525 538
526 /* 539 /*
527 * Don't show empty devices or things that have been 540 * Don't show empty devices or things that have been
@@ -536,10 +549,10 @@ void __init printk_all_partitions(void)
536 * numbers in hex - the same format as the root= 549 * numbers in hex - the same format as the root=
537 * option takes. 550 * option takes.
538 */ 551 */
539 printk("%02x%02x %10llu %s", 552 printk("%s %10llu %s",
540 MAJOR(disk_devt(disk)), MINOR(disk_devt(disk)), 553 bdevt_str(disk_devt(disk), devt_buf),
541 (unsigned long long)get_capacity(disk) >> 1, 554 (unsigned long long)get_capacity(disk) >> 1,
542 disk_name(disk, 0, buf)); 555 disk_name(disk, 0, name_buf));
543 if (disk->driverfs_dev != NULL && 556 if (disk->driverfs_dev != NULL &&
544 disk->driverfs_dev->driver != NULL) 557 disk->driverfs_dev->driver != NULL)
545 printk(" driver: %s\n", 558 printk(" driver: %s\n",
@@ -550,10 +563,10 @@ void __init printk_all_partitions(void)
550 /* now show the partitions */ 563 /* now show the partitions */
551 disk_part_iter_init(&piter, disk, 0); 564 disk_part_iter_init(&piter, disk, 0);
552 while ((part = disk_part_iter_next(&piter))) 565 while ((part = disk_part_iter_next(&piter)))
553 printk(" %02x%02x %10llu %s\n", 566 printk(" %s %10llu %s\n",
554 MAJOR(part_devt(part)), MINOR(part_devt(part)), 567 bdevt_str(part_devt(part), devt_buf),
555 (unsigned long long)part->nr_sects >> 1, 568 (unsigned long long)part->nr_sects >> 1,
556 disk_name(disk, part->partno, buf)); 569 disk_name(disk, part->partno, name_buf));
557 disk_part_iter_exit(&piter); 570 disk_part_iter_exit(&piter);
558 } 571 }
559 class_dev_iter_exit(&iter); 572 class_dev_iter_exit(&iter);
@@ -630,14 +643,14 @@ static int show_partition(struct seq_file *seqf, void *v)
630 return 0; 643 return 0;
631 644
632 /* show the full disk and all non-0 size partitions of it */ 645 /* show the full disk and all non-0 size partitions of it */
633 seq_printf(seqf, "%4d %4d %10llu %s\n", 646 seq_printf(seqf, "%4d %7d %10llu %s\n",
634 MAJOR(disk_devt(sgp)), MINOR(disk_devt(sgp)), 647 MAJOR(disk_devt(sgp)), MINOR(disk_devt(sgp)),
635 (unsigned long long)get_capacity(sgp) >> 1, 648 (unsigned long long)get_capacity(sgp) >> 1,
636 disk_name(sgp, 0, buf)); 649 disk_name(sgp, 0, buf));
637 650
638 disk_part_iter_init(&piter, sgp, 0); 651 disk_part_iter_init(&piter, sgp, 0);
639 while ((part = disk_part_iter_next(&piter))) 652 while ((part = disk_part_iter_next(&piter)))
640 seq_printf(seqf, "%4d %4d %10llu %s\n", 653 seq_printf(seqf, "%4d %7d %10llu %s\n",
641 MAJOR(part_devt(part)), MINOR(part_devt(part)), 654 MAJOR(part_devt(part)), MINOR(part_devt(part)),
642 (unsigned long long)part->nr_sects >> 1, 655 (unsigned long long)part->nr_sects >> 1,
643 disk_name(sgp, part->partno, buf)); 656 disk_name(sgp, part->partno, buf));
@@ -691,6 +704,14 @@ static ssize_t disk_range_show(struct device *dev,
691 return sprintf(buf, "%d\n", disk->minors); 704 return sprintf(buf, "%d\n", disk->minors);
692} 705}
693 706
707static ssize_t disk_ext_range_show(struct device *dev,
708 struct device_attribute *attr, char *buf)
709{
710 struct gendisk *disk = dev_to_disk(dev);
711
712 return sprintf(buf, "%d\n", disk_max_parts(disk) + 1);
713}
714
694static ssize_t disk_removable_show(struct device *dev, 715static ssize_t disk_removable_show(struct device *dev,
695 struct device_attribute *attr, char *buf) 716 struct device_attribute *attr, char *buf)
696{ 717{
@@ -780,6 +801,7 @@ static ssize_t disk_fail_store(struct device *dev,
780#endif 801#endif
781 802
782static DEVICE_ATTR(range, S_IRUGO, disk_range_show, NULL); 803static DEVICE_ATTR(range, S_IRUGO, disk_range_show, NULL);
804static DEVICE_ATTR(ext_range, S_IRUGO, disk_ext_range_show, NULL);
783static DEVICE_ATTR(removable, S_IRUGO, disk_removable_show, NULL); 805static DEVICE_ATTR(removable, S_IRUGO, disk_removable_show, NULL);
784static DEVICE_ATTR(ro, S_IRUGO, disk_ro_show, NULL); 806static DEVICE_ATTR(ro, S_IRUGO, disk_ro_show, NULL);
785static DEVICE_ATTR(size, S_IRUGO, disk_size_show, NULL); 807static DEVICE_ATTR(size, S_IRUGO, disk_size_show, NULL);
@@ -792,6 +814,7 @@ static struct device_attribute dev_attr_fail =
792 814
793static struct attribute *disk_attrs[] = { 815static struct attribute *disk_attrs[] = {
794 &dev_attr_range.attr, 816 &dev_attr_range.attr,
817 &dev_attr_ext_range.attr,
795 &dev_attr_removable.attr, 818 &dev_attr_removable.attr,
796 &dev_attr_ro.attr, 819 &dev_attr_ro.attr,
797 &dev_attr_size.attr, 820 &dev_attr_size.attr,
@@ -858,7 +881,7 @@ static int diskstats_show(struct seq_file *seqf, void *v)
858 cpu = disk_stat_lock(); 881 cpu = disk_stat_lock();
859 disk_round_stats(cpu, gp); 882 disk_round_stats(cpu, gp);
860 disk_stat_unlock(); 883 disk_stat_unlock();
861 seq_printf(seqf, "%4d %4d %s %lu %lu %llu %u %lu %lu %llu %u %u %u %u\n", 884 seq_printf(seqf, "%4d %7d %s %lu %lu %llu %u %lu %lu %llu %u %u %u %u\n",
862 MAJOR(disk_devt(gp)), MINOR(disk_devt(gp)), 885 MAJOR(disk_devt(gp)), MINOR(disk_devt(gp)),
863 disk_name(gp, 0, buf), 886 disk_name(gp, 0, buf),
864 disk_stat_read(gp, ios[0]), disk_stat_read(gp, merges[0]), 887 disk_stat_read(gp, ios[0]), disk_stat_read(gp, merges[0]),
@@ -877,7 +900,7 @@ static int diskstats_show(struct seq_file *seqf, void *v)
877 cpu = disk_stat_lock(); 900 cpu = disk_stat_lock();
878 part_round_stats(cpu, hd); 901 part_round_stats(cpu, hd);
879 disk_stat_unlock(); 902 disk_stat_unlock();
880 seq_printf(seqf, "%4d %4d %s %lu %lu %llu " 903 seq_printf(seqf, "%4d %7d %s %lu %lu %llu "
881 "%u %lu %lu %llu %u %u %u %u\n", 904 "%u %lu %lu %llu %u %u %u %u\n",
882 MAJOR(part_devt(hd)), MINOR(part_devt(hd)), 905 MAJOR(part_devt(hd)), MINOR(part_devt(hd)),
883 disk_name(gp, hd->partno, buf), 906 disk_name(gp, hd->partno, buf),
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 860689f541b1..02a9fb5a830c 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1685,6 +1685,7 @@ extern void chrdev_show(struct seq_file *,off_t);
1685 1685
1686/* fs/block_dev.c */ 1686/* fs/block_dev.c */
1687#define BDEVNAME_SIZE 32 /* Largest string for a blockdev identifier */ 1687#define BDEVNAME_SIZE 32 /* Largest string for a blockdev identifier */
1688#define BDEVT_SIZE 10 /* Largest string for MAJ:MIN for blkdev */
1688 1689
1689#ifdef CONFIG_BLOCK 1690#ifdef CONFIG_BLOCK
1690#define BLKDEV_MAJOR_HASH_SIZE 255 1691#define BLKDEV_MAJOR_HASH_SIZE 255