int fd;
unsigned i;
void *virtaddr;
- struct flock lck = {0};
#ifdef RTE_EAL_NUMA_AWARE_HUGEPAGES
int node_id = -1;
int essential_prev = 0;
}
*(int *)virtaddr = 0;
-
/* set shared lock on the file. */
- lck.l_type = F_RDLCK;
- lck.l_whence = SEEK_SET;
- lck.l_start = 0;
- lck.l_len = hugepage_sz;
- if (fcntl(fd, F_SETLK, &lck) == -1) {
+ if (flock(fd, LOCK_SH) < 0) {
RTE_LOG(DEBUG, EAL, "%s(): Locking file failed:%s \n",
__func__, strerror(errno));
close(fd);
#endif
struct hugepage_file *hfile = &hugepages[cur_page];
struct rte_memseg *ms = rte_fbarray_get(arr, ms_idx);
- struct flock lck;
void *addr;
int fd;
return -1;
}
/* set shared lock on the file. */
- lck.l_type = F_RDLCK;
- lck.l_whence = SEEK_SET;
- lck.l_start = 0;
- lck.l_len = page_sz;
- if (fcntl(fd, F_SETLK, &lck) == -1) {
+ if (flock(fd, LOCK_SH) < 0) {
RTE_LOG(DEBUG, EAL, "Could not lock '%s': %s\n",
hfile->filepath, strerror(errno));
close(fd);
}
/* create shared memory */
- hugepage = create_shared_memory(eal_hugepage_file_path(),
+ hugepage = create_shared_memory(eal_hugepage_data_path(),
nr_hugefiles * sizeof(struct hugepage_file));
if (hugepage == NULL) {
test_phys_addrs_available();
- fd_hugepage = open(eal_hugepage_file_path(), O_RDONLY);
+ fd_hugepage = open(eal_hugepage_data_path(), O_RDONLY);
if (fd_hugepage < 0) {
- RTE_LOG(ERR, EAL, "Could not open %s\n", eal_hugepage_file_path());
+ RTE_LOG(ERR, EAL, "Could not open %s\n",
+ eal_hugepage_data_path());
goto error;
}
size = getFileSize(fd_hugepage);
hp = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd_hugepage, 0);
if (hp == MAP_FAILED) {
- RTE_LOG(ERR, EAL, "Could not mmap %s\n", eal_hugepage_file_path());
+ RTE_LOG(ERR, EAL, "Could not mmap %s\n",
+ eal_hugepage_data_path());
goto error;
}
struct hugepage_file *hf = &hp[i];
size_t map_sz = hf->size;
void *map_addr = hf->final_va;
- struct flock lck;
/* if size is zero, no more pages left */
if (map_sz == 0)
}
/* set shared lock on the file. */
- lck.l_type = F_RDLCK;
- lck.l_whence = SEEK_SET;
- lck.l_start = 0;
- lck.l_len = map_sz;
- if (fcntl(fd, F_SETLK, &lck) == -1) {
+ if (flock(fd, LOCK_SH) < 0) {
RTE_LOG(DEBUG, EAL, "%s(): Locking file failed: %s\n",
__func__, strerror(errno));
close(fd);