Date: Tue, 31 Mar 2015 07:26:40 +0000 (UTC) From: Alexander Motin <mav@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r280898 - in stable/10/sys/cam: ata scsi Message-ID: <201503310726.t2V7QeCN021254@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mav Date: Tue Mar 31 07:26:39 2015 New Revision: 280898 URL: https://svnweb.freebsd.org/changeset/base/280898 Log: MFC r280172: Improve ATA and SCSI versions printing. There is no "SCSI-6" and "ATA-9", but there is "SPC-4" and "ACS-2". Modified: stable/10/sys/cam/ata/ata_all.c stable/10/sys/cam/scsi/scsi_all.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/ata/ata_all.c ============================================================================== --- stable/10/sys/cam/ata/ata_all.c Tue Mar 31 07:22:53 2015 (r280897) +++ stable/10/sys/cam/ata/ata_all.c Tue Mar 31 07:26:39 2015 (r280898) @@ -275,28 +275,38 @@ ata_res_sbuf(struct ccb_ataio *ataio, st void ata_print_ident(struct ata_params *ident_data) { - char product[48], revision[16]; + const char *proto; + char product[48], revision[16], ata[12], sata[12]; cam_strvis(product, ident_data->model, sizeof(ident_data->model), sizeof(product)); cam_strvis(revision, ident_data->revision, sizeof(ident_data->revision), sizeof(revision)); - printf("<%s %s> %s-%d", - product, revision, - (ident_data->config == ATA_PROTO_CFA) ? "CFA" : - (ident_data->config & ATA_PROTO_ATAPI) ? "ATAPI" : "ATA", - ata_version(ident_data->version_major)); + proto = (ident_data->config == ATA_PROTO_CFA) ? "CFA" : + (ident_data->config & ATA_PROTO_ATAPI) ? "ATAPI" : "ATA"; + if (ata_version(ident_data->version_major) == 0) { + snprintf(ata, sizeof(ata), "%s", proto); + } else if (ata_version(ident_data->version_major) <= 7) { + snprintf(ata, sizeof(ata), "%s-%d", proto, + ata_version(ident_data->version_major)); + } else if (ata_version(ident_data->version_major) == 8) { + snprintf(ata, sizeof(ata), "%s8-ACS", proto); + } else { + snprintf(ata, sizeof(ata), "ACS-%d %s", + ata_version(ident_data->version_major) - 7, proto); + } if (ident_data->satacapabilities && ident_data->satacapabilities != 0xffff) { if (ident_data->satacapabilities & ATA_SATA_GEN3) - printf(" SATA 3.x"); + snprintf(sata, sizeof(sata), " SATA 3.x"); else if (ident_data->satacapabilities & ATA_SATA_GEN2) - printf(" SATA 2.x"); + snprintf(sata, sizeof(sata), " SATA 2.x"); else if (ident_data->satacapabilities & ATA_SATA_GEN1) - printf(" SATA 1.x"); + snprintf(sata, sizeof(sata), " SATA 1.x"); else - printf(" SATA"); - } - printf(" device\n"); + snprintf(sata, sizeof(sata), " SATA"); + } else + sata[0] = 0; + printf("<%s %s> %s%s device\n", product, revision, ata, sata); } void Modified: stable/10/sys/cam/scsi/scsi_all.c ============================================================================== --- stable/10/sys/cam/scsi/scsi_all.c Tue Mar 31 07:22:53 2015 (r280897) +++ stable/10/sys/cam/scsi/scsi_all.c Tue Mar 31 07:26:39 2015 (r280898) @@ -5149,7 +5149,7 @@ scsi_print_inquiry(struct scsi_inquiry_d { u_int8_t type; char *dtype, *qtype; - char vendor[16], product[48], revision[16], rstr[4]; + char vendor[16], product[48], revision[16], rstr[12]; type = SID_TYPE(inq_data); @@ -5157,7 +5157,7 @@ scsi_print_inquiry(struct scsi_inquiry_d * Figure out basic device type and qualifier. */ if (SID_QUAL_IS_VENDOR_UNIQUE(inq_data)) { - qtype = "(vendor-unique qualifier)"; + qtype = " (vendor-unique qualifier)"; } else { switch (SID_QUAL(inq_data)) { case SID_QUAL_LU_CONNECTED: @@ -5165,15 +5165,15 @@ scsi_print_inquiry(struct scsi_inquiry_d break; case SID_QUAL_LU_OFFLINE: - qtype = "(offline)"; + qtype = " (offline)"; break; case SID_QUAL_RSVD: - qtype = "(reserved qualifier)"; + qtype = " (reserved qualifier)"; break; default: case SID_QUAL_BAD_LU: - qtype = "(LUN not supported)"; + qtype = " (LUN not supported)"; break; } } @@ -5242,11 +5242,16 @@ scsi_print_inquiry(struct scsi_inquiry_d cam_strvis(revision, inq_data->revision, sizeof(inq_data->revision), sizeof(revision)); - if (SID_ANSI_REV(inq_data) == SCSI_REV_CCS) - bcopy("CCS", rstr, 4); - else - snprintf(rstr, sizeof (rstr), "%d", SID_ANSI_REV(inq_data)); - printf("<%s %s %s> %s %s SCSI-%s device %s\n", + if (SID_ANSI_REV(inq_data) == SCSI_REV_0) + snprintf(rstr, sizeof(rstr), "SCSI"); + else if (SID_ANSI_REV(inq_data) <= SCSI_REV_SPC) { + snprintf(rstr, sizeof(rstr), "SCSI-%d", + SID_ANSI_REV(inq_data)); + } else { + snprintf(rstr, sizeof(rstr), "SPC-%d SCSI", + SID_ANSI_REV(inq_data) - 2); + } + printf("<%s %s %s> %s %s %s device%s\n", vendor, product, revision, SID_IS_REMOVABLE(inq_data) ? "Removable" : "Fixed", dtype, rstr, qtype);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201503310726.t2V7QeCN021254>