chiark / gitweb /
[PATCH] fix for apply_format()
[elogind.git] / namedev.c
index e474b48e57fbb973221e50b68b13cb3f6e671c0f..e69eba657a5be161deda8eafdee9e79d238e86d3 100644 (file)
--- 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;