- struct dirent *dirent = readdir(dir);
- while(dirent != NULL){
- if (strncmp(dirent->d_name, dirent_start_text, dirent_start_len) == 0){
- struct hugepage_info *hpi = \
- &internal_config.hugepage_info[num_sizes];
- hpi->hugepage_sz = rte_str_to_size(&dirent->d_name[dirent_start_len]);
- hpi->hugedir = get_hugepage_dir(hpi->hugepage_sz);
-
- /* first, check if we have a mountpoint */
- if (hpi->hugedir == NULL){
- int32_t num_pages;
- if ((num_pages = get_num_hugepages(dirent->d_name)) > 0)
- RTE_LOG(INFO, EAL, "%u hugepages of size %llu reserved, "\
- "but no mounted hugetlbfs found for that size\n",
- (unsigned)num_pages,
- (unsigned long long)hpi->hugepage_sz);
- } else {
- /* try to obtain a writelock */
- hpi->lock_descriptor = open(hpi->hugedir, O_RDONLY);
-
- /* if blocking lock failed */
- if (flock(hpi->lock_descriptor, LOCK_EX) == -1) {
- RTE_LOG(CRIT, EAL, "Failed to lock hugepage directory!\n");
- closedir(dir);
- return -1;
- }
- /* clear out the hugepages dir from unused pages */
- if (clear_hugedir(hpi->hugedir) == -1) {
- closedir(dir);
- return -1;
- }