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

Function eal_clean_runtime_dir

dpdk/lib/eal/linux/eal.c:82–166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80
81
82int
83eal_clean_runtime_dir(void)
84{
85 const char *runtime_dir = rte_eal_get_runtime_dir();
86 DIR *dir;
87 struct dirent *dirent;
88 int dir_fd, fd, lck_result;
89 static const char * const filters[] = {
90 "fbarray_*",
91 "mp_socket_*"
92 };
93
94 /* open directory */
95 dir = opendir(runtime_dir);
96 if (!dir) {
97 RTE_LOG(ERR, EAL, "Unable to open runtime directory %s\n",
98 runtime_dir);
99 goto error;
100 }
101 dir_fd = dirfd(dir);
102
103 /* lock the directory before doing anything, to avoid races */
104 if (flock(dir_fd, LOCK_EX) < 0) {
105 RTE_LOG(ERR, EAL, "Unable to lock runtime directory %s\n",
106 runtime_dir);
107 goto error;
108 }
109
110 dirent = readdir(dir);
111 if (!dirent) {
112 RTE_LOG(ERR, EAL, "Unable to read runtime directory %s\n",
113 runtime_dir);
114 goto error;
115 }
116
117 while (dirent != NULL) {
118 unsigned int f_idx;
119 bool skip = true;
120
121 /* skip files that don't match the patterns */
122 for (f_idx = 0; f_idx < RTE_DIM(filters); f_idx++) {
123 const char *filter = filters[f_idx];
124
125 if (fnmatch(filter, dirent->d_name, 0) == 0) {
126 skip = false;
127 break;
128 }
129 }
130 if (skip) {
131 dirent = readdir(dir);
132 continue;
133 }
134
135 /* try and lock the file */
136 fd = openat(dir_fd, dirent->d_name, O_RDONLY);
137
138 /* skip to next file */
139 if (fd == -1) {

Callers 1

rte_eal_initFunction · 0.70

Calls 7

rte_eal_get_runtime_dirFunction · 0.85
opendirFunction · 0.85
readdirFunction · 0.85
closedirFunction · 0.85
flockClass · 0.70
fnmatchFunction · 0.50
closeFunction · 0.50

Tested by

no test coverage detected