+ memset(path, 0, SYSFS_PATH_MAX);
+ safestrcpy(path, ((struct sysfs_device *)dev)->path);
+ dir = opendir(path);
+ if (!dir) {
+ dprintf("Error opening directory %s\n", path);
+ return NULL;
+ }
+ while ((dirent = readdir(dir)) != NULL) {
+ if (0 == strcmp(dirent->d_name, "."))
+ continue;
+ if (0 == strcmp(dirent->d_name, ".."))
+ continue;
+ memset(file_path, 0, SYSFS_PATH_MAX);
+ safestrcpy(file_path, path);
+ safestrcat(file_path, "/");
+ safestrcat(file_path, dirent->d_name);
+ if (!sysfs_path_is_file(file_path)) {
+ if (((struct sysfs_device *)dev)->attrlist) {
+ /* check if attr is already in the list */
+ attr = (struct sysfs_attribute *)
+ dlist_find_custom
+ ((((struct sysfs_device *)dev)->attrlist),
+ (void *)dirent->d_name, attr_name_equal);
+ if (attr)
+ continue;
+ else
+ add_attribute(dev, file_path);
+ } else
+ attr = add_attribute(dev, file_path);