keventd: don't publish whole-disk by-id links for partitions

disk_serial_id() falls back to <disk>/../serial so a partition got a
by-id link named after its parent disk's serial, clobbering the link
created for the whole disk.

(cherry picked from commit 4b2f8c89c5)
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Paweł authored and Joachim Wiberg committed 2026-11-13 15:06:08 +01:00
1 parent 297d2de1da
commit c03059a9a0
1 file changed
+11 -2
+11 -2
View File
@@ -848,7 +848,7 @@ static int disk_path_id(struct uevent *ev, char *id, size_t len)
static int symlink_add_disk(struct uevent *ev)
{
char target[PATH_MAX], link[PATH_MAX], id[256];
const char *name;
const char *name, *devtype;
if (!ev->devname)
return -1;
@@ -857,13 +857,22 @@ static int symlink_add_disk(struct uevent *ev)
name = strrchr(ev->devname, '/');
name = name ? name + 1 : ev->devname;
/* by-id: serial-based identifier */
/*
* by-id: serial-based identifier.
* Partitions are skipped, as their serial lives on the parent disk and would
* clobber its by-id link, partitions get theirs from the udev rules instead.
*/
devtype = uevent_getenv(ev, "DEVTYPE");
if (devtype && !strcmp(devtype, "partition"))
goto path;
if (!disk_serial_id(ev, id, sizeof(id))) {
snprintf(target, sizeof(target), "../../%s", name);
snprintf(link, sizeof(link), "/dev/disk/by-id/%s", id);
symlink_create(target, link, ev->devpath);
}
path:
/* by-path: topology-based identifier */
if (!disk_path_id(ev, id, sizeof(id))) {
snprintf(target, sizeof(target), "../../%s", name);