From 2e0b1e375cf53d92c8ec11e92c1d8fb03057358a Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 11 Oct 2018 12:17:55 +0200 Subject: [PATCH] 4.14-stable patches added patches: perf-utils-move-is_directory-to-path.h.patch --- ...rf-utils-move-is_directory-to-path.h.patch | 102 ++++++++++++++++++ queue-4.14/series | 1 + 2 files changed, 103 insertions(+) create mode 100644 queue-4.14/perf-utils-move-is_directory-to-path.h.patch diff --git a/queue-4.14/perf-utils-move-is_directory-to-path.h.patch b/queue-4.14/perf-utils-move-is_directory-to-path.h.patch new file mode 100644 index 00000000000..6a21b562f0c --- /dev/null +++ b/queue-4.14/perf-utils-move-is_directory-to-path.h.patch @@ -0,0 +1,102 @@ +From 06c3f2aa9fc68e7f3fe3d83e7569d2a2801d9f99 Mon Sep 17 00:00:00 2001 +From: Jiri Olsa +Date: Wed, 6 Dec 2017 18:45:35 +0100 +Subject: perf utils: Move is_directory() to path.h + +From: Jiri Olsa + +commit 06c3f2aa9fc68e7f3fe3d83e7569d2a2801d9f99 upstream. + +So that it can be used more widely, like in the next patch, when it will +be used to fix a bug in 'perf test' handling of dirent.d_type == +DT_UNKNOWN. + +Signed-off-by: Jiri Olsa +Cc: David Ahern +Cc: Michael Petlan +Cc: Namhyung Kim +Cc: Peter Zijlstra +Link: http://lkml.kernel.org/r/20171206174535.25380-1-jolsa@kernel.org +[ Split from a larger patch, removed needless includes in path.h ] +Signed-off-by: Arnaldo Carvalho de Melo +Cc: Ignat Korchagin +Signed-off-by: Greg Kroah-Hartman + +--- + tools/perf/builtin-script.c | 14 +------------- + tools/perf/util/path.c | 14 ++++++++++++++ + tools/perf/util/path.h | 3 +++ + 3 files changed, 18 insertions(+), 13 deletions(-) + +--- a/tools/perf/builtin-script.c ++++ b/tools/perf/builtin-script.c +@@ -25,6 +25,7 @@ + #include "util/string2.h" + #include "util/thread-stack.h" + #include "util/time-utils.h" ++#include "util/path.h" + #include "print_binary.h" + #include + #include +@@ -2129,19 +2130,6 @@ out: + return rc; + } + +-/* Helper function for filesystems that return a dent->d_type DT_UNKNOWN */ +-static int is_directory(const char *base_path, const struct dirent *dent) +-{ +- char path[PATH_MAX]; +- struct stat st; +- +- sprintf(path, "%s/%s", base_path, dent->d_name); +- if (stat(path, &st)) +- return 0; +- +- return S_ISDIR(st.st_mode); +-} +- + #define for_each_lang(scripts_path, scripts_dir, lang_dirent) \ + while ((lang_dirent = readdir(scripts_dir)) != NULL) \ + if ((lang_dirent->d_type == DT_DIR || \ +--- a/tools/perf/util/path.c ++++ b/tools/perf/util/path.c +@@ -18,6 +18,7 @@ + #include + #include + #include ++#include + #include + + static char bad_path[] = "/bad-path/"; +@@ -77,3 +78,16 @@ bool is_regular_file(const char *file) + + return S_ISREG(st.st_mode); + } ++ ++/* Helper function for filesystems that return a dent->d_type DT_UNKNOWN */ ++bool is_directory(const char *base_path, const struct dirent *dent) ++{ ++ char path[PATH_MAX]; ++ struct stat st; ++ ++ sprintf(path, "%s/%s", base_path, dent->d_name); ++ if (stat(path, &st)) ++ return false; ++ ++ return S_ISDIR(st.st_mode); ++} +--- a/tools/perf/util/path.h ++++ b/tools/perf/util/path.h +@@ -2,9 +2,12 @@ + #ifndef _PERF_PATH_H + #define _PERF_PATH_H + ++struct dirent; ++ + int path__join(char *bf, size_t size, const char *path1, const char *path2); + int path__join3(char *bf, size_t size, const char *path1, const char *path2, const char *path3); + + bool is_regular_file(const char *file); ++bool is_directory(const char *base_path, const struct dirent *dent); + + #endif /* _PERF_PATH_H */ diff --git a/queue-4.14/series b/queue-4.14/series index 1827718486d..cf060db0908 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -35,3 +35,4 @@ powerpc-avoid-code-patching-freed-init-sections.patch powerpc-lib-fix-book3s-32-boot-failure-due-to-code-patching.patch arc-clone-syscall-to-setp-r25-as-thread-pointer.patch crypto-chelsio-fix-memory-corruption-in-dma-mapped-buffers.patch +perf-utils-move-is_directory-to-path.h.patch -- 2.47.2