From f9d39eee22afac7acb999713d37c693d3a30d485 Mon Sep 17 00:00:00 2001 From: Martin Wilck Date: Wed, 22 Nov 2017 19:25:04 +0100 Subject: [PATCH 1/8] 55-scsi-sg3_id.rules: fix SCSI_IDENT_LUN_NAA_EXT case Reviewed-by: Hannes Reinecke --- scripts/55-scsi-sg3_id.rules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/55-scsi-sg3_id.rules b/scripts/55-scsi-sg3_id.rules index 4975bc53..d648cb82 100644 --- a/scripts/55-scsi-sg3_id.rules +++ b/scripts/55-scsi-sg3_id.rules @@ -45,7 +45,7 @@ ENV{ID_SERIAL_SHORT}!="?*", ENV{SCSI_VENDOR}=="ATA", ENV{SCSI_IDENT_LUN_VENDOR}= # Compat ID_SERIAL setting ENV{ID_SERIAL}!="?*", ENV{SCSI_IDENT_LUN_NAA_REGEXT}=="?*", ENV{ID_BUS}="scsi", ENV{ID_SERIAL}="3$env{SCSI_IDENT_LUN_NAA_REGEXT}", ENV{ID_SERIAL_SHORT}="$env{SCSI_IDENT_LUN_NAA_REGEXT}" ENV{ID_SERIAL}!="?*", ENV{SCSI_IDENT_LUN_NAA_REG}=="?*", ENV{ID_BUS}="scsi", ENV{ID_SERIAL}="3$env{SCSI_IDENT_LUN_NAA_REG}", ENV{ID_SERIAL_SHORT}="$env{SCSI_IDENT_LUN_NAA_REG}" -ENV{ID_SERIAL}!="?*", ENV{SCSI_IDENT_LUN_NAA_EXT}=="?*", ENV{ID_BUS}="scsi", ENV{ID_SERIAL}="3$env{SCSI_IDENT_LUN_NAA}", ENV{ID_SERIAL_SHORT}="$env{SCSI_IDENT_LUN_NAA_EXT}" +ENV{ID_SERIAL}!="?*", ENV{SCSI_IDENT_LUN_NAA_EXT}=="?*", ENV{ID_BUS}="scsi", ENV{ID_SERIAL}="3$env{SCSI_IDENT_LUN_NAA_EXT}", ENV{ID_SERIAL_SHORT}="$env{SCSI_IDENT_LUN_NAA_EXT}" ENV{ID_SERIAL}!="?*", ENV{SCSI_IDENT_LUN_EUI64}=="?*", ENV{ID_BUS}="scsi", ENV{ID_SERIAL}="2$env{SCSI_IDENT_LUN_EUI64}", ENV{ID_SERIAL_SHORT}="$env{SCSI_IDENT_LUN_EUI64}" ENV{ID_SERIAL}!="?*", ENV{SCSI_IDENT_LUN_NAME}=="?*", ENV{ID_BUS}="scsi", ENV{ID_SERIAL}="8$env{SCSI_IDENT_LUN_NAME}", ENV{ID_SERIAL_SHORT}="$env{SCSI_IDENT_LUN_NAME}" ENV{ID_SERIAL}!="?*", ENV{SCSI_IDENT_LUN_T10}=="?*", ENV{ID_BUS}="scsi", ENV{ID_SERIAL}="1$env{SCSI_IDENT_LUN_T10}", ENV{ID_SERIAL_SHORT}="$env{SCSI_IDENT_LUN_T10}" From 5d943a0d4d3058bc68f4889ec471f8a28e0ee466 Mon Sep 17 00:00:00 2001 From: Martin Wilck Date: Thu, 25 Jan 2018 21:05:51 +0100 Subject: [PATCH 2/8] 55-scsi-sg3_id.rules: ID_WWN has max 16 characters Restore compatibility with scsi_id by truncating ID_WWN to 16 chars. ID_WWN_WITH_EXTENSION is what actually matters for SCSI, but we should get this right nevertheless. --- scripts/55-scsi-sg3_id.rules | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/55-scsi-sg3_id.rules b/scripts/55-scsi-sg3_id.rules index d648cb82..d7177651 100644 --- a/scripts/55-scsi-sg3_id.rules +++ b/scripts/55-scsi-sg3_id.rules @@ -31,13 +31,14 @@ KERNEL=="sd*[!0-9]", ENV{ID_SCSI}=="1", ENV{ID_SCSI_INQUIRY}=="1", IMPORT{progra KERNEL=="sd*[!0-9]|sr*", ENV{ID_SCSI}=="1", ENV{ID_SCSI_INQUIRY}!="1", IMPORT{program}="/usr/bin/sg_inq --export --page=di $tempnode" # ID_WWN compat mapping -ENV{SCSI_IDENT_LUN_NAA_REGEXT}=="?*", ENV{ID_WWN}!="?*", ENV{ID_WWN}="0x$env{SCSI_IDENT_LUN_NAA_REGEXT}" -ENV{SCSI_IDENT_LUN_NAA_REG}=="?*", ENV{ID_WWN}!="?*", ENV{ID_WWN}="0x$env{SCSI_IDENT_LUN_NAA_REG}" -ENV{SCSI_IDENT_LUN_NAA_EXT}=="?*", ENV{ID_WWN}!="?*", ENV{ID_WWN}="0x$env{SCSI_IDENT_LUN_NAA_EXT}" -ENV{SCSI_IDENT_LUN_NAA_LOCAL}=="?*", ENV{ID_WWN}!="?*", ENV{ID_WWN}="0x$env{SCSI_IDENT_LUN_NAA_LOCAL}" ENV{SCSI_IDENT_LUN_NAA_REGEXT}=="?*", ENV{ID_WWN_WITH_EXTENSION}!="?*", ENV{ID_WWN_WITH_EXTENSION}="0x$env{SCSI_IDENT_LUN_NAA_REGEXT}" +ENV{SCSI_IDENT_LUN_NAA_REG}=="?*", ENV{ID_WWN_WITH_EXTENSION}!="?*", ENV{ID_WWN_WITH_EXTENSION}="0x$env{SCSI_IDENT_LUN_NAA_REG}" ENV{SCSI_IDENT_LUN_NAA_EXT}=="?*", ENV{ID_WWN_WITH_EXTENSION}!="?*", ENV{ID_WWN_WITH_EXTENSION}="0x$env{SCSI_IDENT_LUN_NAA_EXT}" -ENV{ID_WWN}=="?*", ENV{ID_WWN_WITH_EXTENSION}!="?*", ENV{ID_WWN_WITH_EXTENSION}="$env{ID_WWN}" +ENV{SCSI_IDENT_LUN_NAA_LOCAL}=="?*", ENV{ID_WWN_WITH_EXTENSION}!="?*", ENV{ID_WWN_WITH_EXTENSION}="0x$env{SCSI_IDENT_LUN_NAA_LOCAL}" +# ID_WWN has max 16 characters +ENV{ID_WWN_WITH_EXTENSION}=="?*", ENV{ID_WWN}!="?*", \ + PROGRAM="/bin/sh -c 'echo $env{ID_WWN_WITH_EXTENSION} | /bin/sed s/^\\\(0x.\\\{1,16\\\}\\\).*/\\1/'", \ + ENV{ID_WWN}="$result" # ata_id compability ENV{ID_SERIAL}!="?*", ENV{SCSI_IDENT_LUN_ATA}=="?*", ENV{ID_BUS}="ata", ENV{ID_ATA}="1", ENV{ID_SERIAL}="$env{SCSI_IDENT_LUN_ATA}" From a59e4f1b6cf4eff9caeea06d660850ec13870057 Mon Sep 17 00:00:00 2001 From: Martin Wilck Date: Wed, 22 Nov 2017 21:18:11 +0100 Subject: [PATCH 3/8] 55-scsi-sg3_id.rules: reorder compat and sysfs/sg_inq rules Separate the "compat" rules for creating ID_* variables from SCSI_* variables from the block doing actual inquiry. Also improve code readability by spelling out the sysfs vs. sg code more clearly. This patch should have no functional impact. --- scripts/55-scsi-sg3_id.rules | 37 +++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/scripts/55-scsi-sg3_id.rules b/scripts/55-scsi-sg3_id.rules index d7177651..9cd09473 100644 --- a/scripts/55-scsi-sg3_id.rules +++ b/scripts/55-scsi-sg3_id.rules @@ -5,7 +5,12 @@ ACTION=="remove", GOTO="sg3_utils_id_end" SUBSYSTEM!="block", GOTO="sg3_utils_id_end" # Import values for partitions -ENV{DEVTYPE}=="partition", IMPORT{parent}="SCSI_*", ENV{ID_SCSI}="1" +ENV{DEVTYPE}=="partition", IMPORT{parent}="ID_SCSI", IMPORT{parent}="SCSI_*" +ENV{DEVTYPE}=="partition", ENV{ID_SCSI}=="1", GOTO="compat" + +# Ignore everything else except sd/sr +KERNEL!="sd*[!0-9]|sr*", GOTO="sg3_utils_id_end" + # SCSI INQUIRY values # If the 'inquiry' sysfs attribute is present the kernel will already # have scanned for VPD pages, so if the vpd page attribute is not @@ -14,8 +19,28 @@ ENV{DEVTYPE}=="partition", IMPORT{parent}="SCSI_*", ENV{ID_SCSI}="1" # Set 'ID_SCSI_INQUIRY=0' in an earlier udev rule if the kernel # fails to scan VPD pages correctly; the rules will then fall # back to calling sg_vpd directly. -KERNEL=="sd*[!0-9]|sr*", ENV{ID_SCSI_INQUIRY}!="?*", IMPORT{program}="/usr/bin/sg_inq --export --inhex=/sys/block/$kernel/device/inquiry --raw", ENV{ID_SCSI}="1", ENV{ID_SCSI_INQUIRY}="1" -KERNEL=="sd*[!0-9]|sr*", ENV{ID_SCSI}!="1", IMPORT{program}="/usr/bin/sg_inq --export $tempnode", ENV{ID_SCSI}="1" +ENV{ID_SCSI_INQUIRY}=="0", GOTO="sg_inquiry" +ATTRS{inquiry}!="*", GOTO="sg_inquiry" + +IMPORT{program}="/usr/bin/sg_inq --export --inhex=/sys/block/$kernel/device/inquiry --raw", \ + ENV{ID_SCSI}="1", ENV{ID_SCSI_INQUIRY}="1" +# If inquiry sysfs attribute reading it failed, fallback to sg +ENV{ID_SCSI}!="1", GOTO="sg_inquiry" +# Read VPD pages 80 (sn) and 83 (di) +IMPORT{program}="/usr/bin/sg_inq --export --inhex=/sys/block/$kernel/device/vpd_pg80 --raw" +IMPORT{program}="/usr/bin/sg_inq --export --inhex=/sys/block/$kernel/device/vpd_pg83 --raw" +GOTO="compat" + +LABEL="sg_inquiry" +# Handle devices that have no inquiry attributes in sysfs +IMPORT{program}="/usr/bin/sg_inq --export $tempnode", ENV{ID_SCSI}="1" +# Give up if this fails, too +ENV{ID_SCSI}!="1", GOTO="sg3_utils_id_end" +IMPORT{program}="/usr/bin/sg_inq --export --page=sn $tempnode" +IMPORT{program}="/usr/bin/sg_inq --export --page=di $tempnode" + +LABEL="compat" + # scsi_id compat mappings ENV{SCSI_VENDOR}=="?*", ENV{ID_VENDOR}="$env{SCSI_VENDOR}" ENV{SCSI_VENDOR_ENC}=="?*", ENV{ID_VENDOR_ENC}="$env{SCSI_VENDOR_ENC}" @@ -23,12 +48,6 @@ ENV{SCSI_MODEL}=="?*", ENV{ID_MODEL}="$env{SCSI_MODEL}" ENV{SCSI_MODEL_ENC}=="?*", ENV{ID_MODEL_ENC}="$env{SCSI_MODEL_ENC}" ENV{SCSI_REVISION}=="?*", ENV{ID_REVISION}="$env{SCSI_REVISION}" ENV{SCSI_TYPE}=="?*", ENV{ID_TYPE}="$env{SCSI_TYPE}" -# SCSI EVPD page 0x80 values -KERNEL=="sd*[!0-9]|sr*", ENV{ID_SCSI}=="1", ENV{ID_SCSI_INQUIRY}=="1", IMPORT{program}="/usr/bin/sg_inq --export --inhex=/sys/block/$kernel/device/vpd_pg80 --raw" -KERNEL=="sd*[!0-9]|sr*", ENV{ID_SCSI}=="1", ENV{ID_SCSI_INQUIRY}!="1", IMPORT{program}="/usr/bin/sg_inq --export --page=sn $tempnode" -# SCSI EVPD page 0x83 values -KERNEL=="sd*[!0-9]", ENV{ID_SCSI}=="1", ENV{ID_SCSI_INQUIRY}=="1", IMPORT{program}="/usr/bin/sg_inq --export --inhex=/sys/block/$kernel/device/vpd_pg83 --raw" -KERNEL=="sd*[!0-9]|sr*", ENV{ID_SCSI}=="1", ENV{ID_SCSI_INQUIRY}!="1", IMPORT{program}="/usr/bin/sg_inq --export --page=di $tempnode" # ID_WWN compat mapping ENV{SCSI_IDENT_LUN_NAA_REGEXT}=="?*", ENV{ID_WWN_WITH_EXTENSION}!="?*", ENV{ID_WWN_WITH_EXTENSION}="0x$env{SCSI_IDENT_LUN_NAA_REGEXT}" From 98b04c159c10789a0ce646c614531fab69bb2690 Mon Sep 17 00:00:00 2001 From: Martin Wilck Date: Wed, 22 Nov 2017 19:28:32 +0100 Subject: [PATCH 4/8] 55-scsi-sg3_id.rules: support for legacy CCISS devices In order to replace scsi_id functionality from udev's 60-persistent-storage.rules, add code for non-SCSI devices that support sg INQUIRY (only CCISS at this time). CCISS has been deprecated since Linux 4.14, but these rules are supposed to work with older kernels, too. --- scripts/55-scsi-sg3_id.rules | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/55-scsi-sg3_id.rules b/scripts/55-scsi-sg3_id.rules index 9cd09473..36b881b0 100644 --- a/scripts/55-scsi-sg3_id.rules +++ b/scripts/55-scsi-sg3_id.rules @@ -8,6 +8,9 @@ SUBSYSTEM!="block", GOTO="sg3_utils_id_end" ENV{DEVTYPE}=="partition", IMPORT{parent}="ID_SCSI", IMPORT{parent}="SCSI_*" ENV{DEVTYPE}=="partition", ENV{ID_SCSI}=="1", GOTO="compat" +# Handle non-SCSI devices that implement SCSI inquiry +KERNEL=="cciss*", ENV{DEVTYPE}=="disk", GOTO="sg_inquiry" + # Ignore everything else except sd/sr KERNEL!="sd*[!0-9]|sr*", GOTO="sg3_utils_id_end" From cdc42332570573f88669b9e5166439dad43dd0c6 Mon Sep 17 00:00:00 2001 From: Martin Wilck Date: Wed, 22 Nov 2017 21:18:11 +0100 Subject: [PATCH 5/8] 55-scsi-sg3_id.rules: Support tapes and medium changers In order to replace scsi_id functionality in udev's 60-persistent-storage.rules, add support for some non-block devices. These rules have been tested using the emulated virtual tape library mhVTL (https://github.com/markh794/mhvtl). It turns out that preferring sysfs attributes for inquiry is even more beneficial for those than for disks. --- scripts/55-scsi-sg3_id.rules | 40 ++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/scripts/55-scsi-sg3_id.rules b/scripts/55-scsi-sg3_id.rules index 36b881b0..df53f4ba 100644 --- a/scripts/55-scsi-sg3_id.rules +++ b/scripts/55-scsi-sg3_id.rules @@ -2,7 +2,24 @@ ACTION=="remove", GOTO="sg3_utils_id_end" -SUBSYSTEM!="block", GOTO="sg3_utils_id_end" +SUBSYSTEM=="block", GOTO="block_dev" + +# SCSI devices other than "block" +# This code used to live in 60-persistent-storage-tape.rules. + +# type 8 devices are "Medium Changers" +SUBSYSTEM=="scsi_generic", KERNEL=="sg*[0-9]", ATTRS{type}=="8", \ + GOTO="scsi_inquiry" +SUBSYSTEM=="scsi_changer", KERNEL=="sch*[0-9]", ATTRS{type}=="8", \ + ENV{.INQUIRY_DEV}="$root/bsg/$id", GOTO="scsi_inquiry" + +# tapes need to be accessed through their bsg device +KERNEL=="st*[0-9]|nst*[0-9]", SUBSYSTEMS=="scsi", KERNELS=="[0-9]*:*[0-9]", \ + ENV{.INQUIRY_DEV}="$root/bsg/$id", GOTO="scsi_inquiry" + +GOTO="sg3_utils_id_end" + +LABEL="block_dev" # Import values for partitions ENV{DEVTYPE}=="partition", IMPORT{parent}="ID_SCSI", IMPORT{parent}="SCSI_*" @@ -22,25 +39,32 @@ KERNEL!="sd*[!0-9]|sr*", GOTO="sg3_utils_id_end" # Set 'ID_SCSI_INQUIRY=0' in an earlier udev rule if the kernel # fails to scan VPD pages correctly; the rules will then fall # back to calling sg_vpd directly. +LABEL="scsi_inquiry" ENV{ID_SCSI_INQUIRY}=="0", GOTO="sg_inquiry" -ATTRS{inquiry}!="*", GOTO="sg_inquiry" +# "inquiry" is an attribute of the scsi_device in sysfs, +# we obtain it by using $id after an ATTRS match. +SUBSYSTEMS=="scsi", ATTRS{inquiry}=="*", KERNELS=="[0-9]*:*[0-9]", \ + ENV{.SYSFS_PATH}="$sys/class/scsi_device/$id/device" +ENV{.SYSFS_PATH}=="", GOTO="sg_inquiry" -IMPORT{program}="/usr/bin/sg_inq --export --inhex=/sys/block/$kernel/device/inquiry --raw", \ +IMPORT{program}="/usr/bin/sg_inq --export --inhex=$env{.SYSFS_PATH}/inquiry --raw", \ ENV{ID_SCSI}="1", ENV{ID_SCSI_INQUIRY}="1" # If inquiry sysfs attribute reading it failed, fallback to sg ENV{ID_SCSI}!="1", GOTO="sg_inquiry" # Read VPD pages 80 (sn) and 83 (di) -IMPORT{program}="/usr/bin/sg_inq --export --inhex=/sys/block/$kernel/device/vpd_pg80 --raw" -IMPORT{program}="/usr/bin/sg_inq --export --inhex=/sys/block/$kernel/device/vpd_pg83 --raw" +IMPORT{program}="/usr/bin/sg_inq --export --inhex=$env{.SYSFS_PATH}/vpd_pg80 --raw" +IMPORT{program}="/usr/bin/sg_inq --export --inhex=$env{.SYSFS_PATH}/vpd_pg83 --raw" GOTO="compat" LABEL="sg_inquiry" # Handle devices that have no inquiry attributes in sysfs -IMPORT{program}="/usr/bin/sg_inq --export $tempnode", ENV{ID_SCSI}="1" +ENV{.INQUIRY_DEV}=="", ENV{.INQUIRY_DEV}="$tempnode" + +IMPORT{program}="/usr/bin/sg_inq --export $env{.INQUIRY_DEV}", ENV{ID_SCSI}="1" # Give up if this fails, too ENV{ID_SCSI}!="1", GOTO="sg3_utils_id_end" -IMPORT{program}="/usr/bin/sg_inq --export --page=sn $tempnode" -IMPORT{program}="/usr/bin/sg_inq --export --page=di $tempnode" +IMPORT{program}="/usr/bin/sg_inq --export --page=sn $env{.INQUIRY_DEV}" +IMPORT{program}="/usr/bin/sg_inq --export --page=di $env{.INQUIRY_DEV}" LABEL="compat" From 8be170d94ef299812eb9eb4b07d8a2023b390630 Mon Sep 17 00:00:00 2001 From: Martin Wilck Date: Fri, 26 Jan 2018 01:04:06 +0100 Subject: [PATCH 6/8] 55-scsi-sg3_id.rules: don't overwrite MODEL_ID etc. ata_id or usb_id may have already set these variables. Don't overwrite them in this case. --- scripts/55-scsi-sg3_id.rules | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/55-scsi-sg3_id.rules b/scripts/55-scsi-sg3_id.rules index df53f4ba..2c5faba4 100644 --- a/scripts/55-scsi-sg3_id.rules +++ b/scripts/55-scsi-sg3_id.rules @@ -69,12 +69,12 @@ IMPORT{program}="/usr/bin/sg_inq --export --page=di $env{.INQUIRY_DEV}" LABEL="compat" # scsi_id compat mappings -ENV{SCSI_VENDOR}=="?*", ENV{ID_VENDOR}="$env{SCSI_VENDOR}" -ENV{SCSI_VENDOR_ENC}=="?*", ENV{ID_VENDOR_ENC}="$env{SCSI_VENDOR_ENC}" -ENV{SCSI_MODEL}=="?*", ENV{ID_MODEL}="$env{SCSI_MODEL}" -ENV{SCSI_MODEL_ENC}=="?*", ENV{ID_MODEL_ENC}="$env{SCSI_MODEL_ENC}" -ENV{SCSI_REVISION}=="?*", ENV{ID_REVISION}="$env{SCSI_REVISION}" -ENV{SCSI_TYPE}=="?*", ENV{ID_TYPE}="$env{SCSI_TYPE}" +ENV{ID_VENDOR}!="?*", ENV{SCSI_VENDOR}=="?*", ENV{ID_VENDOR}="$env{SCSI_VENDOR}" +ENV{ID_VENDOR_ENC}!="?*", ENV{SCSI_VENDOR_ENC}=="?*", ENV{ID_VENDOR_ENC}="$env{SCSI_VENDOR_ENC}" +ENV{ID_MODEL}!="?*", ENV{SCSI_MODEL}=="?*", ENV{ID_MODEL}="$env{SCSI_MODEL}" +ENV{ID_MODEL_ENC}!="?*", ENV{SCSI_MODEL_ENC}=="?*", ENV{ID_MODEL_ENC}="$env{SCSI_MODEL_ENC}" +ENV{ID_REVISION}!="?*", ENV{SCSI_REVISION}=="?*", ENV{ID_REVISION}="$env{SCSI_REVISION}" +ENV{ID_TYPE}!="?*", ENV{SCSI_TYPE}=="?*", ENV{ID_TYPE}="$env{SCSI_TYPE}" # ID_WWN compat mapping ENV{SCSI_IDENT_LUN_NAA_REGEXT}=="?*", ENV{ID_WWN_WITH_EXTENSION}!="?*", ENV{ID_WWN_WITH_EXTENSION}="0x$env{SCSI_IDENT_LUN_NAA_REGEXT}" From 8b375d8f72b2182cdd033227f4337848f05c8cd3 Mon Sep 17 00:00:00 2001 From: Martin Wilck Date: Fri, 26 Jan 2018 01:15:34 +0100 Subject: [PATCH 7/8] 55-scsi-sg3_id.rules: compat support for ID_TARGET_PORT scsi_id sets ID_TARGET_PORT=%x. --- scripts/55-scsi-sg3_id.rules | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/55-scsi-sg3_id.rules b/scripts/55-scsi-sg3_id.rules index 2c5faba4..cc87ea37 100644 --- a/scripts/55-scsi-sg3_id.rules +++ b/scripts/55-scsi-sg3_id.rules @@ -75,6 +75,9 @@ ENV{ID_MODEL}!="?*", ENV{SCSI_MODEL}=="?*", ENV{ID_MODEL}="$env{SCSI_MODEL}" ENV{ID_MODEL_ENC}!="?*", ENV{SCSI_MODEL_ENC}=="?*", ENV{ID_MODEL_ENC}="$env{SCSI_MODEL_ENC}" ENV{ID_REVISION}!="?*", ENV{SCSI_REVISION}=="?*", ENV{ID_REVISION}="$env{SCSI_REVISION}" ENV{ID_TYPE}!="?*", ENV{SCSI_TYPE}=="?*", ENV{ID_TYPE}="$env{SCSI_TYPE}" +ENV{ID_TARGET_PORT}!="?*", ENV{SCSI_IDENT_PORT_TARGET_PORT_GROUP}=="?*", \ + PROGRAM="/bin/sh -c 'echo $env{SCSI_IDENT_PORT_TARGET_PORT_GROUP} | /bin/sed s/^0x//'", \ + ENV{ID_TARGET_PORT}="$result" # ID_WWN compat mapping ENV{SCSI_IDENT_LUN_NAA_REGEXT}=="?*", ENV{ID_WWN_WITH_EXTENSION}!="?*", ENV{ID_WWN_WITH_EXTENSION}="0x$env{SCSI_IDENT_LUN_NAA_REGEXT}" From 7df3633722a3b4350642209db2679ddcf5c65d40 Mon Sep 17 00:00:00 2001 From: Martin Wilck Date: Wed, 7 Feb 2018 13:23:22 +0100 Subject: [PATCH 8/8] 55-scsi-sg3_utils.rules: run sg_inq for SPC devices As of 2018 kernel 4.15, the kernel doesn't provide VPD pages for "SPC" devices (SCSI version 0x03, ANSI INCITS 301-1997) in sysfs. It's usually safe to try though (no counter-example is known), and for scsi_id compatibility, we have to try. If the kernel ever changes its policy, this rule can perhaps be dropped. --- scripts/55-scsi-sg3_id.rules | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/55-scsi-sg3_id.rules b/scripts/55-scsi-sg3_id.rules index cc87ea37..f15d5799 100644 --- a/scripts/55-scsi-sg3_id.rules +++ b/scripts/55-scsi-sg3_id.rules @@ -41,6 +41,13 @@ KERNEL!="sd*[!0-9]|sr*", GOTO="sg3_utils_id_end" # back to calling sg_vpd directly. LABEL="scsi_inquiry" ENV{ID_SCSI_INQUIRY}=="0", GOTO="sg_inquiry" + +# As of 2018/4.15, the kernel doesn't provide VPD pages for "SPC" devices +# (SCSI version 0x03, ANSI INCITS 301-1997) in sysfs. +# It's usually safe to try though (no counter-example is known), +# and for scsi_id compatibility, we have to try. +SUBSYSTEMS=="scsi", ATTRS{scsi_level}=="4", GOTO="sg_inquiry" + # "inquiry" is an attribute of the scsi_device in sysfs, # we obtain it by using $id after an ATTRS match. SUBSYSTEMS=="scsi", ATTRS{inquiry}=="*", KERNELS=="[0-9]*:*[0-9]", \