- sub = (struct sysfs_directory *)dlist_find_custom(dir->subdirs,
- subname, dir_subdir_name_equal);
- if (sub != NULL)
- return sub;
-
- if (dir->subdirs != NULL) {
- dlist_for_each_data(dir->subdirs, cursub,
- struct sysfs_directory) {
- if (cursub->subdirs == NULL)
- continue;
- sub = sysfs_get_subdirectory(cursub, subname);
- if (sub != NULL)
- return sub;
- }
- }
- return NULL;
-}
-
-/**
- * sysfs_get_subdirectory_link: looks through all subdirs for specific link.
- * @dir: directory and subdirectories to search for link.
- * @linkname: link name to get.
- * returns reference to link or NULL if not found
- */
-struct sysfs_link *sysfs_get_subdirectory_link(struct sysfs_directory *dir,
- unsigned char *linkname)
-{
- struct sysfs_directory *cursub = NULL;
- struct sysfs_link *ln = NULL;
-
- if (dir == NULL || dir->links == NULL || linkname == NULL) {
- errno = EINVAL;
- return NULL;
- }
-
- ln = sysfs_get_directory_link(dir, linkname);
- if (ln != NULL)
- return ln;
-
- if (dir->subdirs == NULL)
- return NULL;
-
- if (dir->subdirs != NULL) {
- dlist_for_each_data(dir->subdirs, cursub,
- struct sysfs_directory) {
- if (cursub->subdirs == NULL)
- continue;
- ln = sysfs_get_subdirectory_link(cursub, linkname);
- if (ln != NULL)
- return ln;
+ 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)) == 0) {
+ 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);