258{
260 char lustre_dir[PATH_MAX];
261 char path[PATH_MAX];
262 char path_readahead[PATH_MAX],path_stats[PATH_MAX];
263 char *ptr;
264 char fs_name[100];
265 int found_luster_fs = 0;
266 int idx = 0;
267 int tmp_fd;
268 DIR *proc_dir;
269 struct dirent *entry;
270
272
273 proc_dir = opendir( lustre_dir );
274 if ( proc_dir == NULL ) {
275 SUBDBG(
"EXIT: PAPI_ESYS (Cannot open %s)\n",lustre_dir);
277 }
278
279 while ( (entry = readdir( proc_dir )) != NULL ) {
280 memset( path, 0, PATH_MAX );
281 snprintf( path, PATH_MAX - 1, "%s/%s/stats", lustre_dir,
282 entry->d_name );
283 SUBDBG(
"checking for file %s\n", path);
284
285 if ( ( tmp_fd =
open( path, O_RDONLY ) ) == -1 ) {
286 SUBDBG(
"Path: %s, can not be opened.\n", path);
287 continue;
288 }
289
291
292
293
294
295 idx = strlen( path );
296 idx--;
297
298 while ( path[idx] == '\r' || path[idx] == '\n' )
299 path[idx--] = 0;
300
301
302
303 ptr = strstr(path,"llite/") + 6;
304 if (ptr == NULL) {
305 SUBDBG(
"Path: %s, missing llite directory, performance event not created.\n", path);
306 continue;
307 }
308
309 strncpy(fs_name, ptr, sizeof(fs_name)-1);
310 fs_name[sizeof(fs_name)-1] = '\0';
311
312 SUBDBG(
"found Lustre FS: %s\n", fs_name);
313
314 snprintf( path_stats, PATH_MAX - 1,
315 "%s/%s/stats",
316 lustre_dir,
317 entry->d_name );
318 SUBDBG(
"Found file %s\n", path_stats);
319
320 snprintf( path_readahead, PATH_MAX - 1,
321 "%s/%s/read_ahead_stats",
322 lustre_dir,
323 entry->d_name );
324 SUBDBG(
"Now checking for file %s\n", path_readahead);
325
326 strcpy( ptr, "read_ahead_stats" );
327 addLustreFS( fs_name, path_stats, path_readahead );
328 found_luster_fs++;
329 }
330 closedir( proc_dir );
331
332 if (found_luster_fs == 0) {
333 SUBDBG(
"EXIT: PAPI_ESYS (No luster file systems found)\n");
335 }
336
337 SUBDBG(
"EXIT: PAPI_OK\n");
339}
int open(const char *pathname, int flags, mode_t mode)
const char proc_base_path[]
static int addLustreFS(const char *name, const char *procpath_general, const char *procpath_readahead)