Changeset View
Changeset View
Standalone View
Standalone View
sbin/camcontrol/camcontrol.c
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 105 Lines • ▼ Show 20 Lines | typedef enum { | ||||
CAM_CMD_REPROBE, | CAM_CMD_REPROBE, | ||||
CAM_CMD_ZONE, | CAM_CMD_ZONE, | ||||
CAM_CMD_EPC, | CAM_CMD_EPC, | ||||
CAM_CMD_TIMESTAMP, | CAM_CMD_TIMESTAMP, | ||||
CAM_CMD_MMCSD_CMD, | CAM_CMD_MMCSD_CMD, | ||||
CAM_CMD_POWER_MODE, | CAM_CMD_POWER_MODE, | ||||
CAM_CMD_DEVTYPE, | CAM_CMD_DEVTYPE, | ||||
CAM_CMD_AMA, | CAM_CMD_AMA, | ||||
} cam_cmd; | } cam_cmd; | ||||
imp: This is a good change, but unrelated.
| |||||
typedef enum { | typedef enum { | ||||
CAM_ARG_NONE = 0x00000000, | CAM_ARG_NONE = 0x00000000, | ||||
CAM_ARG_VERBOSE = 0x00000001, | CAM_ARG_VERBOSE = 0x00000001, | ||||
CAM_ARG_DEVICE = 0x00000002, | CAM_ARG_DEVICE = 0x00000002, | ||||
CAM_ARG_BUS = 0x00000004, | CAM_ARG_BUS = 0x00000004, | ||||
CAM_ARG_TARGET = 0x00000008, | CAM_ARG_TARGET = 0x00000008, | ||||
CAM_ARG_LUN = 0x00000010, | CAM_ARG_LUN = 0x00000010, | ||||
▲ Show 20 Lines • Show All 119 Lines • ▼ Show 20 Lines | struct cam_devitem { | ||||
int device_id_len; | int device_id_len; | ||||
STAILQ_ENTRY(cam_devitem) links; | STAILQ_ENTRY(cam_devitem) links; | ||||
}; | }; | ||||
struct cam_devlist { | struct cam_devlist { | ||||
STAILQ_HEAD(, cam_devitem) dev_queue; | STAILQ_HEAD(, cam_devitem) dev_queue; | ||||
path_id_t path_id; | path_id_t path_id; | ||||
}; | }; | ||||
static cam_argmask arglist; | static cam_argmask arglist; | ||||
Not Done Inline Actionsditto imp: ditto | |||||
static const char *devtype_names[] = { | static const char *devtype_names[] = { | ||||
"none", | "none", | ||||
"scsi", | "scsi", | ||||
"satl", | "satl", | ||||
"ata", | "ata", | ||||
"nvme", | "nvme", | ||||
"mmcsd", | "mmcsd", | ||||
▲ Show 20 Lines • Show All 756 Lines • ▼ Show 20 Lines | scsiinquiry(struct cam_device *device, int task_attr, int retry_count, | ||||
ccb = cam_getccb(device); | ccb = cam_getccb(device); | ||||
if (ccb == NULL) { | if (ccb == NULL) { | ||||
warnx("couldn't allocate CCB"); | warnx("couldn't allocate CCB"); | ||||
return (1); | return (1); | ||||
} | } | ||||
/* cam_getccb cleans up the header, caller has to zero the payload */ | |||||
CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->csio); | |||||
inq_buf = (struct scsi_inquiry_data *)malloc( | inq_buf = (struct scsi_inquiry_data *)malloc( | ||||
sizeof(struct scsi_inquiry_data)); | sizeof(struct scsi_inquiry_data)); | ||||
if (inq_buf == NULL) { | if (inq_buf == NULL) { | ||||
cam_freeccb(ccb); | cam_freeccb(ccb); | ||||
warnx("can't malloc memory for inquiry\n"); | warnx("can't malloc memory for inquiry\n"); | ||||
return (1); | return (1); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | scsiserial(struct cam_device *device, int task_attr, int retry_count, | ||||
ccb = cam_getccb(device); | ccb = cam_getccb(device); | ||||
if (ccb == NULL) { | if (ccb == NULL) { | ||||
warnx("couldn't allocate CCB"); | warnx("couldn't allocate CCB"); | ||||
return (1); | return (1); | ||||
} | } | ||||
/* cam_getccb cleans up the header, caller has to zero the payload */ | |||||
CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->csio); | |||||
serial_buf = (struct scsi_vpd_unit_serial_number *) | serial_buf = (struct scsi_vpd_unit_serial_number *) | ||||
malloc(sizeof(*serial_buf)); | malloc(sizeof(*serial_buf)); | ||||
if (serial_buf == NULL) { | if (serial_buf == NULL) { | ||||
cam_freeccb(ccb); | cam_freeccb(ccb); | ||||
warnx("can't malloc memory for serial number"); | warnx("can't malloc memory for serial number"); | ||||
return (1); | return (1); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | camxferrate(struct cam_device *device) | ||||
ccb = cam_getccb(device); | ccb = cam_getccb(device); | ||||
if (ccb == NULL) { | if (ccb == NULL) { | ||||
warnx("couldn't allocate CCB"); | warnx("couldn't allocate CCB"); | ||||
return (1); | return (1); | ||||
} | } | ||||
CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->cts); | |||||
ccb->ccb_h.func_code = XPT_GET_TRAN_SETTINGS; | ccb->ccb_h.func_code = XPT_GET_TRAN_SETTINGS; | ||||
ccb->cts.type = CTS_TYPE_CURRENT_SETTINGS; | ccb->cts.type = CTS_TYPE_CURRENT_SETTINGS; | ||||
if (((retval = cam_send_ccb(device, ccb)) < 0) | if (((retval = cam_send_ccb(device, ccb)) < 0) | ||||
|| ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP)) { | || ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP)) { | ||||
const char error_string[] = "error getting transfer settings"; | const char error_string[] = "error getting transfer settings"; | ||||
if (retval < 0) | if (retval < 0) | ||||
▲ Show 20 Lines • Show All 589 Lines • ▼ Show 20 Lines | if (data_ptr != NULL) { | ||||
if (flags & CAM_DIR_OUT) | if (flags & CAM_DIR_OUT) | ||||
ata_flags |= AP_FLAG_TDIR_TO_DEV; | ata_flags |= AP_FLAG_TDIR_TO_DEV; | ||||
else | else | ||||
ata_flags |= AP_FLAG_TDIR_FROM_DEV; | ata_flags |= AP_FLAG_TDIR_FROM_DEV; | ||||
} else { | } else { | ||||
ata_flags |= AP_FLAG_TLEN_NO_DATA; | ata_flags |= AP_FLAG_TLEN_NO_DATA; | ||||
} | } | ||||
CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->csio); | CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->csio); | ||||
Not Done Inline ActionsThis one I'm not sure of since I've not traced all callers of ata_do_pass_16 imp: This one I'm not sure of since I've not traced all callers of ata_do_pass_16 | |||||
Not Done Inline ActionsI'm pretty sure this isn't good. atahpa() gets a ccb imp: I'm pretty sure this isn't good.
atahpa() gets a ccb
Then calls ata_do_identify (which fills… | |||||
scsi_ata_pass_16(&ccb->csio, | scsi_ata_pass_16(&ccb->csio, | ||||
retries, | retries, | ||||
NULL, | NULL, | ||||
flags, | flags, | ||||
tag_action, | tag_action, | ||||
protocol, | protocol, | ||||
ata_flags, | ata_flags, | ||||
▲ Show 20 Lines • Show All 2,638 Lines • ▼ Show 20 Lines | mode_select(struct cam_device *device, int cdb_len, int save_pages, | ||||
union ccb *ccb; | union ccb *ccb; | ||||
int retval; | int retval; | ||||
ccb = cam_getccb(device); | ccb = cam_getccb(device); | ||||
if (ccb == NULL) | if (ccb == NULL) | ||||
errx(1, "mode_select: couldn't allocate CCB"); | errx(1, "mode_select: couldn't allocate CCB"); | ||||
CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->csio); | |||||
scsi_mode_select_len(&ccb->csio, | scsi_mode_select_len(&ccb->csio, | ||||
/* retries */ retry_count, | /* retries */ retry_count, | ||||
/* cbfcnp */ NULL, | /* cbfcnp */ NULL, | ||||
/* tag_action */ task_attr, | /* tag_action */ task_attr, | ||||
/* scsi_page_fmt */ 1, | /* scsi_page_fmt */ 1, | ||||
/* save_pages */ save_pages, | /* save_pages */ save_pages, | ||||
/* param_buf */ data, | /* param_buf */ data, | ||||
/* param_len */ datalen, | /* param_len */ datalen, | ||||
▲ Show 20 Lines • Show All 122 Lines • ▼ Show 20 Lines | scsicmd(struct cam_device *device, int argc, char **argv, char *combinedopt, | ||||
ccb = cam_getccb(device); | ccb = cam_getccb(device); | ||||
if (ccb == NULL) { | if (ccb == NULL) { | ||||
warnx("scsicmd: error allocating ccb"); | warnx("scsicmd: error allocating ccb"); | ||||
return (1); | return (1); | ||||
} | } | ||||
CCB_CLEAR_ALL_EXCEPT_HDR(ccb); | |||||
while ((c = getopt(argc, argv, combinedopt)) != -1) { | while ((c = getopt(argc, argv, combinedopt)) != -1) { | ||||
switch(c) { | switch(c) { | ||||
case 'a': | case 'a': | ||||
tstr = optarg; | tstr = optarg; | ||||
while (isspace(*tstr) && (*tstr != '\0')) | while (isspace(*tstr) && (*tstr != '\0')) | ||||
tstr++; | tstr++; | ||||
hook.argc = argc - optind; | hook.argc = argc - optind; | ||||
hook.argv = argv + optind; | hook.argv = argv + optind; | ||||
▲ Show 20 Lines • Show All 468 Lines • ▼ Show 20 Lines | while ((c = getopt(argc, argv, combinedopt)) != -1) { | ||||
default: | default: | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
cam_path_string(device, pathstr, sizeof(pathstr)); | cam_path_string(device, pathstr, sizeof(pathstr)); | ||||
if (numtags >= 0) { | if (numtags >= 0) { | ||||
CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->crs); | |||||
ccb->ccb_h.func_code = XPT_REL_SIMQ; | ccb->ccb_h.func_code = XPT_REL_SIMQ; | ||||
ccb->ccb_h.flags = CAM_DEV_QFREEZE; | ccb->ccb_h.flags = CAM_DEV_QFREEZE; | ||||
ccb->crs.release_flags = RELSIM_ADJUST_OPENINGS; | ccb->crs.release_flags = RELSIM_ADJUST_OPENINGS; | ||||
ccb->crs.openings = numtags; | ccb->crs.openings = numtags; | ||||
if (cam_send_ccb(device, ccb) < 0) { | if (cam_send_ccb(device, ccb) < 0) { | ||||
warn("error sending XPT_REL_SIMQ CCB"); | warn("error sending XPT_REL_SIMQ CCB"); | ||||
▲ Show 20 Lines • Show All 227 Lines • ▼ Show 20 Lines | get_cpi(struct cam_device *device, struct ccb_pathinq *cpi) | ||||
union ccb *ccb; | union ccb *ccb; | ||||
int retval = 0; | int retval = 0; | ||||
ccb = cam_getccb(device); | ccb = cam_getccb(device); | ||||
if (ccb == NULL) { | if (ccb == NULL) { | ||||
warnx("get_cpi: couldn't allocate CCB"); | warnx("get_cpi: couldn't allocate CCB"); | ||||
return (1); | return (1); | ||||
} | } | ||||
CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->cpi); | |||||
ccb->ccb_h.func_code = XPT_PATH_INQ; | ccb->ccb_h.func_code = XPT_PATH_INQ; | ||||
if (cam_send_ccb(device, ccb) < 0) { | if (cam_send_ccb(device, ccb) < 0) { | ||||
warn("get_cpi: error sending Path Inquiry CCB"); | warn("get_cpi: error sending Path Inquiry CCB"); | ||||
retval = 1; | retval = 1; | ||||
goto get_cpi_bailout; | goto get_cpi_bailout; | ||||
} | } | ||||
if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { | if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { | ||||
if (arglist & CAM_ARG_VERBOSE) | if (arglist & CAM_ARG_VERBOSE) | ||||
Show All 18 Lines | get_cgd(struct cam_device *device, struct ccb_getdev *cgd) | ||||
union ccb *ccb; | union ccb *ccb; | ||||
int retval = 0; | int retval = 0; | ||||
ccb = cam_getccb(device); | ccb = cam_getccb(device); | ||||
if (ccb == NULL) { | if (ccb == NULL) { | ||||
warnx("get_cgd: couldn't allocate CCB"); | warnx("get_cgd: couldn't allocate CCB"); | ||||
return (1); | return (1); | ||||
} | } | ||||
CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->cgd); | |||||
ccb->ccb_h.func_code = XPT_GDEV_TYPE; | ccb->ccb_h.func_code = XPT_GDEV_TYPE; | ||||
if (cam_send_ccb(device, ccb) < 0) { | if (cam_send_ccb(device, ccb) < 0) { | ||||
warn("get_cgd: error sending Get type information CCB"); | warn("get_cgd: error sending Get type information CCB"); | ||||
retval = 1; | retval = 1; | ||||
goto get_cgd_bailout; | goto get_cgd_bailout; | ||||
} | } | ||||
if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { | if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { | ||||
if (arglist & CAM_ARG_VERBOSE) | if (arglist & CAM_ARG_VERBOSE) | ||||
Show All 24 Lines | dev_has_vpd_page(struct cam_device *dev, uint8_t page_id, int retry_count, | ||||
ccb = cam_getccb(dev); | ccb = cam_getccb(dev); | ||||
if (ccb == NULL) { | if (ccb == NULL) { | ||||
warn("Unable to allocate CCB"); | warn("Unable to allocate CCB"); | ||||
retval = -1; | retval = -1; | ||||
goto bailout; | goto bailout; | ||||
} | } | ||||
/* cam_getccb cleans up the header, caller has to zero the payload */ | |||||
CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->csio); | |||||
bzero(&sup_pages, sizeof(sup_pages)); | bzero(&sup_pages, sizeof(sup_pages)); | ||||
scsi_inquiry(&ccb->csio, | scsi_inquiry(&ccb->csio, | ||||
/*retries*/ retry_count, | /*retries*/ retry_count, | ||||
/*cbfcnp*/ NULL, | /*cbfcnp*/ NULL, | ||||
/* tag_action */ MSG_SIMPLE_Q_TAG, | /* tag_action */ MSG_SIMPLE_Q_TAG, | ||||
/* inq_buf */ (u_int8_t *)&sup_pages, | /* inq_buf */ (u_int8_t *)&sup_pages, | ||||
/* inq_len */ sizeof(sup_pages), | /* inq_len */ sizeof(sup_pages), | ||||
▲ Show 20 Lines • Show All 518 Lines • ▼ Show 20 Lines | get_print_cts(struct cam_device *device, int user_settings, int quiet, | ||||
retval = 0; | retval = 0; | ||||
ccb = cam_getccb(device); | ccb = cam_getccb(device); | ||||
if (ccb == NULL) { | if (ccb == NULL) { | ||||
warnx("get_print_cts: error allocating ccb"); | warnx("get_print_cts: error allocating ccb"); | ||||
return (1); | return (1); | ||||
} | } | ||||
CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->cts); | |||||
ccb->ccb_h.func_code = XPT_GET_TRAN_SETTINGS; | ccb->ccb_h.func_code = XPT_GET_TRAN_SETTINGS; | ||||
if (user_settings == 0) | if (user_settings == 0) | ||||
ccb->cts.type = CTS_TYPE_CURRENT_SETTINGS; | ccb->cts.type = CTS_TYPE_CURRENT_SETTINGS; | ||||
else | else | ||||
ccb->cts.type = CTS_TYPE_USER_SETTINGS; | ccb->cts.type = CTS_TYPE_USER_SETTINGS; | ||||
if (cam_send_ccb(device, ccb) < 0) { | if (cam_send_ccb(device, ccb) < 0) { | ||||
▲ Show 20 Lines • Show All 126 Lines • ▼ Show 20 Lines | ratecontrol(struct cam_device *device, int task_attr, int retry_count, | ||||
} | } | ||||
/* | /* | ||||
* Grab path inquiry information, so we can determine whether | * Grab path inquiry information, so we can determine whether | ||||
* or not the initiator is capable of the things that the user | * or not the initiator is capable of the things that the user | ||||
* requests. | * requests. | ||||
*/ | */ | ||||
if ((retval = get_cpi(device, &cpi)) != 0) | if ((retval = get_cpi(device, &cpi)) != 0) | ||||
goto ratecontrol_bailout; | goto ratecontrol_bailout; | ||||
CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->cts); | |||||
if (quiet == 0) { | if (quiet == 0) { | ||||
fprintf(stdout, "%s parameters:\n", | fprintf(stdout, "%s parameters:\n", | ||||
user_settings ? "User" : "Current"); | user_settings ? "User" : "Current"); | ||||
} | } | ||||
retval = get_print_cts(device, user_settings, quiet, &ccb->cts); | retval = get_print_cts(device, user_settings, quiet, &ccb->cts); | ||||
if (retval != 0) | if (retval != 0) | ||||
goto ratecontrol_bailout; | goto ratecontrol_bailout; | ||||
▲ Show 20 Lines • Show All 232 Lines • ▼ Show 20 Lines | scsiformat(struct cam_device *device, int argc, char **argv, | ||||
ccb = cam_getccb(device); | ccb = cam_getccb(device); | ||||
if (ccb == NULL) { | if (ccb == NULL) { | ||||
warnx("scsiformat: error allocating ccb"); | warnx("scsiformat: error allocating ccb"); | ||||
return (1); | return (1); | ||||
} | } | ||||
CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->csio); | |||||
while ((c = getopt(argc, argv, combinedopt)) != -1) { | while ((c = getopt(argc, argv, combinedopt)) != -1) { | ||||
switch(c) { | switch(c) { | ||||
case 'q': | case 'q': | ||||
quiet++; | quiet++; | ||||
break; | break; | ||||
case 'r': | case 'r': | ||||
reportonly = 1; | reportonly = 1; | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 477 Lines • ▼ Show 20 Lines | sanitize(struct cam_device *device, int argc, char **argv, | ||||
ccb = cam_getccb(device); | ccb = cam_getccb(device); | ||||
if (ccb == NULL) { | if (ccb == NULL) { | ||||
warnx("sanitize: error allocating ccb"); | warnx("sanitize: error allocating ccb"); | ||||
return (1); | return (1); | ||||
} | } | ||||
CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->csio); | |||||
while ((c = getopt(argc, argv, combinedopt)) != -1) { | while ((c = getopt(argc, argv, combinedopt)) != -1) { | ||||
switch(c) { | switch(c) { | ||||
case 'a': | case 'a': | ||||
if (strcasecmp(optarg, "overwrite") == 0) | if (strcasecmp(optarg, "overwrite") == 0) | ||||
action = SSZ_SERVICE_ACTION_OVERWRITE; | action = SSZ_SERVICE_ACTION_OVERWRITE; | ||||
else if (strcasecmp(optarg, "block") == 0) | else if (strcasecmp(optarg, "block") == 0) | ||||
action = SSZ_SERVICE_ACTION_BLOCK_ERASE; | action = SSZ_SERVICE_ACTION_BLOCK_ERASE; | ||||
else if (strcasecmp(optarg, "crypto") == 0) | else if (strcasecmp(optarg, "crypto") == 0) | ||||
▲ Show 20 Lines • Show All 340 Lines • ▼ Show 20 Lines | scsireportluns(struct cam_device *device, int argc, char **argv, | ||||
report_type = RPL_REPORT_DEFAULT; | report_type = RPL_REPORT_DEFAULT; | ||||
ccb = cam_getccb(device); | ccb = cam_getccb(device); | ||||
if (ccb == NULL) { | if (ccb == NULL) { | ||||
warnx("%s: error allocating ccb", __func__); | warnx("%s: error allocating ccb", __func__); | ||||
return (1); | return (1); | ||||
} | } | ||||
CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->csio); | |||||
countonly = 0; | countonly = 0; | ||||
lunsonly = 0; | lunsonly = 0; | ||||
while ((c = getopt(argc, argv, combinedopt)) != -1) { | while ((c = getopt(argc, argv, combinedopt)) != -1) { | ||||
switch (c) { | switch (c) { | ||||
case 'c': | case 'c': | ||||
countonly++; | countonly++; | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 226 Lines • ▼ Show 20 Lines | scsireadcapacity(struct cam_device *device, int argc, char **argv, | ||||
ccb = cam_getccb(device); | ccb = cam_getccb(device); | ||||
if (ccb == NULL) { | if (ccb == NULL) { | ||||
warnx("%s: error allocating ccb", __func__); | warnx("%s: error allocating ccb", __func__); | ||||
return (1); | return (1); | ||||
} | } | ||||
CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->csio); | |||||
while ((c = getopt(argc, argv, combinedopt)) != -1) { | while ((c = getopt(argc, argv, combinedopt)) != -1) { | ||||
switch (c) { | switch (c) { | ||||
case 'b': | case 'b': | ||||
blocksizeonly++; | blocksizeonly++; | ||||
break; | break; | ||||
case 'h': | case 'h': | ||||
humanize++; | humanize++; | ||||
baseten = 0; | baseten = 0; | ||||
▲ Show 20 Lines • Show All 183 Lines • ▼ Show 20 Lines | smpcmd(struct cam_device *device, int argc, char **argv, char *combinedopt, | ||||
* devices that aren't probed by CAM. | * devices that aren't probed by CAM. | ||||
*/ | */ | ||||
ccb = cam_getccb(device); | ccb = cam_getccb(device); | ||||
if (ccb == NULL) { | if (ccb == NULL) { | ||||
warnx("%s: error allocating CCB", __func__); | warnx("%s: error allocating CCB", __func__); | ||||
return (1); | return (1); | ||||
} | } | ||||
CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->smpio); | |||||
while ((c = getopt(argc, argv, combinedopt)) != -1) { | while ((c = getopt(argc, argv, combinedopt)) != -1) { | ||||
switch (c) { | switch (c) { | ||||
case 'R': | case 'R': | ||||
arglist |= CAM_ARG_CMD_IN; | arglist |= CAM_ARG_CMD_IN; | ||||
response_size = strtol(optarg, NULL, 0); | response_size = strtol(optarg, NULL, 0); | ||||
if (response_size <= 0) { | if (response_size <= 0) { | ||||
warnx("invalid number of response bytes %d", | warnx("invalid number of response bytes %d", | ||||
response_size); | response_size); | ||||
▲ Show 20 Lines • Show All 531 Lines • ▼ Show 20 Lines | smpreportgeneral(struct cam_device *device, int argc, char **argv, | ||||
* devices that aren't probed by CAM. | * devices that aren't probed by CAM. | ||||
*/ | */ | ||||
ccb = cam_getccb(device); | ccb = cam_getccb(device); | ||||
if (ccb == NULL) { | if (ccb == NULL) { | ||||
warnx("%s: error allocating CCB", __func__); | warnx("%s: error allocating CCB", __func__); | ||||
return (1); | return (1); | ||||
} | } | ||||
CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->smpio); | |||||
while ((c = getopt(argc, argv, combinedopt)) != -1) { | while ((c = getopt(argc, argv, combinedopt)) != -1) { | ||||
switch (c) { | switch (c) { | ||||
case 'l': | case 'l': | ||||
long_response = 1; | long_response = 1; | ||||
break; | break; | ||||
default: | default: | ||||
break; | break; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 126 Lines • ▼ Show 20 Lines | smpphycontrol(struct cam_device *device, int argc, char **argv, | ||||
* devices that aren't probed by CAM. | * devices that aren't probed by CAM. | ||||
*/ | */ | ||||
ccb = cam_getccb(device); | ccb = cam_getccb(device); | ||||
if (ccb == NULL) { | if (ccb == NULL) { | ||||
warnx("%s: error allocating CCB", __func__); | warnx("%s: error allocating CCB", __func__); | ||||
return (1); | return (1); | ||||
} | } | ||||
CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->smpio); | |||||
while ((c = getopt(argc, argv, combinedopt)) != -1) { | while ((c = getopt(argc, argv, combinedopt)) != -1) { | ||||
switch (c) { | switch (c) { | ||||
case 'a': | case 'a': | ||||
case 'A': | case 'A': | ||||
case 's': | case 's': | ||||
case 'S': { | case 'S': { | ||||
int enable = -1; | int enable = -1; | ||||
▲ Show 20 Lines • Show All 239 Lines • ▼ Show 20 Lines | smpmaninfo(struct cam_device *device, int argc, char **argv, | ||||
* devices that aren't probed by CAM. | * devices that aren't probed by CAM. | ||||
*/ | */ | ||||
ccb = cam_getccb(device); | ccb = cam_getccb(device); | ||||
if (ccb == NULL) { | if (ccb == NULL) { | ||||
warnx("%s: error allocating CCB", __func__); | warnx("%s: error allocating CCB", __func__); | ||||
return (1); | return (1); | ||||
} | } | ||||
CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->smpio); | |||||
while ((c = getopt(argc, argv, combinedopt)) != -1) { | while ((c = getopt(argc, argv, combinedopt)) != -1) { | ||||
switch (c) { | switch (c) { | ||||
case 'l': | case 'l': | ||||
long_response = 1; | long_response = 1; | ||||
break; | break; | ||||
default: | default: | ||||
break; | break; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | getdevid(struct cam_devitem *item) | ||||
ccb = cam_getccb(dev); | ccb = cam_getccb(dev); | ||||
if (ccb == NULL) { | if (ccb == NULL) { | ||||
warnx("%s: error allocating CCB", __func__); | warnx("%s: error allocating CCB", __func__); | ||||
retval = 1; | retval = 1; | ||||
goto bailout; | goto bailout; | ||||
} | } | ||||
CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->cdai); | |||||
/* | /* | ||||
* On the first try, we just probe for the size of the data, and | * On the first try, we just probe for the size of the data, and | ||||
* then allocate that much memory and try again. | * then allocate that much memory and try again. | ||||
*/ | */ | ||||
retry: | retry: | ||||
ccb->ccb_h.func_code = XPT_DEV_ADVINFO; | ccb->ccb_h.func_code = XPT_DEV_ADVINFO; | ||||
ccb->ccb_h.flags = CAM_DIR_IN; | ccb->ccb_h.flags = CAM_DIR_IN; | ||||
ccb->cdai.flags = CDAI_FLAG_NONE; | ccb->cdai.flags = CDAI_FLAG_NONE; | ||||
▲ Show 20 Lines • Show All 267 Lines • ▼ Show 20 Lines | smpphylist(struct cam_device *device, int argc, char **argv, | ||||
* devices that aren't probed by CAM. | * devices that aren't probed by CAM. | ||||
*/ | */ | ||||
ccb = cam_getccb(device); | ccb = cam_getccb(device); | ||||
if (ccb == NULL) { | if (ccb == NULL) { | ||||
warnx("%s: error allocating CCB", __func__); | warnx("%s: error allocating CCB", __func__); | ||||
return (1); | return (1); | ||||
} | } | ||||
CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->smpio); | |||||
STAILQ_INIT(&devlist.dev_queue); | STAILQ_INIT(&devlist.dev_queue); | ||||
rgrequest = malloc(sizeof(*rgrequest)); | rgrequest = malloc(sizeof(*rgrequest)); | ||||
if (rgrequest == NULL) { | if (rgrequest == NULL) { | ||||
warn("%s: unable to allocate %zd bytes", __func__, | warn("%s: unable to allocate %zd bytes", __func__, | ||||
sizeof(*rgrequest)); | sizeof(*rgrequest)); | ||||
retval = 1; | retval = 1; | ||||
goto bailout; | goto bailout; | ||||
▲ Show 20 Lines • Show All 448 Lines • ▼ Show 20 Lines | scsigetopcodes(struct cam_device *device, int opcode_set, int opcode, | ||||
ccb = cam_getccb(device); | ccb = cam_getccb(device); | ||||
if (ccb == NULL) { | if (ccb == NULL) { | ||||
warnx("couldn't allocate CCB"); | warnx("couldn't allocate CCB"); | ||||
retval = 1; | retval = 1; | ||||
goto bailout; | goto bailout; | ||||
} | } | ||||
/* cam_getccb cleans up the header, caller has to zero the payload */ | |||||
CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->csio); | |||||
if (opcode_set != 0) { | if (opcode_set != 0) { | ||||
options |= RSO_OPTIONS_OC; | options |= RSO_OPTIONS_OC; | ||||
num_opcodes = 1; | num_opcodes = 1; | ||||
alloc_len = sizeof(*one) + CAM_MAX_CDBLEN; | alloc_len = sizeof(*one) + CAM_MAX_CDBLEN; | ||||
} else { | } else { | ||||
num_opcodes = 256; | num_opcodes = 256; | ||||
alloc_len = sizeof(*all_hdr) + (num_opcodes * | alloc_len = sizeof(*all_hdr) + (num_opcodes * | ||||
sizeof(struct scsi_report_supported_opcodes_descr)); | sizeof(struct scsi_report_supported_opcodes_descr)); | ||||
▲ Show 20 Lines • Show All 420 Lines • ▼ Show 20 Lines | reprobe(struct cam_device *device) | ||||
int retval = 0; | int retval = 0; | ||||
ccb = cam_getccb(device); | ccb = cam_getccb(device); | ||||
if (ccb == NULL) { | if (ccb == NULL) { | ||||
warnx("%s: error allocating ccb", __func__); | warnx("%s: error allocating ccb", __func__); | ||||
return (1); | return (1); | ||||
} | } | ||||
CCB_CLEAR_ALL_EXCEPT_HDR(ccb); | |||||
ccb->ccb_h.func_code = XPT_REPROBE_LUN; | ccb->ccb_h.func_code = XPT_REPROBE_LUN; | ||||
if (cam_send_ccb(device, ccb) < 0) { | if (cam_send_ccb(device, ccb) < 0) { | ||||
warn("error sending XPT_REPROBE_LUN CCB"); | warn("error sending XPT_REPROBE_LUN CCB"); | ||||
retval = 1; | retval = 1; | ||||
goto bailout; | goto bailout; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 379 Lines • ▼ Show 20 Lines | main(int argc, char **argv) | ||||
camcontrol_optret optreturn; | camcontrol_optret optreturn; | ||||
char *tstr; | char *tstr; | ||||
const char *mainopt = "C:En:Q:t:u:v"; | const char *mainopt = "C:En:Q:t:u:v"; | ||||
const char *subopt = NULL; | const char *subopt = NULL; | ||||
char combinedopt[256]; | char combinedopt[256]; | ||||
int error = 0, optstart = 2; | int error = 0, optstart = 2; | ||||
int task_attr = MSG_SIMPLE_Q_TAG; | int task_attr = MSG_SIMPLE_Q_TAG; | ||||
int devopen = 1; | int devopen = 1; | ||||
cam_cmd cmdlist; | cam_cmd cmdlist; | ||||
Not Done Inline Actionsditto imp: ditto | |||||
path_id_t bus; | path_id_t bus; | ||||
target_id_t target; | target_id_t target; | ||||
lun_id_t lun; | lun_id_t lun; | ||||
cmdlist = CAM_CMD_NONE; | cmdlist = CAM_CMD_NONE; | ||||
arglist = CAM_ARG_NONE; | arglist = CAM_ARG_NONE; | ||||
if (argc < 2) { | if (argc < 2) { | ||||
▲ Show 20 Lines • Show All 397 Lines • Show Last 20 Lines |
This is a good change, but unrelated.