+ if (sysfs_device) {
+ dbg("found devices device: path='%s', bus_id='%s', bus='%s'",
+ sysfs_device->path, sysfs_device->bus_id, sysfs_device->bus);
+ strfieldcpy(udev->bus_id, sysfs_device->bus_id);
+ strfieldcpy(udev->bus, sysfs_device->bus);
+ }
+
+ strfieldcpy(udev->kernel_name, class_dev->name);
+ fix_kernel_name(udev);
+ dbg("udev->kernel_name = '%s'", udev->kernel_name);
+
+ /* get kernel number */
+ pos = class_dev->name + strlen(class_dev->name);
+ while (isdigit(*(pos-1)))
+ pos--;
+ strfieldcpy(udev->kernel_number, pos);
+ dbg("kernel_number='%s'", udev->kernel_number);
+
+ /* look for a matching rule to apply */
+ list_for_each_entry(dev, &config_device_list, node) {
+ dbg("process rule");
+ if (match_rule(dev, class_dev, udev, sysfs_device) == 0) {
+ if (dev->name[0] == '\0' && dev->symlink[0] == '\0') {
+ info("configured rule in '%s' at line %i applied, '%s' is ignored",
+ dev->config_file, dev->config_line, udev->kernel_name);
+ return -1;
+ }
+
+ if (dev->symlink[0] != '\0') {
+ char temp[NAME_SIZE];
+
+ info("configured rule in '%s' at line %i applied, added symlink '%s'",
+ dev->config_file, dev->config_line, dev->symlink);
+ strfieldcpy(temp, dev->symlink);
+ apply_format(udev, temp, sizeof(temp), class_dev, sysfs_device);
+ if (udev->symlink[0] != '\0')
+ strfieldcat(udev->symlink, " ");
+ strfieldcat(udev->symlink, temp);
+ }
+
+ if (dev->name[0] != '\0') {
+ /* apply all_partitions flag only at a main block device */
+ if (dev->partitions > 0 &&
+ (udev->type != 'b' || udev->kernel_number[0] != '\0'))
+ continue;
+
+ info("configured rule in '%s' at line %i applied, '%s' becomes '%s'",
+ dev->config_file, dev->config_line, udev->kernel_name, dev->name);
+ strfieldcpy(udev->name, dev->name);
+ goto found;
+ }
+ }
+ }