new copyright notice
[unix-history] / usr / src / sys / ufs / ffs / ufs_disksubr.c
index 79d520d..fb22543 100644 (file)
@@ -1,9 +1,10 @@
 /*
  * Copyright (c) 1982, 1986, 1988 Regents of the University of California.
 /*
  * Copyright (c) 1982, 1986, 1988 Regents of the University of California.
- * All rights reserved.  The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
+ * All rights reserved.
  *
  *
- *     @(#)ufs_disksubr.c      7.8 (Berkeley) %G%
+ * %sccs.include.redist.c%
+ *
+ *     @(#)ufs_disksubr.c      7.14 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -11,8 +12,6 @@
 #include "buf.h"
 #include "disklabel.h"
 #include "syslog.h"
 #include "buf.h"
 #include "disklabel.h"
 #include "syslog.h"
-
-#include "dir.h"
 #include "user.h"
 
 /*
 #include "user.h"
 
 /*
@@ -149,9 +148,7 @@ readdisklabel(dev, strat, lp)
        bp->b_flags = B_BUSY | B_READ;
        bp->b_cylin = LABELSECTOR / lp->d_secpercyl;
        (*strat)(bp);
        bp->b_flags = B_BUSY | B_READ;
        bp->b_cylin = LABELSECTOR / lp->d_secpercyl;
        (*strat)(bp);
-       biowait(bp);
-       if (bp->b_flags & B_ERROR) {
-               u.u_error = 0;          /* XXX */
+       if (biowait(bp)) {
                msg = "I/O error";
        } else for (dlp = (struct disklabel *)bp->b_un.b_addr;
            dlp <= (struct disklabel *)(bp->b_un.b_addr+DEV_BSIZE-sizeof(*dlp));
                msg = "I/O error";
        } else for (dlp = (struct disklabel *)bp->b_un.b_addr;
            dlp <= (struct disklabel *)(bp->b_un.b_addr+DEV_BSIZE-sizeof(*dlp));
@@ -159,7 +156,8 @@ readdisklabel(dev, strat, lp)
                if (dlp->d_magic != DISKMAGIC || dlp->d_magic2 != DISKMAGIC) {
                        if (msg == NULL)
                                msg = "no disk label";
                if (dlp->d_magic != DISKMAGIC || dlp->d_magic2 != DISKMAGIC) {
                        if (msg == NULL)
                                msg = "no disk label";
-               } else if (dkcksum(dlp) != 0)
+               } else if (dlp->d_npartitions > MAXPARTITIONS ||
+                          dkcksum(dlp) != 0)
                        msg = "disk label corrupted";
                else {
                        *lp = *dlp;
                        msg = "disk label corrupted";
                else {
                        *lp = *dlp;
@@ -167,8 +165,6 @@ readdisklabel(dev, strat, lp)
                        break;
                }
        }
                        break;
                }
        }
-       if (lp->d_npartitions > MAXPARTITIONS)
-               lp->d_npartitions = MAXPARTITIONS;
        bp->b_flags = B_INVAL | B_AGE;
        brelse(bp);
        return (msg);
        bp->b_flags = B_INVAL | B_AGE;
        brelse(bp);
        return (msg);
@@ -244,12 +240,8 @@ writedisklabel(dev, strat, lp)
        bp->b_bcount = lp->d_secsize;
        bp->b_flags = B_READ;
        (*strat)(bp);
        bp->b_bcount = lp->d_secsize;
        bp->b_flags = B_READ;
        (*strat)(bp);
-       biowait(bp);
-       if (bp->b_flags & B_ERROR) {
-               error = u.u_error;              /* XXX */
-               u.u_error = 0;
+       if (error = biowait(bp))
                goto done;
                goto done;
-       }
        for (dlp = (struct disklabel *)bp->b_un.b_addr;
            dlp <= (struct disklabel *)
              (bp->b_un.b_addr + lp->d_secsize - sizeof(*dlp));
        for (dlp = (struct disklabel *)bp->b_un.b_addr;
            dlp <= (struct disklabel *)
              (bp->b_un.b_addr + lp->d_secsize - sizeof(*dlp));
@@ -259,11 +251,7 @@ writedisklabel(dev, strat, lp)
                        *dlp = *lp;
                        bp->b_flags = B_WRITE;
                        (*strat)(bp);
                        *dlp = *lp;
                        bp->b_flags = B_WRITE;
                        (*strat)(bp);
-                       biowait(bp);
-                       if (bp->b_flags & B_ERROR) {
-                               error = u.u_error;              /* XXX */
-                               u.u_error = 0;
-                       }
+                       error = biowait(bp);
                        goto done;
                }
        }
                        goto done;
                }
        }
@@ -292,7 +280,9 @@ dkcksum(lp)
 /*
  * Disk error is the preface to plaintive error messages
  * about failing disk transfers.  It prints messages of the form
 /*
  * Disk error is the preface to plaintive error messages
  * about failing disk transfers.  It prints messages of the form
- *     "hp0g: hard error reading fsbn 12345 of 12344-12347 (hp0 bn 812345)"
+
+hp0g: hard error reading fsbn 12345 of 12344-12347 (hp0 bn %d cn %d tn %d sn %d)
+
  * if the offset of the error in the transfer and a disk label
  * are both available.  blkdone should be -1 if the position of the error
  * is unknown; the disklabel pointer may be null from drivers that have not
  * if the offset of the error in the transfer and a disk label
  * are both available.  blkdone should be -1 if the position of the error
  * is unknown; the disklabel pointer may be null from drivers that have not
@@ -330,9 +320,14 @@ diskerr(bp, dname, what, pri, blkdone, lp)
                (*pr)("%d-%d", bp->b_blkno,
                    bp->b_blkno + (bp->b_bcount - 1) / DEV_BSIZE);
        }
                (*pr)("%d-%d", bp->b_blkno,
                    bp->b_blkno + (bp->b_bcount - 1) / DEV_BSIZE);
        }
-       if (lp && (blkdone >= 0 || bp->b_bcount <= DEV_BSIZE)) {
+       if (lp && (blkdone >= 0 || bp->b_bcount <= lp->d_secsize)) {
+#ifdef tahoe
+               sn *= DEV_BSIZE / lp->d_secsize;                /* XXX */
+#endif
                sn += lp->d_partitions[part].p_offset;
                sn += lp->d_partitions[part].p_offset;
-               (*pr)(" (%s%d bn %d) ", dname, unit, sn);
-               /* could log cyl/trk/sect */
+               (*pr)(" (%s%d bn %d; cn %d", dname, unit, sn,
+                   sn / lp->d_secpercyl);
+               sn %= lp->d_secpercyl;
+               (*pr)(" tn %d sn %d)", sn / lp->d_nsectors, sn % lp->d_nsectors);
        }
 }
        }
 }