+ memset(inqBuf, 0, 96);
+ req_len = 36;
+ if ((err = scsiStdInquiry(scsidev, inqBuf, req_len))) {
+ /* Marvell controllers fail on a 36 bytes StdInquiry, but 64 suffices */
+ req_len = 64;
+ if ((err = scsiStdInquiry(scsidev, inqBuf, req_len))) {
+ PrintOut(LOG_INFO, "Device: %s, Both 36 and 64 byte INQUIRY failed; "
+ "skip device\n", device);
+ return 2;
+ }
+ }
+ version = (inqBuf[2] & 0x7f); /* Accept old ISO/IEC 9316:1995 variants */
+
+ avail_len = inqBuf[4] + 5;
+ len = (avail_len < req_len) ? avail_len : req_len;
+ if (len < 36) {
+ PrintOut(LOG_INFO, "Device: %s, INQUIRY response less than 36 bytes; "
+ "skip device\n", device);
+ return 2;
+ }
+
+ int pdt = inqBuf[0] & 0x1f;
+
+ if (! ((0 == pdt) || (4 == pdt) || (5 == pdt) || (7 == pdt) ||
+ (0xe == pdt))) {
+ PrintOut(LOG_INFO, "Device: %s, not a disk like device [PDT=0x%x], "
+ "skip\n", device, pdt);
+ return 2;
+ }
+
+ if (supported_vpd_pages_p) {
+ delete supported_vpd_pages_p;
+ supported_vpd_pages_p = NULL;
+ }
+ supported_vpd_pages_p = new supported_vpd_pages(scsidev);
+
+ lu_id[0] = '\0';
+ if ((version >= 0x3) && (version < 0x8)) {
+ /* SPC to SPC-5 */
+ if (0 == scsiInquiryVpd(scsidev, SCSI_VPD_DEVICE_IDENTIFICATION,
+ vpdBuf, sizeof(vpdBuf))) {
+ len = vpdBuf[3];
+ scsi_decode_lu_dev_id(vpdBuf + 4, len, lu_id, sizeof(lu_id), NULL);
+ }
+ }
+ serial[0] = '\0';
+ if (0 == scsiInquiryVpd(scsidev, SCSI_VPD_UNIT_SERIAL_NUMBER,
+ vpdBuf, sizeof(vpdBuf))) {
+ len = vpdBuf[3];
+ vpdBuf[4 + len] = '\0';
+ scsi_format_id_string(serial, (const unsigned char *)&vpdBuf[4], len);
+ }
+
+ unsigned int lb_size;
+ char si_str[64];
+ uint64_t capacity = scsiGetSize(scsidev, &lb_size, NULL);
+
+ if (capacity)
+ format_capacity(si_str, sizeof(si_str), capacity);
+ else
+ si_str[0] = '\0';
+
+ // Format device id string for warning emails
+ cfg.dev_idinfo = strprintf("[%.8s %.16s %.4s]%s%s%s%s%s%s",
+ (char *)&inqBuf[8], (char *)&inqBuf[16], (char *)&inqBuf[32],
+ (lu_id[0] ? ", lu id: " : ""), (lu_id[0] ? lu_id : ""),
+ (serial[0] ? ", S/N: " : ""), (serial[0] ? serial : ""),
+ (si_str[0] ? ", " : ""), (si_str[0] ? si_str : ""));
+
+ // format "model" string
+ scsi_format_id_string(vendor, (const unsigned char *)&inqBuf[8], 8);
+ scsi_format_id_string(model, (const unsigned char *)&inqBuf[16], 16);
+ PrintOut(LOG_INFO, "Device: %s, %s\n", device, cfg.dev_idinfo.c_str());