diff options
author | Masami Hiramatsu | 2016-04-26 11:02:42 +0200 |
---|---|---|
committer | Arnaldo Carvalho de Melo | 2016-04-26 18:14:55 +0200 |
commit | e1ce726e1db2522b4848b3acffb7ece12439517c (patch) | |
tree | 4aa431756eb86d941aeffd06d955a681c3a3eb8d /tools/perf/util/util.h | |
parent | perf probe: Close target file on error path (diff) | |
download | kernel-qcow2-linux-e1ce726e1db2522b4848b3acffb7ece12439517c.tar.gz kernel-qcow2-linux-e1ce726e1db2522b4848b3acffb7ece12439517c.tar.xz kernel-qcow2-linux-e1ce726e1db2522b4848b3acffb7ece12439517c.zip |
perf tools: Add lsdir() helper to read a directory
As a utility function, add lsdir() which reads given directory and store
entry name into a strlist. lsdir accepts a filter function so that user
can filter out unneeded entries.
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20160426090242.11891.79014.stgit@devbox
[ Do not use the 'dirname' it is used in some distros ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/util.h')
-rw-r--r-- | tools/perf/util/util.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 3bf3de86d429..26a924651e7b 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -79,6 +79,7 @@ #include <termios.h> #include <linux/bitops.h> #include <termios.h> +#include "strlist.h" extern const char *graph_line; extern const char *graph_dotted_line; @@ -222,6 +223,8 @@ static inline int sane_case(int x, int high) int mkdir_p(char *path, mode_t mode); int rm_rf(char *path); +struct strlist *lsdir(const char *name, bool (*filter)(const char *, struct dirent *)); +bool lsdir_no_dot_filter(const char *name, struct dirent *d); int copyfile(const char *from, const char *to); int copyfile_mode(const char *from, const char *to, mode_t mode); int copyfile_offset(int fromfd, loff_t from_ofs, int tofd, loff_t to_ofs, u64 size); |