MCPcopy Create free account
hub / github.com/F-Stack/f-stack / fsdev_find_all_devs

Function fsdev_find_all_devs

dpdk/drivers/crypto/bcmfs/bcmfs_device.c:175–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173}
174
175static int
176fsdev_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
209static bool
210fsdev_find_sub_dir(char *path, const char *search, char *output)

Callers 1

bcmfs_vdev_probeFunction · 0.85

Calls 7

opendirFunction · 0.85
readdirFunction · 0.85
strstrFunction · 0.85
closedirFunction · 0.85
strtoulFunction · 0.85
qsortFunction · 0.85
strlcpyFunction · 0.50

Tested by

no test coverage detected