+ struct device *loop_device;
+ struct device *tmp_device;
+ int i;
+
+ /* handle the "first" type devices first */
+ list_for_each_entry_safe(loop_device, tmp_device, device_list, node) {
+ for (i = 0; first_list[i] != NULL; i++) {
+ if (strncmp(loop_device->path, first_list[i], strlen(first_list[i])) == 0) {
+ add_device(loop_device->path, loop_device->subsys);
+ list_del(&loop_device->node);
+ free(loop_device);
+ break;
+ }
+ }
+ }
+
+ /* handle the devices we are allowed to, excluding the "last" type devices */
+ list_for_each_entry_safe(loop_device, tmp_device, device_list, node) {
+ int found = 0;
+ for (i = 0; last_list[i] != NULL; i++) {
+ if (strncmp(loop_device->path, last_list[i], strlen(last_list[i])) == 0) {
+ found = 1;
+ break;
+ }
+ }
+ if (found)
+ continue;
+
+ add_device(loop_device->path, loop_device->subsys);
+ list_del(&loop_device->node);
+ free(loop_device);
+ }
+
+ /* handle the rest of the devices left over, if any */
+ list_for_each_entry_safe(loop_device, tmp_device, device_list, node) {
+ add_device(loop_device->path, loop_device->subsys);
+ list_del(&loop_device->node);
+ free(loop_device);
+ }
+}
+
+static int has_devt(const char *directory)
+{
+ char filename[PATH_SIZE];
+ struct stat statbuf;
+
+ snprintf(filename, sizeof(filename), "%s/dev", directory);
+ filename[sizeof(filename)-1] = '\0';
+
+ if (stat(filename, &statbuf) == 0)
+ return 1;
+
+ return 0;
+}
+
+static void udev_scan_block(void)
+{
+ char base[PATH_SIZE];