[PATCH] fix 2.4.8-ac6 brokenness

From: Kevin P. Fleming (kevin@labsysgrp.com)
Date: Thu Aug 16 2001 - 23:29:52 EST


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;
 }

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



This archive was generated by hypermail 2b29 : Thu Aug 23 2001 - 21:00:21 EST