chiark / gitweb /
[PATCH] minor grammer fixes for the udev_vs_devfs document
[elogind.git] / namedev.c
index 1e600bbe6d2b997112325133dbc03c980c2d12d7..cff338f1a719b635c06a33c765d2376f46869f4b 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,8 @@ static struct bus_file {
 } bus_files[] = {
        { .bus = "scsi",        .file = "vendor" },
        { .bus = "usb",         .file = "idVendor" },
+       { .bus = "ide",         .file = "detach_state" },
+       { .bus = "pci",         .file = "vendor" },
        {}
 };
 
@@ -398,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;
@@ -469,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;
@@ -644,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 */