aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/path.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/path.c')
-rw-r--r--tools/perf/util/path.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/tools/perf/util/path.c b/tools/perf/util/path.c
index 933f5c6bffb4..ca56ba2dd3da 100644
--- a/tools/perf/util/path.c
+++ b/tools/perf/util/path.c
@@ -18,6 +18,7 @@
18#include <stdio.h> 18#include <stdio.h>
19#include <sys/types.h> 19#include <sys/types.h>
20#include <sys/stat.h> 20#include <sys/stat.h>
21#include <dirent.h>
21#include <unistd.h> 22#include <unistd.h>
22 23
23static char bad_path[] = "/bad-path/"; 24static char bad_path[] = "/bad-path/";
@@ -77,3 +78,16 @@ bool is_regular_file(const char *file)
77 78
78 return S_ISREG(st.st_mode); 79 return S_ISREG(st.st_mode);
79} 80}
81
82/* Helper function for filesystems that return a dent->d_type DT_UNKNOWN */
83bool is_directory(const char *base_path, const struct dirent *dent)
84{
85 char path[PATH_MAX];
86 struct stat st;
87
88 sprintf(path, "%s/%s", base_path, dent->d_name);
89 if (stat(path, &st))
90 return false;
91
92 return S_ISDIR(st.st_mode);
93}