diff options
author | joerg <joerg@FreeBSD.org> | 1994-11-07 20:09:35 +0000 |
---|---|---|
committer | joerg <joerg@FreeBSD.org> | 1994-11-07 20:09:35 +0000 |
commit | b78cd14f01f62a5e22144088014cd73f25ee8137 (patch) | |
tree | 965c647a60748e913c2e1f48209648a4904de7de | |
parent | 85b4fbc7138b6ea2ed09c725f2be12681ecf172a (diff) | |
download | FreeBSD-src-b78cd14f01f62a5e22144088014cd73f25ee8137.zip FreeBSD-src-b78cd14f01f62a5e22144088014cd73f25ee8137.tar.gz |
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.
-rw-r--r-- | sys/scsi/sd.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c index f30df75..ac37543 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), |