The vendor_id attribute will allow for the modification of the T10 Vendor Identification string returned in inquiry responses. Its value can be viewed and modified via the ConfigFS path at: target/core/$backstore/$name/wwn/vendor_id "LIO-ORG" remains the default value, which is set when the backstore device is enabled. Signed-off-by: David Disseldorp <ddiss@xxxxxxx> --- drivers/target/target_core_configfs.c | 55 +++++++++++++++++++++++++++++++++++ include/target/target_core_base.h | 3 +- 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c index 860e840..4d1c8a1 100644 --- a/drivers/target/target_core_configfs.c +++ b/drivers/target/target_core_configfs.c @@ -1097,6 +1097,60 @@ do { \ } while (0); /* + * STANDARD and VPD page 0x80 T10 Vendor Identification + */ +static ssize_t target_core_dev_wwn_show_attr_vendor_id( + struct t10_wwn *t10_wwn, + char *page) +{ + return sprintf(page, "T10 Vendor Identification: %" + __stringify(INQUIRY_VENDOR_IDENTIFIER_LEN) "s\n", + &t10_wwn->vendor[0]); +} + +static ssize_t target_core_dev_wwn_store_attr_vendor_id( + struct t10_wwn *t10_wwn, + const char *page, + size_t count) +{ + struct se_device *dev = t10_wwn->t10_dev; + unsigned char buf[INQUIRY_VENDOR_IDENTIFIER_LEN]; + + if (strlen(page) >= INQUIRY_VENDOR_IDENTIFIER_LEN) { + pr_err("Emulated T10 Vendor Identification exceeds" + " INQUIRY_VENDOR_IDENTIFIER_LEN: %d\n", + INQUIRY_VENDOR_IDENTIFIER_LEN); + return -EOVERFLOW; + } + /* + * Check to see if any active $FABRIC_MOD exports exist. If they + * do exist, fail here as changing this information on the fly + * (underneath the initiator side OS dependent multipath code) + * could cause negative effects. + */ + if (dev->export_count) { + pr_err("Unable to set T10 Vendor Identification while" + " active %d $FABRIC_MOD exports exist\n", + dev->export_count); + return -EINVAL; + } + + /* Assume ASCII encoding. Strip any newline added from userspace */ + memset(buf, 0, INQUIRY_VENDOR_IDENTIFIER_LEN); + snprintf(buf, INQUIRY_VENDOR_IDENTIFIER_LEN, "%s", page); + strncpy(dev->t10_wwn.vendor, strstrip(buf), + INQUIRY_VENDOR_IDENTIFIER_LEN); + + pr_debug("Target_Core_ConfigFS: Set emulated T10 Vendor Identification:" + " %" __stringify(INQUIRY_VENDOR_IDENTIFIER_LEN) "s\n", + dev->t10_wwn.vendor); + + return count; +} + +SE_DEV_WWN_ATTR(vendor_id, S_IRUGO | S_IWUSR); + +/* * VPD page 0x80 Unit serial */ static ssize_t target_core_dev_wwn_show_attr_vpd_unit_serial( @@ -1297,6 +1351,7 @@ SE_DEV_WWN_ATTR(vpd_assoc_scsi_target_device, S_IRUGO | S_IWUSR); CONFIGFS_EATTR_OPS(target_core_dev_wwn, t10_wwn, t10_wwn_group); static struct configfs_attribute *target_core_dev_wwn_attrs[] = { + &target_core_dev_wwn_vendor_id.attr, &target_core_dev_wwn_vpd_unit_serial.attr, &target_core_dev_wwn_vpd_protocol_identifier.attr, &target_core_dev_wwn_vpd_assoc_logical_unit.attr, diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index b83a8ec..d980794 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -46,6 +46,7 @@ #define INQUIRY_VPD_SERIAL_LEN 254 /* Used by transport_get_inquiry_vpd_device_ident() */ #define INQUIRY_VPD_DEVICE_IDENTIFIER_LEN 254 +#define INQUIRY_VENDOR_IDENTIFIER_LEN 8 /* Attempts before moving from SHORT to LONG */ #define PYX_TRANSPORT_WINDOW_CLOSED_THRESHOLD 3 @@ -310,7 +311,7 @@ struct t10_vpd { }; struct t10_wwn { - char vendor[8]; + char vendor[INQUIRY_VENDOR_IDENTIFIER_LEN]; char model[16]; char revision[4]; char unit_serial[INQUIRY_VPD_SERIAL_LEN]; -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe target-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html