udev/path_id: introduce support for NVMe devices

This appends the nvme name and namespace identifier attribute the the
PCI path for by-path links. Symlinks like the following are now present:

lrwxrwxrwx. 1 root root 13 Sep 16 12:12 pci-0000:01:00.0-nvme-1 -> ../../nvme0n1
lrwxrwxrwx. 1 root root 15 Sep 16 12:12 pci-0000:01:00.0-nvme-1-part1 -> ../../nvme0n1p1

Cc: Michal Sekletar <sekletar.m@gmail.com>
Signed-off-by: Keith Busch <keith.busch@intel.com>
This commit is contained in:
Keith Busch 2023-12-31 01:20:55 -05:00 committed by Brian White
parent f2d455e5d1
commit cad674e76e
No known key found for this signature in database
GPG Key ID: 606D7358F94DA209

View File

@ -636,6 +636,15 @@ static int builtin_path_id(struct udev_device *dev, int argc __attribute__((unus
parent = skip_subsystem(parent, "scm"); parent = skip_subsystem(parent, "scm");
supported_transport = true; supported_transport = true;
supported_parent = true; supported_parent = true;
} else if (streq(subsys, "nvme")) {
const char *nsid = udev_device_get_sysattr_value(dev, "nsid");
if (nsid) {
path_prepend(&path, "nvme-%s", nsid);
parent = skip_subsystem(parent, "nvme");
supported_parent = true;
supported_transport = true;
}
} }
parent = udev_device_get_parent(parent); parent = udev_device_get_parent(parent);