Re: [PATCH] Enhancement of /proc/partitions output (2.5.1-pre5)

Andreas Dilger (adilger@turbolabs.com)
Sat, 1 Dec 2001 01:39:59 -0700


On Dec 01, 2001 07:08 +0000, Anton Altaparmakov wrote:
> Linus,
> Please consider below patch which adds the starting sector and number of
> sectors to /proc/partitions.
>
> It works fine here and I find having this information output can be very
> useful (especially when the values in the kernel don't match the values
> output by fdisk for example).

Please do not accept as-is. This breaks the format of /proc/partitions
terribly, and all of the code that looks at it (fsck, mount, etc). Rather
add the start_sect and nr_sects parameters _after_ the name parameter,
and it will be "mostly" ok.

While we are at it, how about adding the partition type to the output?
This is the only reason that I ever need to re-parse the on-disk crud
from DOS partition tables, and the kernel already handles it when it
is parsing the partition table. For the "partitions" that don't have
DOS-style partition types, we can either just put a string (like LVM
or MD) which may be useful for a variety of other reasons.

(Purely hand-edited version of Anton's patch changing it to have the
new fields at the end, may not apply, may not line up strings properly.
Doesn't include suggested parition type field either).

On a similar note - Linus, will you accept a patch which fixes the block
device naming, to make it a per driver issue, rather than embedding it
into the core code? I have one sitting around from way back, that has
been itching to get in.

Cheers, Andreas
============================================================================
diff -u -urN linux-2.5.1-pre5-vanilla/drivers/block/genhd.c l251p5/drivers/block/genhd.c
--- linux-2.5.1-pre5-vanilla/drivers/block/genhd.c Sat Dec 1 06:09:57 2001
+++ l251p5/drivers/block/genhd.c Sat Dec 1 03:57:57 2001
@@ -149,7 +149,8 @@
char buf[64];
int len, n;

- len = sprintf(page, "major minor #blocks name\n\n");
+ len = sprintf(page, "major minor %9s %-16s %10s %10s\n",
+ "#blocks", "name", "start_sect", "nr_sects");
read_lock(&gendisk_lock);
for (gp = gendisk_head; gp; gp = gp->next) {
for (n = 0; n < (gp->nr_real << gp->minor_shift); n++) {
@@ -157,8 +158,10 @@
continue;

len += snprintf(page + len, 63,
- "%4d %4d %10d %s\n",
+ "%4d %4d %10d %-16s %10lu %10lu\n",
gp->major, n, gp->sizes[n],
- disk_name(gp, n, buf));
+ disk_name(gp, n, buf),
+ gp->part[n].start_sect,
+ gp->part[n].nr_sects);
if (len < offset)
offset -= len, len = 0;

--
Andreas Dilger
http://sourceforge.net/projects/ext2resize/
http://www-mddsp.enel.ucalgary.ca/People/adilger/

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/