svn commit: r268145 - stable/10/sys/cam/ctl
Alexander Motin
mav at FreeBSD.org
Wed Jul 2 10:37:23 UTC 2014
Author: mav
Date: Wed Jul 2 10:37:22 2014
New Revision: 268145
URL: http://svnweb.freebsd.org/changeset/base/268145
Log:
MFC r267496, r267498:
Add "vendor", "product" and "revision" options to control inquiry data.
Modified:
stable/10/sys/cam/ctl/ctl.c
stable/10/sys/cam/ctl/ctl_frontend_iscsi.c
Directory Properties:
stable/10/ (props changed)
Modified: stable/10/sys/cam/ctl/ctl.c
==============================================================================
--- stable/10/sys/cam/ctl/ctl.c Wed Jul 2 10:36:04 2014 (r268144)
+++ stable/10/sys/cam/ctl/ctl.c Wed Jul 2 10:37:22 2014 (r268145)
@@ -9303,6 +9303,7 @@ ctl_inquiry_evpd_devid(struct ctl_scsiio
struct ctl_softc *ctl_softc;
struct ctl_lun *lun;
struct ctl_frontend *fe;
+ char *val;
#ifndef CTL_USE_BACKEND_SN
char tmpstr[32];
#endif /* CTL_USE_BACKEND_SN */
@@ -9396,7 +9397,13 @@ ctl_inquiry_evpd_devid(struct ctl_scsiio
*/
desc->id_type = SVPD_ID_PIV | SVPD_ID_ASSOC_LUN | SVPD_ID_TYPE_T10;
desc->length = sizeof(*t10id) + CTL_DEVID_LEN;
- strncpy((char *)t10id->vendor, CTL_VENDOR, sizeof(t10id->vendor));
+ if (lun == NULL || (val = ctl_get_opt(lun->be_lun, "vendor")) == NULL) {
+ strncpy((char *)t10id->vendor, CTL_VENDOR, sizeof(t10id->vendor));
+ } else {
+ memset(t10id->vendor, ' ', sizeof(t10id->vendor));
+ strncpy(t10id->vendor, val,
+ min(sizeof(t10id->vendor), strlen(val)));
+ }
/*
* desc1 is for the WWPN which is a port asscociation.
@@ -9634,6 +9641,7 @@ ctl_inquiry_std(struct ctl_scsiio *ctsio
struct scsi_inquiry *cdb;
struct ctl_softc *ctl_softc;
struct ctl_lun *lun;
+ char *val;
uint32_t alloc_len;
int is_fc;
@@ -9778,10 +9786,16 @@ ctl_inquiry_std(struct ctl_scsiio *ctsio
* We have 8 bytes for the vendor name, and 16 bytes for the device
* name and 4 bytes for the revision.
*/
- strncpy(inq_ptr->vendor, CTL_VENDOR, sizeof(inq_ptr->vendor));
+ if (lun == NULL || (val = ctl_get_opt(lun->be_lun, "vendor")) == NULL) {
+ strcpy(inq_ptr->vendor, CTL_VENDOR);
+ } else {
+ memset(inq_ptr->vendor, ' ', sizeof(inq_ptr->vendor));
+ strncpy(inq_ptr->vendor, val,
+ min(sizeof(inq_ptr->vendor), strlen(val)));
+ }
if (lun == NULL) {
strcpy(inq_ptr->product, CTL_DIRECT_PRODUCT);
- } else {
+ } else if ((val = ctl_get_opt(lun->be_lun, "product")) == NULL) {
switch (lun->be_lun->lun_type) {
case T_DIRECT:
strcpy(inq_ptr->product, CTL_DIRECT_PRODUCT);
@@ -9793,13 +9807,23 @@ ctl_inquiry_std(struct ctl_scsiio *ctsio
strcpy(inq_ptr->product, CTL_UNKNOWN_PRODUCT);
break;
}
+ } else {
+ memset(inq_ptr->product, ' ', sizeof(inq_ptr->product));
+ strncpy(inq_ptr->product, val,
+ min(sizeof(inq_ptr->product), strlen(val)));
}
/*
* XXX make this a macro somewhere so it automatically gets
* incremented when we make changes.
*/
- strncpy(inq_ptr->revision, "0001", sizeof(inq_ptr->revision));
+ if (lun == NULL || (val = ctl_get_opt(lun->be_lun, "revision")) == NULL) {
+ strncpy(inq_ptr->revision, "0001", sizeof(inq_ptr->revision));
+ } else {
+ memset(inq_ptr->revision, ' ', sizeof(inq_ptr->revision));
+ strncpy(inq_ptr->revision, val,
+ min(sizeof(inq_ptr->revision), strlen(val)));
+ }
/*
* For parallel SCSI, we support double transition and single
Modified: stable/10/sys/cam/ctl/ctl_frontend_iscsi.c
==============================================================================
--- stable/10/sys/cam/ctl/ctl_frontend_iscsi.c Wed Jul 2 10:36:04 2014 (r268144)
+++ stable/10/sys/cam/ctl/ctl_frontend_iscsi.c Wed Jul 2 10:37:22 2014 (r268145)
@@ -2037,6 +2037,7 @@ cfiscsi_devid(struct ctl_scsiio *ctsio,
struct scsi_vpd_id_t10 *t10id;
struct ctl_lun *lun;
const struct icl_pdu *request;
+ char *val;
size_t devid_len, wwpn_len;
lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
@@ -2101,7 +2102,13 @@ cfiscsi_devid(struct ctl_scsiio *ctsio,
desc->proto_codeset = (SCSI_PROTO_ISCSI << 4) | SVPD_ID_CODESET_ASCII;
desc->id_type = SVPD_ID_PIV | SVPD_ID_ASSOC_LUN | SVPD_ID_TYPE_T10;
desc->length = sizeof(*t10id) + CTL_DEVID_LEN;
- strncpy((char *)t10id->vendor, CTL_VENDOR, sizeof(t10id->vendor));
+ if (lun == NULL || (val = ctl_get_opt(lun->be_lun, "vendor")) == NULL) {
+ strncpy((char *)t10id->vendor, CTL_VENDOR, sizeof(t10id->vendor));
+ } else {
+ memset(t10id->vendor, ' ', sizeof(t10id->vendor));
+ strncpy(t10id->vendor, val,
+ min(sizeof(t10id->vendor), strlen(val)));
+ }
/*
* If we've actually got a backend, copy the device id from the
More information about the svn-src-stable
mailing list