- /* handle the devices on the "first" list first */
- list_for_each_entry_safe(loop_device, tmp_device, &device_first_list, node) {
- trigger_uevent(loop_device->name);
- list_del(&loop_device->node);
- free(loop_device);
+ if (verbose)
+ printf("%s\n", devpath);
+
+ udev_device_init(&udev);
+ udev_db_get_device(&udev, devpath);
+
+ /* add header */
+ bufpos = snprintf(buf, sizeof(buf)-1, "%s@%s", action, devpath);
+ bufpos++;
+
+ /* add standard keys */
+ bufpos += snprintf(&buf[bufpos], sizeof(buf)-1, "DEVPATH=%s", devpath);
+ bufpos++;
+ bufpos += snprintf(&buf[bufpos], sizeof(buf)-1, "ACTION=%s", action);
+ bufpos++;
+
+ /* add subsystem */
+ strlcpy(path, sysfs_path, sizeof(path));
+ strlcat(path, devpath, sizeof(path));
+ strlcat(path, "/subsystem", sizeof(path));
+ len = readlink(path, link_target, sizeof(link_target));
+ if (len > 0) {
+ char *pos;
+
+ link_target[len] = '\0';
+ pos = strrchr(link_target, '/');
+ if (pos != NULL) {
+ bufpos += snprintf(&buf[bufpos], sizeof(buf)-1, "SUBSYSTEM=%s", &pos[1]);
+ bufpos++;
+ }