if (hdr->protocol != BSG_PROTOCOL_SCSI ||
hdr->subprotocol != BSG_SUB_PROTOCOL_SCSI_CMD) return -EINVAL; if (hdr->dout_xfer_len && hdr->din_xfer_len) {
pr_warn_once("BIDI support in bsg has been removed.\n"); return -EOPNOTSUPP;
}
scmd = blk_mq_rq_to_pdu(rq);
scmd->cmd_len = hdr->request_len; if (scmd->cmd_len > sizeof(scmd->cmnd)) {
ret = -EINVAL; goto out_put_request;
}
ret = -EFAULT; if (copy_from_user(scmd->cmnd, uptr64(hdr->request), scmd->cmd_len)) goto out_put_request;
ret = -EPERM; if (!scsi_cmd_allowed(scmd->cmnd, open_for_write)) goto out_put_request;
ret = 0; if (hdr->dout_xfer_len) {
ret = blk_rq_map_user(rq->q, rq, NULL, uptr64(hdr->dout_xferp),
hdr->dout_xfer_len, GFP_KERNEL);
} elseif (hdr->din_xfer_len) {
ret = blk_rq_map_user(rq->q, rq, NULL, uptr64(hdr->din_xferp),
hdr->din_xfer_len, GFP_KERNEL);
}
if (ret) goto out_put_request;
bio = rq->bio;
blk_execute_rq(rq, !(hdr->flags & BSG_FLAG_Q_AT_TAIL));
/* * fill in all the output members
*/
hdr->device_status = scmd->result & 0xff;
hdr->transport_status = host_byte(scmd->result);
hdr->driver_status = 0; if (scsi_status_is_check_condition(scmd->result))
hdr->driver_status = DRIVER_SENSE;
hdr->info = 0; if (hdr->device_status || hdr->transport_status || hdr->driver_status)
hdr->info |= SG_INFO_CHECK;
hdr->response_len = 0;
if (scmd->sense_len && hdr->response) { int len = min_t(unsignedint, hdr->max_response_len,
scmd->sense_len);
if (copy_to_user(uptr64(hdr->response), scmd->sense_buffer,
len))
ret = -EFAULT; else
hdr->response_len = len;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.