cleanups and bug fixes from John
[unix-history] / usr / src / sys / ufs / ffs / ufs_disksubr.c
index 902d513..0a4d05c 100644 (file)
@@ -2,47 +2,36 @@
  * Copyright (c) 1982, 1986, 1988 Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1982, 1986, 1988 Regents of the University of California.
  * All rights reserved.
  *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * %sccs.include.redist.c%
  *
  *
- *     @(#)ufs_disksubr.c      7.12 (Berkeley) %G%
+ *     @(#)ufs_disksubr.c      7.17 (Berkeley) %G%
  */
 
  */
 
-#include "param.h"
-#include "systm.h"
-#include "buf.h"
-#include "disklabel.h"
-#include "syslog.h"
-#include "user.h"
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/buf.h>
+#include <sys/disklabel.h>
+#include <sys/syslog.h>
 
 /*
 
 /*
- * Seek sort for disks.  We depend on the driver
- * which calls us using b_resid as the current cylinder number.
+ * Seek sort for disks.  We depend on the driver which calls us using b_resid
+ * as the current cylinder number.
  *
  *
- * The argument dp structure holds a b_actf activity chain pointer
- * on which we keep two queues, sorted in ascending cylinder order.
- * The first queue holds those requests which are positioned after
- * the current cylinder (in the first request); the second holds
- * requests which came in after their cylinder number was passed.
- * Thus we implement a one way scan, retracting after reaching the
- * end of the drive to the first request on the second queue,
- * at which time it becomes the first queue.
+ * The argument dp structure holds a b_actf activity chain pointer on which we
+ * keep two queues, sorted in ascending cylinder order.  The first queue holds
+ * those requests which are positioned after the current cylinder (in the first
+ * request); the second holds requests which came in after their cylinder number
+ * was passed.  Thus we implement a one way scan, retracting after reaching the
+ * end of the drive to the first request on the second queue, at which time it
+ * becomes the first queue.
  *
  *
- * A one-way scan is natural because of the way UNIX read-ahead
- * blocks are allocated.
+ * A one-way scan is natural because of the way UNIX read-ahead blocks are
+ * allocated.
  */
 
 #define        b_cylin b_resid
 
  */
 
 #define        b_cylin b_resid
 
+void
 disksort(dp, bp)
        register struct buf *dp, *bp;
 {
 disksort(dp, bp)
        register struct buf *dp, *bp;
 {
@@ -127,12 +116,11 @@ insert:
 }
 
 /*
 }
 
 /*
- * Attempt to read a disk label from a device
- * using the indicated stategy routine.
- * The label must be partly set up before this:
- * secpercyl and anything required in the strategy routine
- * (e.g., sector size) must be filled in before calling us.
- * Returns null on success and an error string on failure.
+ * Attempt to read a disk label from a device using the indicated stategy
+ * routine.  The label must be partly set up before this: secpercyl and
+ * anything required in the strategy routine (e.g., sector size) must be
+ * filled in before calling us.  Returns NULL on success and an error
+ * string on failure.
  */
 char *
 readdisklabel(dev, strat, lp)
  */
 char *
 readdisklabel(dev, strat, lp)
@@ -166,7 +154,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;
@@ -174,17 +163,15 @@ 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);
 }
 
 /*
- * Check new disk label for sensibility
- * before setting it.
+ * Check new disk label for sensibility before setting it.
  */
  */
+int
 setdisklabel(olp, nlp, openmask)
        register struct disklabel *olp, *nlp;
        u_long openmask;
 setdisklabel(olp, nlp, openmask)
        register struct disklabel *olp, *nlp;
        u_long openmask;
@@ -229,6 +216,7 @@ setdisklabel(olp, nlp, openmask)
 /*
  * Write disk label back to device after modification.
  */
 /*
  * Write disk label back to device after modification.
  */
+int
 writedisklabel(dev, strat, lp)
        dev_t dev;
        int (*strat)();
 writedisklabel(dev, strat, lp)
        dev_t dev;
        int (*strat)();
@@ -302,6 +290,7 @@ hp0g: hard error reading fsbn 12345 of 12344-12347 (hp0 bn %d cn %d tn %d sn %d)
  * The message should be completed (with at least a newline) with printf
  * or addlog, respectively.  There is no trailing space.
  */
  * The message should be completed (with at least a newline) with printf
  * or addlog, respectively.  There is no trailing space.
  */
+void
 diskerr(bp, dname, what, pri, blkdone, lp)
        register struct buf *bp;
        char *dname, *what;
 diskerr(bp, dname, what, pri, blkdone, lp)
        register struct buf *bp;
        char *dname, *what;
@@ -309,9 +298,9 @@ diskerr(bp, dname, what, pri, blkdone, lp)
        register struct disklabel *lp;
 {
        int unit = dkunit(bp->b_dev), part = dkpart(bp->b_dev);
        register struct disklabel *lp;
 {
        int unit = dkunit(bp->b_dev), part = dkpart(bp->b_dev);
-       register int (*pr)(), sn;
+       register void (*pr) __P((const char *, ...));
        char partname = 'a' + part;
        char partname = 'a' + part;
-       extern printf(), addlog();
+       int sn;
 
        if (pri != LOG_PRINTF) {
                log(pri, "");
 
        if (pri != LOG_PRINTF) {
                log(pri, "");