summaryrefslogtreecommitdiffstats
path: root/sys/cam
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2017-01-05 11:43:47 +0000
committermav <mav@FreeBSD.org>2017-01-05 11:43:47 +0000
commit25ed58e17f528f9408bef469ea813292be541b72 (patch)
treeef4a7e138ade21a1aa27a1d6068ccf76e383c610 /sys/cam
parentf7b2da91f9d4f9a61389c7674a16fd18249b913e (diff)
downloadFreeBSD-src-25ed58e17f528f9408bef469ea813292be541b72.zip
FreeBSD-src-25ed58e17f528f9408bef469ea813292be541b72.tar.gz
MFC r310360, r310361: Report UUID and MD5 LUN IDs.
Diffstat (limited to 'sys/cam')
-rw-r--r--sys/cam/cam_xpt.c19
-rw-r--r--sys/cam/scsi/scsi_all.c26
-rw-r--r--sys/cam/scsi/scsi_all.h2
3 files changed, 46 insertions, 1 deletions
diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c
index 184d43e..3cf307a 100644
--- a/sys/cam/cam_xpt.c
+++ b/sys/cam/cam_xpt.c
@@ -1096,7 +1096,7 @@ xpt_denounce_periph(struct cam_periph *periph)
int
xpt_getattr(char *buf, size_t len, const char *attr, struct cam_path *path)
{
- int ret = -1, l;
+ int ret = -1, l, o;
struct ccb_dev_advinfo cdai;
struct scsi_vpd_id_descriptor *idd;
@@ -1136,6 +1136,12 @@ xpt_getattr(char *buf, size_t len, const char *attr, struct cam_path *path)
if (idd == NULL)
idd = scsi_get_devid((struct scsi_vpd_device_id *)cdai.buf,
cdai.provsiz, scsi_devid_is_lun_eui64);
+ if (idd == NULL)
+ idd = scsi_get_devid((struct scsi_vpd_device_id *)cdai.buf,
+ cdai.provsiz, scsi_devid_is_lun_uuid);
+ if (idd == NULL)
+ idd = scsi_get_devid((struct scsi_vpd_device_id *)cdai.buf,
+ cdai.provsiz, scsi_devid_is_lun_md5);
} else
idd = NULL;
if (idd == NULL)
@@ -1162,6 +1168,17 @@ xpt_getattr(char *buf, size_t len, const char *attr, struct cam_path *path)
buf[l] = 0;
} else
ret = EFAULT;
+ } else if ((idd->id_type & SVPD_ID_TYPE_MASK) == SVPD_ID_TYPE_UUID
+ && idd->identifier[0] == 0x10) {
+ if ((idd->length - 2) * 2 + 4 < len) {
+ for (l = 2, o = 0; l < idd->length; l++) {
+ if (l == 6 || l == 8 || l == 10 || l == 12)
+ o += sprintf(buf + o, "-");
+ o += sprintf(buf + o, "%02x",
+ idd->identifier[l]);
+ }
+ } else
+ ret = EFAULT;
} else {
if (idd->length * 2 < len) {
for (l = 0; l < idd->length; l++)
diff --git a/sys/cam/scsi/scsi_all.c b/sys/cam/scsi/scsi_all.c
index 3d5c323..c0059d7 100644
--- a/sys/cam/scsi/scsi_all.c
+++ b/sys/cam/scsi/scsi_all.c
@@ -5639,6 +5639,32 @@ scsi_devid_is_lun_name(uint8_t *bufp)
}
int
+scsi_devid_is_lun_md5(uint8_t *bufp)
+{
+ struct scsi_vpd_id_descriptor *descr;
+
+ descr = (struct scsi_vpd_id_descriptor *)bufp;
+ if ((descr->id_type & SVPD_ID_ASSOC_MASK) != SVPD_ID_ASSOC_LUN)
+ return 0;
+ if ((descr->id_type & SVPD_ID_TYPE_MASK) != SVPD_ID_TYPE_MD5_LUN_ID)
+ return 0;
+ return 1;
+}
+
+int
+scsi_devid_is_lun_uuid(uint8_t *bufp)
+{
+ struct scsi_vpd_id_descriptor *descr;
+
+ descr = (struct scsi_vpd_id_descriptor *)bufp;
+ if ((descr->id_type & SVPD_ID_ASSOC_MASK) != SVPD_ID_ASSOC_LUN)
+ return 0;
+ if ((descr->id_type & SVPD_ID_TYPE_MASK) != SVPD_ID_TYPE_UUID)
+ return 0;
+ return 1;
+}
+
+int
scsi_devid_is_port_naa(uint8_t *bufp)
{
struct scsi_vpd_id_descriptor *descr;
diff --git a/sys/cam/scsi/scsi_all.h b/sys/cam/scsi/scsi_all.h
index bddf3c6..af7b65b 100644
--- a/sys/cam/scsi/scsi_all.h
+++ b/sys/cam/scsi/scsi_all.h
@@ -3672,6 +3672,8 @@ int scsi_devid_is_lun_eui64(uint8_t *bufp);
int scsi_devid_is_lun_naa(uint8_t *bufp);
int scsi_devid_is_lun_name(uint8_t *bufp);
int scsi_devid_is_lun_t10(uint8_t *bufp);
+int scsi_devid_is_lun_md5(uint8_t *bufp);
+int scsi_devid_is_lun_uuid(uint8_t *bufp);
int scsi_devid_is_port_naa(uint8_t *bufp);
struct scsi_vpd_id_descriptor *
scsi_get_devid(struct scsi_vpd_device_id *id, uint32_t len,
OpenPOWER on IntegriCloud