Author: mav
Date: Wed Dec 21 09:36:23 2016
New Revision: 310360
URL: https://svnweb.freebsd.org/changeset/base/310360

Log:
  Report UUID and MD5 LUN IDs.
  
  MFC after:    2 weeks

Modified:
  head/sys/cam/cam_xpt.c
  head/sys/cam/scsi/scsi_all.c
  head/sys/cam/scsi/scsi_all.h

Modified: head/sys/cam/cam_xpt.c
==============================================================================
--- head/sys/cam/cam_xpt.c      Wed Dec 21 09:22:06 2016        (r310359)
+++ head/sys/cam/cam_xpt.c      Wed Dec 21 09:36:23 2016        (r310360)
@@ -1115,7 +1115,7 @@ xpt_denounce_periph(struct cam_periph *p
 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;
 
@@ -1155,6 +1155,12 @@ xpt_getattr(char *buf, size_t len, const
                        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)
@@ -1181,6 +1187,17 @@ xpt_getattr(char *buf, size_t len, const
                                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++) {
+                                       o += sprintf(buf + o, "%02x",
+                                           idd->identifier[l]);
+                                       if (l == 4 || l == 6 || l == 8 || l == 
10)
+                                           o += sprintf(buf + o, "-");
+                               }
+                       } else
+                               ret = EFAULT;
                } else {
                        if (idd->length * 2 < len) {
                                for (l = 0; l < idd->length; l++)

Modified: head/sys/cam/scsi/scsi_all.c
==============================================================================
--- head/sys/cam/scsi/scsi_all.c        Wed Dec 21 09:22:06 2016        
(r310359)
+++ head/sys/cam/scsi/scsi_all.c        Wed Dec 21 09:36:23 2016        
(r310360)
@@ -5691,6 +5691,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;

Modified: head/sys/cam/scsi/scsi_all.h
==============================================================================
--- head/sys/cam/scsi/scsi_all.h        Wed Dec 21 09:22:06 2016        
(r310359)
+++ head/sys/cam/scsi/scsi_all.h        Wed Dec 21 09:36:23 2016        
(r310360)
@@ -3782,6 +3782,8 @@ int               scsi_devid_is_lun_eui64(uint8_t *bu
 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,
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to