Changeset View
Changeset View
Standalone View
Standalone View
sys/cam/cam_xpt.c
Show First 20 Lines • Show All 680 Lines • ▼ Show 20 Lines | if (periph != NULL) { | ||||
/* | /* | ||||
* Check to see whether we have a | * Check to see whether we have a | ||||
* passthrough device or not. | * passthrough device or not. | ||||
*/ | */ | ||||
if (strcmp(periph->periph_name, "pass") == 0) { | if (strcmp(periph->periph_name, "pass") == 0) { | ||||
/* | /* | ||||
* Fill in the getdevlist fields. | * Fill in the getdevlist fields. | ||||
*/ | */ | ||||
strcpy(ccb->cgdl.periph_name, | strlcpy(ccb->cgdl.periph_name, | ||||
imp: this actually did NUL terminate. It wasn't safe though. I'd make a note of the migration from… | |||||
periph->periph_name); | periph->periph_name, DEV_IDLEN); | ||||
impUnsubmitted Not Done Inline Actionsthe traditional thing here is 'sizeof(ccb->cgdl.periph_name)' instead of some random #define that may be right or wrong. We know the CCBs preallocate so we don't have to worry about the pointer issue. imp: the traditional thing here is 'sizeof(ccb->cgdl.periph_name)' instead of some random #define… | |||||
kenUnsubmitted Not Done Inline ActionsI agree with the sizeof() thing. That would be the better way to do it. ken: I agree with the sizeof() thing. That would be the better way to do it. | |||||
ccb->cgdl.unit_number = | ccb->cgdl.unit_number = | ||||
periph->unit_number; | periph->unit_number; | ||||
if (SLIST_NEXT(periph, periph_links)) | if (SLIST_NEXT(periph, periph_links)) | ||||
ccb->cgdl.status = | ccb->cgdl.status = | ||||
CAM_GDEVLIST_MORE_DEVS; | CAM_GDEVLIST_MORE_DEVS; | ||||
else | else | ||||
ccb->cgdl.status = | ccb->cgdl.status = | ||||
CAM_GDEVLIST_LAST_DEVICE; | CAM_GDEVLIST_LAST_DEVICE; | ||||
▲ Show 20 Lines • Show All 1,052 Lines • ▼ Show 20 Lines | if (retval & DM_RET_COPY) { | ||||
} | } | ||||
j = cdm->num_matches; | j = cdm->num_matches; | ||||
cdm->num_matches++; | cdm->num_matches++; | ||||
cdm->matches[j].type = DEV_MATCH_BUS; | cdm->matches[j].type = DEV_MATCH_BUS; | ||||
cdm->matches[j].result.bus_result.path_id = bus->path_id; | cdm->matches[j].result.bus_result.path_id = bus->path_id; | ||||
cdm->matches[j].result.bus_result.bus_id = bus->sim->bus_id; | cdm->matches[j].result.bus_result.bus_id = bus->sim->bus_id; | ||||
cdm->matches[j].result.bus_result.unit_number = | cdm->matches[j].result.bus_result.unit_number = | ||||
bus->sim->unit_number; | bus->sim->unit_number; | ||||
strncpy(cdm->matches[j].result.bus_result.dev_name, | strlcpy(cdm->matches[j].result.bus_result.dev_name, | ||||
bus->sim->sim_name, DEV_IDLEN); | bus->sim->sim_name, DEV_IDLEN); | ||||
impUnsubmitted Not Done Inline ActionsSame sizeof comment for this argument. imp: Same sizeof comment for this argument. | |||||
} | } | ||||
/* | /* | ||||
* If the user is only interested in buses, there's no | * If the user is only interested in buses, there's no | ||||
* reason to descend to the next level in the tree. | * reason to descend to the next level in the tree. | ||||
*/ | */ | ||||
if ((retval & DM_RET_ACTION_MASK) == DM_RET_STOP) | if ((retval & DM_RET_ACTION_MASK) == DM_RET_STOP) | ||||
return(1); | return(1); | ||||
▲ Show 20 Lines • Show All 245 Lines • ▼ Show 20 Lines | if (retval & DM_RET_COPY) { | ||||
cdm->matches[j].result.periph_result.path_id = | cdm->matches[j].result.periph_result.path_id = | ||||
periph->path->bus->path_id; | periph->path->bus->path_id; | ||||
cdm->matches[j].result.periph_result.target_id = | cdm->matches[j].result.periph_result.target_id = | ||||
periph->path->target->target_id; | periph->path->target->target_id; | ||||
cdm->matches[j].result.periph_result.target_lun = | cdm->matches[j].result.periph_result.target_lun = | ||||
periph->path->device->lun_id; | periph->path->device->lun_id; | ||||
cdm->matches[j].result.periph_result.unit_number = | cdm->matches[j].result.periph_result.unit_number = | ||||
periph->unit_number; | periph->unit_number; | ||||
strncpy(cdm->matches[j].result.periph_result.periph_name, | strlcpy(cdm->matches[j].result.periph_result.periph_name, | ||||
periph->periph_name, DEV_IDLEN); | periph->periph_name, DEV_IDLEN); | ||||
} | } | ||||
return(1); | return(1); | ||||
} | } | ||||
static int | static int | ||||
xptedtmatch(struct ccb_dev_match *cdm) | xptedtmatch(struct ccb_dev_match *cdm) | ||||
▲ Show 20 Lines • Show All 155 Lines • ▼ Show 20 Lines | if (periph->path->device) | ||||
cdm->matches[j].result.periph_result.target_lun = | cdm->matches[j].result.periph_result.target_lun = | ||||
periph->path->device->lun_id; | periph->path->device->lun_id; | ||||
else | else | ||||
cdm->matches[j].result.periph_result.target_lun = | cdm->matches[j].result.periph_result.target_lun = | ||||
CAM_LUN_WILDCARD; | CAM_LUN_WILDCARD; | ||||
cdm->matches[j].result.periph_result.unit_number = | cdm->matches[j].result.periph_result.unit_number = | ||||
periph->unit_number; | periph->unit_number; | ||||
strncpy(cdm->matches[j].result.periph_result.periph_name, | strlcpy(cdm->matches[j].result.periph_result.periph_name, | ||||
periph->periph_name, DEV_IDLEN); | periph->periph_name, DEV_IDLEN); | ||||
} | } | ||||
return(1); | return(1); | ||||
} | } | ||||
static int | static int | ||||
xptperiphlistmatch(struct ccb_dev_match *cdm) | xptperiphlistmatch(struct ccb_dev_match *cdm) | ||||
▲ Show 20 Lines • Show All 697 Lines • ▼ Show 20 Lines | case XPT_GDEVLIST: | ||||
/* | /* | ||||
* Traverse the list of peripherals and attempt to find | * Traverse the list of peripherals and attempt to find | ||||
* the requested peripheral. | * the requested peripheral. | ||||
*/ | */ | ||||
for (nperiph = SLIST_FIRST(periph_head), i = 0; | for (nperiph = SLIST_FIRST(periph_head), i = 0; | ||||
(nperiph != NULL) && (i <= cgdl->index); | (nperiph != NULL) && (i <= cgdl->index); | ||||
nperiph = SLIST_NEXT(nperiph, periph_links), i++) { | nperiph = SLIST_NEXT(nperiph, periph_links), i++) { | ||||
if (i == cgdl->index) { | if (i == cgdl->index) { | ||||
strncpy(cgdl->periph_name, | strlcpy(cgdl->periph_name, | ||||
nperiph->periph_name, | nperiph->periph_name, | ||||
DEV_IDLEN); | DEV_IDLEN); | ||||
cgdl->unit_number = nperiph->unit_number; | cgdl->unit_number = nperiph->unit_number; | ||||
found = 1; | found = 1; | ||||
} | } | ||||
} | } | ||||
if (found == 0) { | if (found == 0) { | ||||
cgdl->status = CAM_GDEVLIST_ERROR; | cgdl->status = CAM_GDEVLIST_ERROR; | ||||
▲ Show 20 Lines • Show All 2,661 Lines • Show Last 20 Lines |
this actually did NUL terminate. It wasn't safe though. I'd make a note of the migration from the unsafe / hard-to-user interfaces to the strl interfaces in the commit.