- for (cur = bus->directory->subdirs; cur != NULL; cur = cur->next) {
- memset(dirname, 0, SYSFS_NAME_LEN);
- if ((sysfs_get_name_from_path(cur->path, dirname,
- SYSFS_NAME_LEN)) != 0)
- continue;
- if (strcmp(dirname, SYSFS_DEVICES_NAME) != 0)
- continue;
- for (curl = cur->links; curl != NULL; curl = nextl) {
- nextl = curl->next;
- bdev = sysfs_open_device(curl->target->path);
- if (bdev == NULL) {
- dprintf(stderr, "Error opening device at %s\n",
- curl->target->path);
+ memset(path, 0, SYSFS_PATH_MAX);
+ safestrcpy(path, bus->path);
+ safestrcat(path, "/");
+ safestrcat(path, SYSFS_DEVICES_NAME);
+
+ linklist = read_dir_links(path);
+ if (linklist) {
+ dlist_for_each_data(linklist, curlink, char) {
+ if (bus->devices) {
+ dev = (struct sysfs_device *)
+ dlist_find_custom(bus->devices,
+ (void *)curlink, name_equal);
+ if (dev)
+ continue;
+ }
+ safestrcpy(devpath, path);
+ safestrcat(devpath, "/");
+ safestrcat(devpath, curlink);
+ if (sysfs_get_link(devpath, target, SYSFS_PATH_MAX)) {
+ dprintf("Error getting link - %s\n", devpath);