diff options
author | mav <mav@FreeBSD.org> | 2017-01-05 11:41:53 +0000 |
---|---|---|
committer | mav <mav@FreeBSD.org> | 2017-01-05 11:41:53 +0000 |
commit | f7b2da91f9d4f9a61389c7674a16fd18249b913e (patch) | |
tree | 0bb5ff61b9c160b889933cd72e60c410aa9c95e1 /sys | |
parent | f2970b71b52488e4cc93b04caa4a90cdfbc2a73e (diff) | |
download | FreeBSD-src-f7b2da91f9d4f9a61389c7674a16fd18249b913e.zip FreeBSD-src-f7b2da91f9d4f9a61389c7674a16fd18249b913e.tar.gz |
MFC r310356: Add support for locally assigned RFC 4122 UUID LUN identifiers.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/cam/ctl/ctl.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c index 2e7341c..9cb5199 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -4362,6 +4362,8 @@ hex2bin(const char *str, uint8_t *buf, int buf_size) str += 2; buf_size *= 2; for (i = 0; str[i] != 0 && i < buf_size; i++) { + while (str[i] == '-') /* Skip dashes in UUIDs. */ + str++; c = str[i]; if (isdigit(c)) c -= '0'; @@ -4397,7 +4399,7 @@ ctl_alloc_lun(struct ctl_softc *ctl_softc, struct ctl_lun *ctl_lun, struct ctl_lun *nlun, *lun; struct scsi_vpd_id_descriptor *desc; struct scsi_vpd_id_t10 *t10id; - const char *eui, *naa, *scsiname, *vendor, *value; + const char *eui, *naa, *scsiname, *uuid, *vendor, *value; int lun_number, i, lun_malloced; int devidlen, idlen1, idlen2 = 0, len; @@ -4449,6 +4451,10 @@ ctl_alloc_lun(struct ctl_softc *ctl_softc, struct ctl_lun *ctl_lun, if (naa != NULL) { len += sizeof(struct scsi_vpd_id_descriptor) + 16; } + uuid = ctl_get_opt(&be_lun->options, "uuid"); + if (uuid != NULL) { + len += sizeof(struct scsi_vpd_id_descriptor) + 18; + } lun->lun_devid = malloc(sizeof(struct ctl_devid) + len, M_CTL, M_WAITOK | M_ZERO); desc = (struct scsi_vpd_id_descriptor *)lun->lun_devid->data; @@ -4495,6 +4501,16 @@ ctl_alloc_lun(struct ctl_softc *ctl_softc, struct ctl_lun *ctl_lun, desc->length = desc->length > 8 ? 16 : 8; len -= 16 - desc->length; } + if (uuid != NULL) { + desc = (struct scsi_vpd_id_descriptor *)(&desc->identifier[0] + + desc->length); + desc->proto_codeset = SVPD_ID_CODESET_BINARY; + desc->id_type = SVPD_ID_PIV | SVPD_ID_ASSOC_LUN | + SVPD_ID_TYPE_UUID; + desc->identifier[0] = 0x10; + hex2bin(uuid, &desc->identifier[2], 16); + desc->length = 18; + } lun->lun_devid->len = len; mtx_lock(&ctl_softc->ctl_lock); |