/* Yields most of first 36 bytes of a standard INQUIRY (evpd==0) response. * Returns 0 when successful, various SG_LIB_CAT_* positive values or * -1 -> other errors */ int sg_simple_inquiry(int sg_fd, struct sg_simple_inquiry_resp * inq_data, bool noisy, int verbose) { int ret; unsigned char inq_resp[SAFE_STD_INQ_RESP_LEN]; if (inq_data) { memset(inq_data, 0, sizeof(* inq_data)); inq_data->peripheral_qualifier = 0x3; inq_data->peripheral_type = 0x1f; } ret = sg_ll_inquiry_com(sg_fd, false, false, 0, inq_resp, sizeof(inq_resp), 0, NULL, noisy, verbose); if (inq_data && (0 == ret)) { inq_data->peripheral_qualifier = (inq_resp[0] >> 5) & 0x7; inq_data->peripheral_type = inq_resp[0] & 0x1f; inq_data->byte_1 = inq_resp[1]; inq_data->version = inq_resp[2]; inq_data->byte_3 = inq_resp[3]; inq_data->byte_5 = inq_resp[5]; inq_data->byte_6 = inq_resp[6]; inq_data->byte_7 = inq_resp[7]; memcpy(inq_data->vendor, inq_resp + 8, 8); memcpy(inq_data->product, inq_resp + 16, 16); memcpy(inq_data->revision, inq_resp + 32, 4); }
/* Invokes a SCSI INQUIRY command and yields the response. Returns 0 when * successful, various SG_LIB_CAT_* positive values or -1 -> other errors. * The CMDDT field is obsolete in the INQUIRY cdb. */ int sg_ll_inquiry(int sg_fd, bool cmddt, bool evpd, int pg_op, void * resp, int mx_resp_len, bool noisy, int verbose) { return sg_ll_inquiry_com(sg_fd, cmddt, evpd, pg_op, resp, mx_resp_len, 0 /* timeout_sec */, NULL, noisy, verbose); }
/* Similar to _v2 but takes a pointer to an object (derived from) sg_pt_base. * That object is assumed to be constructed and have a device file descriptor * associated with it. Caller is responsible for lifetime of ptp. */ int sg_ll_inquiry_pt(struct sg_pt_base * ptvp, bool evpd, int pg_op, void * resp, int mx_resp_len, int timeout_secs, int * residp, bool noisy, int verbose) { clear_scsi_pt_obj(ptvp); return sg_ll_inquiry_com(ptvp, false, evpd, pg_op, resp, mx_resp_len, timeout_secs, residp, noisy, verbose); }
/* Invokes a SCSI INQUIRY command and yields the response. Returns 0 when * successful, various SG_LIB_CAT_* positive values, negated errno or * -1 -> other errors. The CMDDT field is obsolete in the INQUIRY cdb. */ int sg_ll_inquiry(int sg_fd, bool cmddt, bool evpd, int pg_op, void * resp, int mx_resp_len, bool noisy, int verbose) { int ret; struct sg_pt_base * ptvp; ptvp = construct_scsi_pt_obj_with_fd(sg_fd, verbose); if (NULL == ptvp) return sg_convert_errno(ENOMEM); ret = sg_ll_inquiry_com(ptvp, cmddt, evpd, pg_op, resp, mx_resp_len, 0 /* timeout_sec */, NULL, noisy, verbose); destruct_scsi_pt_obj(ptvp); return ret; }
/* Invokes a SCSI INQUIRY command and yields the response. Returns 0 when * successful, various SG_LIB_CAT_* positive values or -1 -> other errors. * The CMDDT field is obsolete in the INQUIRY cdb (since spc3r16 in 2003) so * an argument to set it has been removed (use the REPORT SUPPORTED OPERATION * CODES command instead). Adds the ability to set the command abort timeout * and the ability to report the residual count. If timeout_secs is zero * or less the default command abort timeout (60 seconds) is used. * If residp is non-NULL then the residual value is written where residp * points. A residual value of 0 implies mx_resp_len bytes have be written * where resp points. If the residual value equals mx_resp_len then no * bytes have been written. */ int sg_ll_inquiry_v2(int sg_fd, bool evpd, int pg_op, void * resp, int mx_resp_len, int timeout_secs, int * residp, bool noisy, int verbose) { int ret; struct sg_pt_base * ptvp; ptvp = construct_scsi_pt_obj_with_fd(sg_fd, verbose); if (NULL == ptvp) return sg_convert_errno(ENOMEM); ret = sg_ll_inquiry_com(ptvp, false, evpd, pg_op, resp, mx_resp_len, timeout_secs, residp, noisy, verbose); destruct_scsi_pt_obj(ptvp); return ret; }