[PATCH] /proc/partitions show startings sectors

David Balazic (david.balazic@uni-mb.si)
Wed, 04 Aug 1999 10:02:07 +0200


Here is a patch to make /proc/partitions show more data,
namely the starting sector of each partition and its length
in sectors. Usefull if you accidentaly overwrite the partition table
on disk and want to restore it.

This breaks the parsing in the mount command ( versions 2.9n to 2.9s ),
so options -L and -U don't work anymore.
A simple fix is attached at the end.

I also noticed a possible small optimisation in fs/buffer.c.
Someone look at it and maybe aply it. ( the third diff )

Oh yes , patches are against linux 2.2.5-22 ( redhat ) , but should be easy
to use
on other 2.2.x versions too.

The patches are probabla mangled by Outlook :-( so there are good versions
at :
http://rcum.uni-mb.si/~uel003r2a/PROC-PARTITIONS.PATCH

the /proc/partitions patch :

diff -u -r linux-2.2.5-22-redhat/drivers/block/genhd.c
linux/drivers/block/genhd.c
--- linux-2.2.5-22-redhat/drivers/block/genhd.c Wed Jun 2 14:36:15 1999
+++ linux/drivers/block/genhd.c Thu Jul 29 00:54:24 1999
@@ -1427,14 +1427,17 @@
char buf[32];
int n, len;

- len = sprintf(page, "major minor #blocks name\n\n");
+ len = sprintf(page, "major minor #blocks name start_sect
nr_sects\n\n");
for (p = gendisk_head; p; p = p->next) {
for (n=0; n < (p->nr_real << p->minor_shift); n++) {
if (p->part[n].nr_sects && len < PAGE_SIZE - 80) {
len += sprintf(page+len,
- "%4d %4d %10d %s\n",
+ "%4d %4d %10d %6s %10ld %10ld\n",
p->major, n, p->sizes[n],
- disk_name(p, n, buf));
+ disk_name(p, n, buf),
+ p->part[n].start_sect,
+ p->part[n].nr_sects
+ );
}
}
}

fs/buffer.c simplification :

diff -u -r linux-2.2.5-22-redhat/fs/buffer.c linux/fs/buffer.c
--- linux-2.2.5-22-redhat/fs/buffer.c Wed Jun 2 14:36:14 1999
+++ linux/fs/buffer.c Thu Jul 29 12:52:39 1999
@@ -616,8 +616,12 @@
*/
if (hardsect_size[MAJOR(dev)] != NULL) {
int blksize = hardsect_size[MAJOR(dev)][MINOR(dev)];
- if (blksize != 0)
- return blksize;
+/* if (blksize != 0)
+ * this if() is redundant , as I see it.
+ * the blksize variable could be removed also,
+ * leaving only return hardsect_size[....]
+ */
+ return blksize;
}

/*

mount patch :

--- util-linux-2.9s/mount/mount_by_label.c.orig Mon Aug 2 13:38:19 1999
+++ util-linux-2.9s/mount/mount_by_label.c Mon Aug 2 13:38:37 1999
@@ -37,7 +37,7 @@
static char ptname[100];

while (fgets(line, sizeof(line), procpt)) {
- if (sscanf (line, " %d %d %d %[^\n]\n", &ma, &mi, &sz, ptname) != 4)
+ if (sscanf (line, " %d %d %d %s ", &ma, &mi, &sz, ptname) != 4)
continue;

/* skip extended partitions (heuristic: size 1) */

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