summaryrefslogtreecommitdiffstats
path: root/sys/cam
diff options
context:
space:
mode:
authormjacob <mjacob@FreeBSD.org>2006-04-18 22:01:59 +0000
committermjacob <mjacob@FreeBSD.org>2006-04-18 22:01:59 +0000
commita8aa2f7420174a29a77fdbd0819f592c62506116 (patch)
tree1459e41011cc27e171dd534986f9ae81f887c4d8 /sys/cam
parent4a281133b72c4eac833249d87008ffd531168fb3 (diff)
downloadFreeBSD-src-a8aa2f7420174a29a77fdbd0819f592c62506116.zip
FreeBSD-src-a8aa2f7420174a29a77fdbd0819f592c62506116.tar.gz
Actually check to see if XPT_CALC_GEOMETRY had an error
and pick a bogus geometry if it had so we don't later get a divide by zero trap.
Diffstat (limited to 'sys/cam')
-rw-r--r--sys/cam/scsi/scsi_da.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c
index c31b10b..bc16d8b 100644
--- a/sys/cam/scsi/scsi_da.c
+++ b/sys/cam/scsi/scsi_da.c
@@ -1865,9 +1865,23 @@ dasetgeom(struct cam_periph *periph, uint32_t block_len, uint64_t maxsector)
ccg.secs_per_track = 0;
ccg.cylinders = 0;
xpt_action((union ccb*)&ccg);
- dp->heads = ccg.heads;
- dp->secs_per_track = ccg.secs_per_track;
- dp->cylinders = ccg.cylinders;
+ if ((ccg.ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
+ /*
+ * We don't know what went wrong here- but just pick
+ * a geometry so we don't have nasty things like divide
+ * by zero.
+ */
+ dp->heads = 255;
+ dp->secs_per_track = 255;
+ dp->cylinders = dp->sectors / (255 * 255);
+ if (dp->cylinders == 0) {
+ dp->cylinders = 1;
+ }
+ } else {
+ dp->heads = ccg.heads;
+ dp->secs_per_track = ccg.secs_per_track;
+ dp->cylinders = ccg.cylinders;
+ }
}
static void
OpenPOWER on IntegriCloud