| 173 | } |
| 174 | |
| 175 | static int |
| 176 | fsdev_find_all_devs(const char *path, const char *search, |
| 177 | uint32_t *devs) |
| 178 | { |
| 179 | DIR *dir; |
| 180 | struct dirent *entry; |
| 181 | int count = 0; |
| 182 | char addr[BCMFS_MAX_NODES][BCMFS_MAX_PATH_LEN]; |
| 183 | int i; |
| 184 | |
| 185 | dir = opendir(path); |
| 186 | if (dir == NULL) { |
| 187 | BCMFS_LOG(ERR, "Unable to open directory"); |
| 188 | return 0; |
| 189 | } |
| 190 | |
| 191 | while ((entry = readdir(dir)) != NULL) { |
| 192 | if (strstr(entry->d_name, search)) { |
| 193 | strlcpy(addr[count], entry->d_name, |
| 194 | BCMFS_MAX_PATH_LEN); |
| 195 | count++; |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | closedir(dir); |
| 200 | |
| 201 | for (i = 0 ; i < count; i++) |
| 202 | devs[i] = (uint32_t)strtoul(addr[i], NULL, 16); |
| 203 | /* sort the devices based on IO addresses */ |
| 204 | qsort(devs, count, sizeof(uint32_t), cmprator); |
| 205 | |
| 206 | return count; |
| 207 | } |
| 208 | |
| 209 | static bool |
| 210 | fsdev_find_sub_dir(char *path, const char *search, char *output) |