Changeset View
Changeset View
Standalone View
Standalone View
head/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, | ||||
periph->periph_name); | periph->periph_name, | ||||
sizeof(ccb->cgdl.periph_name)); | |||||
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, | ||||
sizeof(cdm->matches[j].result.bus_result.dev_name)); | |||||
} | } | ||||
/* | /* | ||||
* 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 202 Lines • ▼ Show 20 Lines | if ((retval & DM_RET_ACTION_MASK) == DM_RET_ERROR) { | ||||
return(0); | return(0); | ||||
} | } | ||||
/* | /* | ||||
* If the copy flag is set, copy this peripheral out. | * If the copy flag is set, copy this peripheral out. | ||||
*/ | */ | ||||
if (retval & DM_RET_COPY) { | if (retval & DM_RET_COPY) { | ||||
int spaceleft, j; | int spaceleft, j; | ||||
size_t l; | |||||
spaceleft = cdm->match_buf_len - (cdm->num_matches * | spaceleft = cdm->match_buf_len - (cdm->num_matches * | ||||
sizeof(struct dev_match_result)); | sizeof(struct dev_match_result)); | ||||
/* | /* | ||||
* If we don't have enough space to put in another | * If we don't have enough space to put in another | ||||
* match result, save our position and tell the | * match result, save our position and tell the | ||||
* user there are more devices to check. | * user there are more devices to check. | ||||
Show All 27 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, | l = sizeof(cdm->matches[j].result.periph_result.periph_name); | ||||
periph->periph_name, DEV_IDLEN); | strlcpy(cdm->matches[j].result.periph_result.periph_name, | ||||
periph->periph_name, l); | |||||
} | } | ||||
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 78 Lines • ▼ Show 20 Lines | if ((retval & DM_RET_ACTION_MASK) == DM_RET_ERROR) { | ||||
return(0); | return(0); | ||||
} | } | ||||
/* | /* | ||||
* If the copy flag is set, copy this peripheral out. | * If the copy flag is set, copy this peripheral out. | ||||
*/ | */ | ||||
if (retval & DM_RET_COPY) { | if (retval & DM_RET_COPY) { | ||||
int spaceleft, j; | int spaceleft, j; | ||||
size_t l; | |||||
spaceleft = cdm->match_buf_len - (cdm->num_matches * | spaceleft = cdm->match_buf_len - (cdm->num_matches * | ||||
sizeof(struct dev_match_result)); | sizeof(struct dev_match_result)); | ||||
/* | /* | ||||
* If we don't have enough space to put in another | * If we don't have enough space to put in another | ||||
* match result, save our position and tell the | * match result, save our position and tell the | ||||
* user there are more devices to check. | * user there are more devices to check. | ||||
▲ Show 20 Lines • Show All 60 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, | l = sizeof(cdm->matches[j].result.periph_result.periph_name); | ||||
periph->periph_name, DEV_IDLEN); | strlcpy(cdm->matches[j].result.periph_result.periph_name, | ||||
periph->periph_name, l); | |||||
} | } | ||||
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 696 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); | sizeof(cgdl->periph_name)); | ||||
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; | ||||
break; | break; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 2,659 Lines • Show Last 20 Lines |