SHA256
1
0
forked from pool/systemd
systemd/0001-compat-rules-get-rid-of-scsi_id-when-generating-comp.patch
Franck Bui 995db5b7d7 Accepting request 546398 from home:fbui:systemd:Factory
- Import commit e30f1b10e276fb18db10ea2463fbd7146ae778f6
  63481b24b firstboot: do not write vconsole.conf when arg_keymap is empty (bsc#1070124)

- Add 0001-compat-rules-get-rid-of-scsi_id-when-generating-comp.patch (bsc#1051465)
  This patch is not yet merged in the 'compats/udev-compat-symlinks'
  branch: we asked to upstream if it would be possible to introduce a
  new specifier that wouldn't strip trailing whitespaces , see
  https://github.com/systemd/systemd/issues/7462
  Also this allows to give the patch more testing before merging it in
  the git repo.

OBS-URL: https://build.opensuse.org/request/show/546398
OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=999
2017-11-29 10:41:17 +00:00

78 lines
3.5 KiB
Diff

From 17be35b017aa39fad8aec98c81d4fade917096ec Mon Sep 17 00:00:00 2001
From: Franck Bui <fbui@suse.com>
Date: Mon, 27 Nov 2017 11:46:40 +0100
Subject: [PATCH 1/1] compat-rules: get rid of scsi_id when generating compat
symlinks for NVMe devices
The SCSI translation layer for NVMe devices has been removed from the
kernel since 4.13 (commit 3f7f25a910ed8988b2a87c1ca2bfee6b4fb83ac7),
so drop scsi_id in favor of the sysfs interface to generate the
name of the compat symlinks.
Unfortunately we have to retrieve manually the model attribute
because %s{} strips trailing whitespaces otherwise. Indeed scsi_id
replaced them with a single '_' char due to the use of the
'--replace-whitespace' option.
[tblume: fixes bsc#1051465]
---
rules/61-persistent-storage-compat.rules | 34 ++++++++++++++++++++++++++++----
1 file changed, 30 insertions(+), 4 deletions(-)
diff --git a/rules/61-persistent-storage-compat.rules b/rules/61-persistent-storage-compat.rules
index 82a38fac7..639dc1ee1 100644
--- a/rules/61-persistent-storage-compat.rules
+++ b/rules/61-persistent-storage-compat.rules
@@ -16,6 +16,10 @@
# doesn't rely on them and they could be disabled permanently.
#
# Thanks !
+#
+# Note: this rules file can rely on all ID_* variables (set by
+# 60-persistent-storage.rule) but should not overwrite them, see
+# bsc#1048679 for details.
ACTION=="remove", GOTO="persistent_storage_end"
@@ -49,11 +53,33 @@ ENV{COMPAT_SYMLINK_GENERATION}!="?*", ENV{COMPAT_SYMLINK_GENERATION}="1"
#
ENV{COMPAT_SYMLINK_GENERATION}!="1", GOTO="generation_2"
-# NVMe links were introduced first via a SUSE specific commit
+# NVMe symlinks were introduced first via a SUSE specific commit
# (bsc#944132) and upstream gained support later but of course using a
-# different scheme. Also note that ID_SERIAL is already used by the
-# contemporary rules, see bsc#1048679 for details.
-KERNEL=="nvme*", ENV{DEVTYPE}=="disk", ENV{ID_NVME_SERIAL_COMPAT}!="?*", PROGRAM="scsi_id --whitelisted --replace-whitespace -d $devnode", RESULT=="?*", ENV{ID_NVME_SERIAL_COMPAT}="$result"
+# different scheme.
+
+# The SCSI translation layer for NVMe devices has been removed from
+# the kernel since 4.13, therefore we switched from scsi_id to the
+# sysfs interface to generate the name of the compat symlinks.
+# Unfortunately we can't use %s{model} to retrieve the model string
+# because udev strips any trailing whitespaces and some plateforms
+# (QEMU does that) might append such chars. In those cases scsi_id was
+# replacing them with a single trailing '_'. Therefore the currently
+# code retrieves the model string manually making sure to preserve all
+# characters so trailing whitespaces are still converted when the
+# symlink is created.
+
+# KERNEL=="nvme*", ENV{DEVTYPE}=="disk", ENV{ID_NVME_SERIAL_COMPAT}!="?*", ATTRS{model}=="?*", ATTRS{serial}=="?*" \
+# PROGRAM=="/bin/sh -c 'MODEL=\"%s{model}\"; echo \"${MODEL:0:16}\"'", ENV{ID_NVME_SERIAL_COMPAT}="SNVMe_%c%s{serial}"
+
+KERNEL=="nvme*", ENV{DEVTYPE}=="disk", ENV{ID_NVME_SERIAL_COMPAT}!="?*", ATTRS{model}=="?*", ATTRS{serial}=="?*" \
+ PROGRAM=="/bin/sh -c ' \
+ cd /sys/%p; \
+ while ! [ -f model ]; do \
+ cd ..; \
+ [ $(pwd) = %S ] && exit 1; \
+ done; \
+ cut -c 1-16 model'", ENV{ID_NVME_SERIAL_COMPAT}="SNVMe_%c%s{serial}"
+
KERNEL=="nvme*", ENV{DEVTYPE}=="disk", ENV{ID_NVME_SERIAL_COMPAT}=="?*", SYMLINK+="disk/by-id/nvme-$env{ID_NVME_SERIAL_COMPAT}"
KERNEL=="nvme*", ENV{DEVTYPE}=="partition", ENV{ID_NVME_SERIAL_COMPAT}=="?*", SYMLINK+="disk/by-id/nvme-$env{ID_NVME_SERIAL_COMPAT}-part%n"
--
2.14.2