a9339c
From 14ca846073e3b7accb71012a9612d0a7cb6b5ea6 Mon Sep 17 00:00:00 2001
a9339c
From: gwendalcr <gwendal@chromium.org>
a9339c
Date: Wed, 20 Jun 2018 16:54:05 +0200
a9339c
Subject: [PATCH] rules: Add MODEL_ID for NVMe device (#7037)
a9339c
a9339c
To mimic MODEL_ID variable built for ATA and SCSI devices, add rules
a9339c
to add MODEL_ID variable for NVMe devices.
a9339c
a9339c
TEST: Check on a system with NVMe device that MODEL_ID variable is
a9339c
present:
a9339c
 udevadm info --query=all -n /dev/nvme0n1p1 | grep ID_MODEL
a9339c
and
a9339c
 udevadm info --query=all -n /dev/nvme0n1p1 | grep ID_MODEL
a9339c
return:
a9339c
E: ID_MODEL=SAMSUNG...
a9339c
a9339c
(cherry picked from commit e2c2d70ba7cc7497b03c4a377bfb529035540aa7)
a9339c
a9339c
Resolves: #1397264
a9339c
---
a9339c
 rules/60-persistent-storage.rules | 6 ++++--
a9339c
 1 file changed, 4 insertions(+), 2 deletions(-)
a9339c
a9339c
diff --git a/rules/60-persistent-storage.rules b/rules/60-persistent-storage.rules
a9339c
index ba619633b..4aae97a9f 100644
a9339c
--- a/rules/60-persistent-storage.rules
a9339c
+++ b/rules/60-persistent-storage.rules
a9339c
@@ -28,10 +28,12 @@ KERNEL=="nvme*[0-9]n*[0-9]p*[0-9]", ENV{DEVTYPE}=="partition", ATTRS{wwid}=="?*"
a9339c
 
a9339c
 KERNEL=="nvme*[0-9]n*[0-9]", ENV{DEVTYPE}=="disk", ATTRS{serial}=="?*", ENV{ID_SERIAL_SHORT}="$attr{serial}"
a9339c
 KERNEL=="nvme*[0-9]n*[0-9]", ENV{DEVTYPE}=="disk", ATTRS{wwid}=="?*", ENV{ID_WWN}="$attr{wwid}"
a9339c
-KERNEL=="nvme*[0-9]n*[0-9]", ENV{DEVTYPE}=="disk", ATTRS{model}=="?*", ENV{ID_SERIAL_SHORT}=="?*", ENV{ID_SERIAL}="$attr{model}_$env{ID_SERIAL_SHORT}", SYMLINK+="disk/by-id/nvme-$env{ID_SERIAL}", OPTIONS="string_escape=replace"
a9339c
+KERNEL=="nvme*[0-9]n*[0-9]", ENV{DEVTYPE}=="disk", ATTRS{model}=="?*", ENV{ID_MODEL}="$attr{model}"
a9339c
+KERNEL=="nvme*[0-9]n*[0-9]", ENV{DEVTYPE}=="disk", ENV{ID_MODEL}=="?*", ENV{ID_SERIAL_SHORT}=="?*", ENV{ID_SERIAL}="$env{ID_MODEL}_$env{ID_SERIAL_SHORT}", SYMLINK+="disk/by-id/nvme-$env{ID_SERIAL}", OPTIONS="string_escape=replace"
a9339c
 
a9339c
 KERNEL=="nvme*[0-9]n*[0-9]p*[0-9]", ENV{DEVTYPE}=="partition", ATTRS{serial}=="?*", ENV{ID_SERIAL_SHORT}="$attr{serial}"
a9339c
-KERNEL=="nvme*[0-9]n*[0-9]p*[0-9]", ENV{DEVTYPE}=="partition", ATTRS{model}=="?*", ENV{ID_SERIAL_SHORT}=="?*", ENV{ID_SERIAL}="$attr{model}_$env{ID_SERIAL_SHORT}", SYMLINK+="disk/by-id/nvme-$env{ID_SERIAL}-part%n", OPTIONS="string_escape=replace"
a9339c
+KERNEL=="nvme*[0-9]n*[0-9]p*[0-9]", ENV{DEVTYPE}=="partition", ATTRS{model}=="?*", ENV{ID_MODEL}="$attr{model}"
a9339c
+KERNEL=="nvme*[0-9]n*[0-9]p*[0-9]", ENV{DEVTYPE}=="partition", ENV{ID_MODEL}=="?*", ENV{ID_SERIAL_SHORT}=="?*", ENV{ID_SERIAL}="$env{ID_MODEL}_$env{ID_SERIAL_SHORT}", SYMLINK+="disk/by-id/nvme-$env{ID_SERIAL}-part%n", OPTIONS="string_escape=replace"
a9339c
 
a9339c
 # virtio-blk
a9339c
 KERNEL=="vd*[!0-9]", ATTRS{serial}=="?*", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="disk/by-id/virtio-$env{ID_SERIAL}"