Catch the divide by zero bug earlier. If the drive give back
[unix-history] / sys / scsi / sd.c
index f785660..1cb15da 100644 (file)
@@ -14,7 +14,7 @@
  *
  * Ported to run under 386BSD by Julian Elischer (julian@dialix.oz.au) Sept 1992
  *
  *
  * Ported to run under 386BSD by Julian Elischer (julian@dialix.oz.au) Sept 1992
  *
- *      $Id: sd.c,v 1.14 1993/12/19 00:54:57 wollman Exp $
+ *      $Id: sd.c,v 1.19 1994/03/14 23:09:34 ats Exp $
  */
 
 #define SPLSD splbio
  */
 
 #define SPLSD splbio
@@ -818,7 +818,7 @@ sd_get_parms(unit, flags)
        /*
         * First check if we have it all loaded
         */
        /*
         * First check if we have it all loaded
         */
-       if (sd->flags & SDEV_MEDIA_LOADED)
+       if (sd->sc_link->flags & SDEV_MEDIA_LOADED)
                return 0;
 
        /*
                return 0;
 
        /*
@@ -877,7 +877,16 @@ sd_get_parms(unit, flags)
 
                sectors = sd_size(unit, flags);
                disk_parms->disksize = sectors;
 
                sectors = sd_size(unit, flags);
                disk_parms->disksize = sectors;
-               sectors /= (disk_parms->heads * disk_parms->cyls);
+               /* Check if none of these values are zero */
+               if(disk_parms->heads && disk_parms->cyls) {
+                       sectors /= (disk_parms->heads * disk_parms->cyls);
+               }
+               else {
+                       /* set it to something reasonable */
+                       sectors = 32;
+                       disk_parms->heads = 64;
+                       disk_parms->cyls = sectors / (64 * 32);
+               }
                disk_parms->sectors = sectors;  /* dubious on SCSI *//*XXX */
        }
        sd->sc_link->flags |= SDEV_MEDIA_LOADED;
                disk_parms->sectors = sectors;  /* dubious on SCSI *//*XXX */
        }
        sd->sc_link->flags |= SDEV_MEDIA_LOADED;
@@ -972,10 +981,9 @@ sddump(dev_t dev)
        sddoingadump = 1;
 
        blknum = dumplo + blkoff;
        sddoingadump = 1;
 
        blknum = dumplo + blkoff;
-       /* blkcnt = initialise_me; */
        while (num > 0) {
                 *(int *)CMAP1 =
        while (num > 0) {
                 *(int *)CMAP1 =
-                       PG_V | PG_KW | ((unsigned long)addr >> PG_SHIFT);
+                       PG_V | PG_KW | trunc_page(addr);
                 tlbflush();
                /*
                 *  Fill out the scsi command
                 tlbflush();
                /*
                 *  Fill out the scsi command