From bc8cb7d0b46b7cba7163df1649d0c9adea914c5a Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Mon, 7 Nov 1994 20:09:35 +0000 Subject: Avoid a division by zero if the actual sector size isn't known during the device announcement; assume a sector size of 512 instead (likely to be right at all). This case happens when booting with a removable disk device attached (e.g. an MOD), but no medium inserted. --- sys/scsi/sd.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c index f30df75377c5..ac375435bda1 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.39 1994/10/31 23:45:40 phk Exp $ + * $Id: sd.c,v 1.40 1994/11/03 18:20:15 joerg Exp $ */ #define SPLSD splbio @@ -221,6 +221,12 @@ sdattach(sc_link) * request must specify this. */ sd_get_parms(unit, SCSI_NOSLEEP | SCSI_NOMASK); + /* + * if we don't have actual parameters, assume 512 bytes/sec + * (could happen on removable media - MOD) + * -- this avoids the division below from falling over + */ + if(dp->secsiz == 0) dp->secsiz = 512; printf("sd%ld: %ldMB (%ld total sec), %d cyl, %d head, %d sec, bytes/sec %d\n", unit, dp->disksize / ((1024L * 1024L) / dp->secsiz), -- cgit v1.2.3