summaryrefslogtreecommitdiff
path: root/src/udev
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2023-05-10 15:47:44 +0900
committerMike Yuan <me@yhndnzj.com>2023-05-10 19:42:49 +0800
commit39a39f18f2bd2b1ef7b4fa4823472d129c514030 (patch)
tree12cc0de914f898aabf569876d8ba42692a7e8924 /src/udev
parenteb29296937b268e0140a2ab1cf204c2ebb72fa5a (diff)
downloadsystemd-39a39f18f2bd2b1ef7b4fa4823472d129c514030.tar.gz
udev: do not set ID_PATH and by-path symlink for nvmf disks
Prompted by #27391.
Diffstat (limited to 'src/udev')
-rw-r--r--src/udev/udev-builtin-path_id.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/udev/udev-builtin-path_id.c b/src/udev/udev-builtin-path_id.c
index 8e4d57ee72..ff6682cad9 100644
--- a/src/udev/udev-builtin-path_id.c
+++ b/src/udev/udev-builtin-path_id.c
@@ -545,7 +545,7 @@ static sd_device *handle_ap(sd_device *parent, char **path) {
static int find_real_nvme_parent(sd_device *dev, sd_device **ret) {
_cleanup_(sd_device_unrefp) sd_device *nvme = NULL;
- const char *sysname, *end;
+ const char *sysname, *end, *devpath;
int r;
/* If the device belongs to "nvme-subsystem" (not to be confused with "nvme"), which happens when
@@ -577,6 +577,14 @@ static int find_real_nvme_parent(sd_device *dev, sd_device **ret) {
if (r < 0)
return r;
+ r = sd_device_get_devpath(nvme, &devpath);
+ if (r < 0)
+ return r;
+
+ /* If the 'real parent' is (still) virtual, e.g. for nvmf disks, refuse to set ID_PATH. */
+ if (path_startswith(devpath, "/devices/virtual/"))
+ return -ENXIO;
+
*ret = TAKE_PTR(nvme);
return 0;
}