X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fudev%2Fudev-builtin-path_id.c;h=df996cb17aca160fd4496b6769adf82a62f52826;hb=79008bddf679a5e0900369950eb346c9fa687107;hp=ac0f71f83e2f4d01d2f230b1c697f4ac4ee5a4d7;hpb=9ec6e95b046de71c0198cb9d17acc5462dc76c74;p=elogind.git diff --git a/src/udev/udev-builtin-path_id.c b/src/udev/udev-builtin-path_id.c index ac0f71f83..df996cb17 100644 --- a/src/udev/udev-builtin-path_id.c +++ b/src/udev/udev-builtin-path_id.c @@ -332,7 +332,7 @@ static struct udev_device *handle_scsi_hyperv(struct udev_device *parent, char * return parent; } -static struct udev_device *handle_scsi(struct udev_device *parent, char **path) { +static struct udev_device *handle_scsi(struct udev_device *parent, char **path, bool *supported_parent) { const char *devtype; const char *name; const char *id; @@ -346,6 +346,7 @@ static struct udev_device *handle_scsi(struct udev_device *parent, char **path) if (id != NULL) { parent = skip_subsystem(parent, "scsi"); path_prepend(path, "ieee1394-0x%s", id); + *supported_parent = true; goto out; } @@ -354,16 +355,19 @@ static struct udev_device *handle_scsi(struct udev_device *parent, char **path) if (strstr(name, "/rport-") != NULL) { parent = handle_scsi_fibre_channel(parent, path); + *supported_parent = true; goto out; } if (strstr(name, "/end_device-") != NULL) { parent = handle_scsi_sas(parent, path); + *supported_parent = true; goto out; } if (strstr(name, "/session") != NULL) { parent = handle_scsi_iscsi(parent, path); + *supported_parent = true; goto out; } @@ -481,7 +485,8 @@ out: static int builtin_path_id(struct udev_device *dev, int argc, char *argv[], bool test) { struct udev_device *parent; char *path = NULL; - bool some_transport = false; + bool supported_transport = false; + bool supported_parent = false; /* S390 ccw bus */ parent = udev_device_get_parent_with_subsystem_devtype(dev, "ccw", NULL); @@ -501,48 +506,63 @@ static int builtin_path_id(struct udev_device *dev, int argc, char *argv[], bool } else if (streq(subsys, "scsi_tape")) { handle_scsi_tape(parent, &path); } else if (streq(subsys, "scsi")) { - parent = handle_scsi(parent, &path); - some_transport = true; + parent = handle_scsi(parent, &path, &supported_parent); + supported_transport = true; } else if (streq(subsys, "cciss")) { parent = handle_cciss(parent, &path); - some_transport = true; + supported_transport = true; } else if (streq(subsys, "usb")) { parent = handle_usb(parent, &path); - some_transport = true; + supported_transport = true; } else if (streq(subsys, "bcma")) { parent = handle_bcma(parent, &path); - some_transport = true; + supported_transport = true; } else if (streq(subsys, "serio")) { path_prepend(&path, "serio-%s", udev_device_get_sysnum(parent)); parent = skip_subsystem(parent, "serio"); } else if (streq(subsys, "pci")) { path_prepend(&path, "pci-%s", udev_device_get_sysname(parent)); parent = skip_subsystem(parent, "pci"); + supported_parent = true; } else if (streq(subsys, "platform")) { path_prepend(&path, "platform-%s", udev_device_get_sysname(parent)); parent = skip_subsystem(parent, "platform"); - some_transport = true; + supported_transport = true; + supported_parent = true; } else if (streq(subsys, "acpi")) { path_prepend(&path, "acpi-%s", udev_device_get_sysname(parent)); parent = skip_subsystem(parent, "acpi"); + supported_parent = true; } else if (streq(subsys, "xen")) { path_prepend(&path, "xen-%s", udev_device_get_sysname(parent)); parent = skip_subsystem(parent, "xen"); + supported_parent = true; } else if (streq(subsys, "scm")) { path_prepend(&path, "scm-%s", udev_device_get_sysname(parent)); parent = skip_subsystem(parent, "scm"); - some_transport = true; + supported_transport = true; + supported_parent = true; } parent = udev_device_get_parent(parent); } /* - * Do not return a single-parent-device-only for block - * devices, they might have entire buses behind it which - * do not get unique IDs only by using the parent device. + * Do not return devices with an unknown parent device type. They + * might produce conflicting IDs if the parent does not provide a + * unique and predictable name. */ - if (!some_transport && streq(udev_device_get_subsystem(dev), "block")) { + if (!supported_parent) { + free(path); + path = NULL; + } + + /* + * Do not return block devices without a well-known transport. Some + * devices do not expose their buses and do not provide a unique + * and predictable name that way. + */ + if (streq(udev_device_get_subsystem(dev), "block") && !supported_transport) { free(path); path = NULL; }