X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=namedev.c;h=cff338f1a719b635c06a33c765d2376f46869f4b;hb=c78cb204bc64bce32e705dead071bd4149b731ac;hp=e474b48e57fbb973221e50b68b13cb3f6e671c0f;hpb=480763324d812d3d5eb11cbe898a9b358b6fedbf;p=elogind.git diff --git a/namedev.c b/namedev.c index e474b48e5..cff338f1a 100644 --- a/namedev.c +++ b/namedev.c @@ -200,11 +200,12 @@ static void apply_format(struct udevice *udev, unsigned char *string) case 'D': if (strlen(udev->kernel_number) == 0) { strcat(pos, "disc"); + dbg("substitute devfs disc"); break; } strcat(pos, "part"); strcat(pos, udev->kernel_number); - dbg("substitute kernel number '%s'", udev->kernel_number); + dbg("substitute devfs part '%s'", udev->kernel_number); break; case 'm': sprintf(pos, "%u", udev->minor); @@ -229,8 +230,10 @@ static void apply_format(struct udevice *udev, unsigned char *string) break; } } - strcat(pos, pos3); - dbg("substitute partial callout output '%s'", pos3); + if (pos3) { + strcat(pos, pos3); + dbg("substitute partial callout output '%s'", pos3); + } } else { strcat(pos, udev->callout_value); dbg("substitute callout output '%s'", udev->callout_value); @@ -252,6 +255,7 @@ static struct bus_file { } bus_files[] = { { .bus = "scsi", .file = "vendor" }, { .bus = "usb", .file = "idVendor" }, + { .bus = "ide", .file = "detach_state" }, { .bus = "pci", .file = "vendor" }, {} }; @@ -399,7 +403,10 @@ static int do_callout(struct sysfs_class_device *class_dev, struct udevice *udev if (dev->type != CALLOUT) continue; - if (sysfs_device) { + if (dev->bus[0] != '\0') { + /* as the user specified a bus, we must match it up */ + if (!sysfs_device) + continue; dbg("dev->bus='%s' sysfs_device->bus='%s'", dev->bus, sysfs_device->bus); if (strcasecmp(dev->bus, sysfs_device->bus) != 0) continue; @@ -470,7 +477,10 @@ static int do_label(struct sysfs_class_device *class_dev, struct udevice *udev, if (dev->type != LABEL) continue; - if (sysfs_device) { + if (dev->bus[0] != '\0') { + /* as the user specified a bus, we must match it up */ + if (!sysfs_device) + continue; dbg("dev->bus='%s' sysfs_device->bus='%s'", dev->bus, sysfs_device->bus); if (strcasecmp(dev->bus, sysfs_device->bus) != 0) continue; @@ -645,9 +655,9 @@ static struct sysfs_device *get_sysfs_device(struct sysfs_class_device *class_de if (isdigit(class_dev->path[strlen(class_dev->path)-1])) { temp = strrchr(filename, '/'); if (temp) { + char *temp2 = strrchr(filename, '/'); partition = 1; *temp = 0x00; - char *temp2 = strrchr(filename, '/'); dbg("temp2 = %s", temp2); if (temp2 && (strcmp(temp2, "/block") == 0)) { /* oops, we have no parent block device, so go back to original directory */