Skip to content

Commit 1807b8f

Browse files
yuwatabluca
authored andcommitted
udev: do not set ID_PATH and by-path symlink for nvmf disks
Prompted by #27391. (cherry picked from commit 39a39f1) (cherry picked from commit dbf50f1) (cherry picked from commit 5ec7ad9)
1 parent 7510be9 commit 1807b8f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/udev/udev-builtin-path_id.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ static sd_device *handle_ap(sd_device *parent, char **path) {
545545

546546
static int find_real_nvme_parent(sd_device *dev, sd_device **ret) {
547547
_cleanup_(sd_device_unrefp) sd_device *nvme = NULL;
548-
const char *sysname, *end;
548+
const char *sysname, *end, *devpath;
549549
int r;
550550

551551
/* If the device belongs to "nvme-subsystem" (not to be confused with "nvme"), which happens when
@@ -576,6 +576,14 @@ static int find_real_nvme_parent(sd_device *dev, sd_device **ret) {
576576
if (r < 0)
577577
return r;
578578

579+
r = sd_device_get_devpath(nvme, &devpath);
580+
if (r < 0)
581+
return r;
582+
583+
/* If the 'real parent' is (still) virtual, e.g. for nvmf disks, refuse to set ID_PATH. */
584+
if (path_startswith(devpath, "/devices/virtual/"))
585+
return -ENXIO;
586+
579587
*ret = TAKE_PTR(nvme);
580588
return 0;
581589
}

0 commit comments

Comments
 (0)