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.
This commit is contained in:
Matt Jacob 2006-04-18 22:01:59 +00:00
parent 5b9fdd582c
commit 9dcfabf816
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=157856

View File

@ -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