public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fix 2.4.8-ac6 brokenness
@ 2001-08-17  4:29 Kevin P. Fleming
  0 siblings, 0 replies; only message in thread
From: Kevin P. Fleming @ 2001-08-17  4:29 UTC (permalink / raw)
  To: Alan Cox; +Cc: linux-kernel

The patch you included in -ac6 from Neil Brown for fs/partitions/check.c was
a quick&dirty thing he wrote up on the mailing list, and it does not work at
all. In fact, with that patch in place disk_name() will never call devfs to
generate a disk name path at all, because of the way the unit number is
computed. Attached is the patch that I created a couple of days ago when I
first found this problem; it corrects the problem and also removes some
extraneous code from disk_name().

--- fs/partitions/check.old Wed Aug 15 10:09:50 2001
+++ fs/partitions/check.c Wed Aug 15 10:24:15 2001
@@ -96,12 +96,11 @@

 char *disk_name (struct gendisk *hd, int minor, char *buf)
 {
- unsigned int part;
  const char *maj = hd->major_name;
- int unit = (minor >> hd->minor_shift) + 'a';
+ unsigned int unit = (minor >> hd->minor_shift);
+ unsigned int part = (minor & ((1 << hd->minor_shift) - 1));

- part = minor & ((1 << hd->minor_shift) - 1);
- if (hd->part[minor].de) {
+ if ((unit < hd->nr_real) && (hd->part[minor].de)) {
   int pos;

   pos = devfs_generate_path (hd->part[minor].de, buf, 64);
@@ -111,7 +110,7 @@

 #ifdef CONFIG_ARCH_S390
  if (genhd_dasd_name
-     && genhd_dasd_name (buf, unit - 'a', part, hd) == 0)
+     && genhd_dasd_name (buf, unit, part, hd) == 0)
   return buf;
 #endif
  /*
@@ -142,11 +141,11 @@
    maj = "hd";
    break;
   case MD_MAJOR:
-   sprintf(buf, "%s%d", maj, unit - 'a');
+   sprintf(buf, "%s%d", maj, unit);
    return buf;
  }
  if (hd->major >= SCSI_DISK1_MAJOR && hd->major <= SCSI_DISK7_MAJOR) {
-  unit = unit + (hd->major - SCSI_DISK1_MAJOR + 1) * 16;
+  unit = unit + 'a' + (hd->major - SCSI_DISK1_MAJOR + 1) * 16;
   if (unit > 'z') {
    unit -= 'z' + 1;
    sprintf(buf, "sd%c%c", 'a' + unit / 26, 'a' + unit % 26);
@@ -157,47 +156,39 @@
  }
  if (hd->major >= COMPAQ_SMART2_MAJOR && hd->major <=
COMPAQ_SMART2_MAJOR+7) {
   int ctlr = hd->major - COMPAQ_SMART2_MAJOR;
-   int disk = minor >> hd->minor_shift;
-   int part = minor & (( 1 << hd->minor_shift) - 1);
    if (part == 0)
-    sprintf(buf, "%s/c%dd%d", maj, ctlr, disk);
+    sprintf(buf, "%s/c%dd%d", maj, ctlr, unit);
    else
-    sprintf(buf, "%s/c%dd%dp%d", maj, ctlr, disk, part);
+    sprintf(buf, "%s/c%dd%dp%d", maj, ctlr, unit, part);
    return buf;
   }
  if (hd->major >= COMPAQ_CISS_MAJOR && hd->major <= COMPAQ_CISS_MAJOR+7) {
                 int ctlr = hd->major - COMPAQ_CISS_MAJOR;
-                int disk = minor >> hd->minor_shift;
-                int part = minor & (( 1 << hd->minor_shift) - 1);
                 if (part == 0)
-                        sprintf(buf, "%s/c%dd%d", maj, ctlr, disk);
+                        sprintf(buf, "%s/c%dd%d", maj, ctlr, unit);
                 else
-                        sprintf(buf, "%s/c%dd%dp%d", maj, ctlr, disk,
part);
+                        sprintf(buf, "%s/c%dd%dp%d", maj, ctlr, unit,
part);
                 return buf;
  }
  if (hd->major >= DAC960_MAJOR && hd->major <= DAC960_MAJOR+7) {
   int ctlr = hd->major - DAC960_MAJOR;
-   int disk = minor >> hd->minor_shift;
-   int part = minor & (( 1 << hd->minor_shift) - 1);
    if (part == 0)
-    sprintf(buf, "%s/c%dd%d", maj, ctlr, disk);
+    sprintf(buf, "%s/c%dd%d", maj, ctlr, unit);
    else
-    sprintf(buf, "%s/c%dd%dp%d", maj, ctlr, disk, part);
+    sprintf(buf, "%s/c%dd%dp%d", maj, ctlr, unit, part);
    return buf;
   }
  if (hd->major == ATARAID_MAJOR) {
-   int disk = minor >> hd->minor_shift;
-   int part = minor & (( 1 << hd->minor_shift) - 1);
    if (part == 0)
-    sprintf(buf, "%s/d%d", maj, disk);
+    sprintf(buf, "%s/d%d", maj, unit);
    else
-    sprintf(buf, "%s/d%dp%d", maj, disk, part);
+    sprintf(buf, "%s/d%dp%d", maj, unit, part);
    return buf;
   }
  if (part)
-  sprintf(buf, "%s%c%d", maj, unit, part);
+  sprintf(buf, "%s%c%d", maj, unit + 'a', part);
  else
-  sprintf(buf, "%s%c", maj, unit);
+  sprintf(buf, "%s%c", maj, unit + 'a');
  return buf;
 }



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-08-17  4:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-08-17  4:29 [PATCH] fix 2.4.8-ac6 brokenness Kevin P. Fleming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox