X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_eal%2Flinuxapp%2Feal%2Feal_hugepage_info.c;h=7eca711ba72bfc00d04001cab527d64c5a112146;hb=1a7dc2252f28;hp=485a89e12ddef1ae804b790f1023e74233c53459;hpb=046aa5c4477bbd61718317e9c115c5d3ed42eabf;p=dpdk.git diff --git a/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c b/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c index 485a89e12d..7eca711ba7 100644 --- a/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c +++ b/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c @@ -236,18 +236,6 @@ get_hugepage_dir(uint64_t hugepage_sz, char *hugedir, int len) return retval; } -/* - * uses fstat to report the size of a file on disk - */ -static off_t -get_file_size(int fd) -{ - struct stat st; - if (fstat(fd, &st) < 0) - return 0; - return st.st_size; -} - /* * Clear the hugepage directory of whatever hugepage files * there are. Checks if the file is locked (i.e. @@ -278,8 +266,6 @@ clear_hugedir(const char * hugedir) } while(dirent != NULL){ - struct flock lck = {0}; - /* skip files that don't match the hugepage pattern */ if (fnmatch(filter, dirent->d_name, 0) > 0) { dirent = readdir(dir); @@ -296,14 +282,9 @@ clear_hugedir(const char * hugedir) } /* non-blocking lock */ - lck.l_type = F_RDLCK; - lck.l_whence = SEEK_SET; - lck.l_start = 0; - lck.l_len = get_file_size(fd); - - lck_result = fcntl(fd, F_SETLK, &lck); + lck_result = flock(fd, LOCK_EX | LOCK_NB); - /* if lock succeeds, unlock and remove the file */ + /* if lock succeeds, remove the file */ if (lck_result != -1) unlinkat(dir_fd, dirent->d_name, 0); close (fd);