diff options
Diffstat (limited to 'tools/perf/util')
| -rw-r--r-- | tools/perf/util/path.c | 10 | ||||
| -rw-r--r-- | tools/perf/util/path.h | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/tools/perf/util/path.c b/tools/perf/util/path.c index 00adf872bf00..9712466c51e2 100644 --- a/tools/perf/util/path.c +++ b/tools/perf/util/path.c @@ -68,6 +68,16 @@ bool is_directory(const char *base_path, const struct dirent *dent) return S_ISDIR(st.st_mode); } +bool is_directory_at(int dir_fd, const char *path) +{ + struct stat st; + + if (fstatat(dir_fd, path, &st, /*flags=*/0)) + return false; + + return S_ISDIR(st.st_mode); +} + bool is_executable_file(const char *base_path, const struct dirent *dent) { char path[PATH_MAX]; diff --git a/tools/perf/util/path.h b/tools/perf/util/path.h index d94902c22222..fbafbe7015dd 100644 --- a/tools/perf/util/path.h +++ b/tools/perf/util/path.h @@ -12,6 +12,7 @@ int path__join3(char *bf, size_t size, const char *path1, const char *path2, con bool is_regular_file(const char *file); bool is_directory(const char *base_path, const struct dirent *dent); +bool is_directory_at(int dir_fd, const char *path); bool is_executable_file(const char *base_path, const struct dirent *dent); #endif /* _PERF_PATH_H */ |
