--- src/sys/bus/cam/scsi/scsi_all.c 2007/11/24 03:09:57 1.18 +++ src/sys/bus/cam/scsi/scsi_all.c 2007/11/24 03:48:31 1.19 @@ -2584,6 +2584,34 @@ scsi_read_capacity_16(struct ccb_scsiio reladr |= SRC16_RELADR; } +/* + * Prevent or allow the user to remove the media + */ +void +scsi_prevent(struct ccb_scsiio *csio, u_int32_t retries, + void (*cbfcnp)(struct cam_periph *, union ccb *), + u_int8_t tag_action, u_int8_t action, + u_int8_t sense_len, u_int32_t timeout) +{ + struct scsi_prevent *scsi_cmd; + + cam_fill_csio(csio, + retries, + cbfcnp, + /*flags*/CAM_DIR_NONE, + tag_action, + /*data_ptr*/NULL, + /*dxfer_len*/0, + sense_len, + sizeof(*scsi_cmd), + timeout); + + scsi_cmd = (struct scsi_prevent *)&csio->cdb_io.cdb_bytes; + bzero(scsi_cmd, sizeof(*scsi_cmd)); + scsi_cmd->opcode = PREVENT_ALLOW; + scsi_cmd->how = action; +} + /* XXX allow specification of address and PMI bit and LBA */ void scsi_read_capacity(struct ccb_scsiio *csio, u_int32_t retries, @@ -2610,32 +2638,28 @@ scsi_read_capacity(struct ccb_scsiio *cs scsi_cmd->opcode = READ_CAPACITY; } -/* - * Prevent or allow the user to remove the media - */ void -scsi_prevent(struct ccb_scsiio *csio, u_int32_t retries, - void (*cbfcnp)(struct cam_periph *, union ccb *), - u_int8_t tag_action, u_int8_t action, - u_int8_t sense_len, u_int32_t timeout) +scsi_report_luns(struct ccb_scsiio *csio, u_int32_t retries, + void (*cbfcnp)(struct cam_periph *, union ccb *), + u_int8_t tag_action, struct scsi_report_luns_data *rpl_buf, + u_int32_t alloc_len, u_int8_t sense_len, u_int32_t timeout) { - struct scsi_prevent *scsi_cmd; + struct scsi_report_luns *scsi_cmd; cam_fill_csio(csio, retries, cbfcnp, - /*flags*/CAM_DIR_NONE, + /*flags*/CAM_DIR_IN, tag_action, - /*data_ptr*/NULL, - /*dxfer_len*/0, + /*data_ptr*/(u_int8_t *)rpl_buf, + /*dxfer_len*/alloc_len, sense_len, sizeof(*scsi_cmd), timeout); - - scsi_cmd = (struct scsi_prevent *)&csio->cdb_io.cdb_bytes; + scsi_cmd = (struct scsi_report_luns *)&csio->cdb_io.cdb_bytes; bzero(scsi_cmd, sizeof(*scsi_cmd)); - scsi_cmd->opcode = PREVENT_ALLOW; - scsi_cmd->how = action; + scsi_cmd->opcode = REPORT_LUNS; + scsi_ulto4b(alloc_len, scsi_cmd->addr); } /*