public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Kevin P. Fleming" <kevin@labsysgrp.com>
To: "Alan Cox" <alan@lxorguk.ukuu.org.uk>
Cc: <linux-kernel@vger.kernel.org>
Subject: [PATCH] fix 2.4.8-ac6 brokenness
Date: Thu, 16 Aug 2001 21:29:52 -0700	[thread overview]
Message-ID: <008901c126d5$425d60f0$6caaa8c0@kevin> (raw)

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



                 reply	other threads:[~2001-08-17  4:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='008901c126d5$425d60f0$6caaa8c0@kevin' \
    --to=kevin@labsysgrp.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox