udev/path_id: fix skip_subsystem()
This partially revertsd340bdd1bd. The function previously drops multiple except for the last parents which matches the specified subsystem. But the commitd340bdd1bddrops all parents. E.g. input is pci-pci-pci-usb-usb-usb, then Befored340bdd: pci-pci-pci-usb Afterd340bdd: pci-pci-pci
This commit is contained in:
@@ -80,19 +80,29 @@ static int format_lun_number(sd_device *dev, char **path) {
|
||||
}
|
||||
|
||||
static sd_device *skip_subsystem(sd_device *dev, const char *subsys) {
|
||||
sd_device *parent;
|
||||
|
||||
assert(dev);
|
||||
assert(subsys);
|
||||
|
||||
for (;;) {
|
||||
/* Unlike the function name, this drops multiple parent devices EXCEPT FOR THE LAST ONE.
|
||||
* The last one will be dropped at the end of the loop in builtin_path_id().
|
||||
* E.g.
|
||||
* Input: /sys/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0
|
||||
* Output: /sys/devices/pci0000:00/0000:00:14.0/usb1
|
||||
*/
|
||||
|
||||
for (parent = dev; ; ) {
|
||||
const char *subsystem;
|
||||
|
||||
if (sd_device_get_subsystem(dev, &subsystem) < 0)
|
||||
if (sd_device_get_subsystem(parent, &subsystem) < 0)
|
||||
break;
|
||||
|
||||
if (!streq(subsystem, subsys))
|
||||
break;
|
||||
|
||||
if (sd_device_get_parent(dev, &dev) < 0)
|
||||
dev = parent;
|
||||
if (sd_device_get_parent(dev, &parent) < 0)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user