[PATCH] disk_index weirdness

Martin Wilck (mwilck@freenet.de)
Thu, 21 Jun 2001 01:21:08 +0200 (CEST)


Hi,

I suggest the follwoing patch to make /proc/stat work as expected in 2.4.
I noted that "gkrellm" erroneously reported my disk hdc as hde. the reason
is that (a relict from the 2.2 series, I suppose) disk_index adds 2 to
the disk number for IDE controller 1. This is IMO wrong, because in 2.4
the disks are indexed by major and minor number.

I also added more major numbers to the routine and tried to order the
majors such that the "right" results are found quickly.

Regards,
Martin

PS: I'm not subscribed to this list, but I read the archives regularly.

--- include/linux/genhd.h.orig Tue Mar 27 01:48:11 2001
+++ include/linux/genhd.h Wed Jun 20 19:17:09 2001
@@ -248,21 +248,30 @@
unsigned int index;

switch (major) {
- case DAC960_MAJOR+0:
- index = (minor & 0x00f8) >> 3;
- break;
case SCSI_DISK0_MAJOR:
index = (minor & 0x00f0) >> 4;
break;
case IDE0_MAJOR: /* same as HD_MAJOR */
case XT_DISK_MAJOR:
+ case IDE1_MAJOR:
+ case IDE2_MAJOR:
+ case IDE3_MAJOR:
+ case IDE4_MAJOR:
+ case IDE5_MAJOR:
index = (minor & 0x0040) >> 6;
break;
- case IDE1_MAJOR:
- index = ((minor & 0x0040) >> 6) + 2;
+ case SCSI_CDROM_MAJOR:
+ index = minor & 0x000f;
break;
default:
- return 0;
+ if (major >= SCSI_DISK1_MAJOR && major <= SCSI_DISK7_MAJOR)
+ index = (minor & 0x00f0) >> 4;
+ else if (major >= DAC960_MAJOR && major <= DAC960_MAJOR + 7)
+ index = (minor & 0x00f8) >> 3;
+ else if (major >= IDE6_MAJOR && major <= IDE9_MAJOR)
+ index = (minor & 0x0040) >> 6;
+ else
+ return 0;
}
return index;
}

--
Martin Wilck <mwilck@freenet.de>
Inst. for Tropospheric Research, Permoserstr. 15, 04303 Leipzig, Germany

- 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/