- /* double entries will be ignored */
- name_list_add(device_list, path, 0);
+
+ /* we only have a device, if we have an uevent file */
+ strlcpy(filename, path, sizeof(filename));
+ strlcat(filename, "/uevent", sizeof(filename));
+ if (stat(filename, &statbuf) < 0)
+ return -1;
+ if (!(statbuf.st_mode & S_IWUSR))
+ return -1;
+
+ strlcpy(devpath, &path[strlen(sysfs_path)], sizeof(devpath));
+
+ /* resolve possible link to real target */
+ if (lstat(path, &statbuf) < 0)
+ return -1;
+ if (S_ISLNK(statbuf.st_mode))
+ if (sysfs_resolve_link(devpath, sizeof(devpath)) != 0)
+ return -1;
+
+ name_list_add(&device_list, devpath, 1);