From ee3794ce7d7ad116810ccf802a1fb4b74edb2079 Mon Sep 17 00:00:00 2001 From: Andreas Schulz Date: Tue, 15 Mar 1994 20:49:09 +0000 Subject: [PATCH] Catch the divide by zero bug earlier. If the drive give back a zero cylinder and/or head count, set them and the sector count to some fictious values. The same already happens if the request sense is unsuccessfull. --- sys/scsi/sd.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c index aee2076789ee..1cb15da6ad92 100644 --- a/sys/scsi/sd.c +++ b/sys/scsi/sd.c @@ -14,7 +14,7 @@ * * Ported to run under 386BSD by Julian Elischer (julian@dialix.oz.au) Sept 1992 * - * $Id: sd.c,v 1.18 1994/01/29 11:17:10 davidg Exp $ + * $Id: sd.c,v 1.19 1994/03/14 23:09:34 ats Exp $ */ #define SPLSD splbio @@ -183,7 +183,7 @@ sdattach(sc_link) sd_get_parms(unit, SCSI_NOSLEEP | SCSI_NOMASK); printf("sd%d: %dMB (%d total sec), %d cyl, %d head, %d sec, bytes/sec %d\n", unit, - dp->secsiz ? dp->disksize / ((1024L * 1024L) / dp->secsiz) : 0, + dp->disksize / ((1024L * 1024L) / dp->secsiz), dp->disksize, dp->cyls, dp->heads, @@ -877,7 +877,16 @@ sd_get_parms(unit, flags) 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;