* [PATCH] perf buildid-cache: option -p does not delete anything
@ 2017-10-17 6:38 Thomas Richter
0 siblings, 0 replies; only message in thread
From: Thomas Richter @ 2017-10-17 6:38 UTC (permalink / raw)
To: acme, linux-perf-users; +Cc: brueckner, schwidefsky, Thomas Richter
Command perf buildid-cache -p <path> should delete all entries
in the buildid cache which start with path. However this does not happen.
When perf buildid-cache -p /usr/bin is invoked, tracing shows in detail
function
build_id_cache__purge_path() is called and
build_id_cache__list_build_ids() creates a list of file names
located in directory /usr/bin of the buildid-cache.
build_id_cache__remove_s() is called for each name in the list
and tries to locate each file name
in directory .buildid/YY/ZZZ..ZZZ which fails because
build_id_cache__linkname() expects a buildid and gets a file name.
The file name bash is treated as .buildid/ba/sh which does not exist.
Fix this by walking along the specified path and test for the
object type. If it is a directory, scan this subdirectory.
If this is a file, convert the file name to a buildid and
call function build_id_cache__remove_file().
Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
---
tools/perf/builtin-buildid-cache.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c
index e3eb624..bcd2b0e 100644
--- a/tools/perf/builtin-buildid-cache.c
+++ b/tools/perf/builtin-buildid-cache.c
@@ -8,6 +8,7 @@
*/
#include <sys/types.h>
#include <sys/time.h>
+#include <sys/stat.h>
#include <time.h>
#include <dirent.h>
#include <errno.h>
@@ -197,6 +198,7 @@ static int build_id_cache__remove_file(const char *filename, struct nsinfo *nsi)
int err;
+//printf("%s filename:%s\n", __func__, filename);
nsinfo__mountns_enter(nsi, &nsc);
err = filename__read_build_id(filename, &build_id, sizeof(build_id));
nsinfo__mountns_exit(&nsc);
@@ -224,8 +226,18 @@ static int build_id_cache__purge_path(const char *pathname, struct nsinfo *nsi)
goto out;
strlist__for_each_entry(pos, list) {
- err = build_id_cache__remove_s(pos->s);
- pr_debug("Removing %s %s: %s\n", pos->s, pathname,
+ char filename[PATH_MAX];
+ struct stat st;
+
+ scnprintf(filename, sizeof(filename), "%s/%s",
+ pathname, pos->s);
+ if (stat(filename, &st))
+ continue;
+ if (S_ISDIR(st.st_mode))
+ err = build_id_cache__purge_path(filename, nsi);
+ else
+ err = build_id_cache__remove_file(filename, nsi);
+ pr_debug("Removing %s %s: %s\n", filename, pathname,
err ? "FAIL" : "Ok");
if (err)
break;
--
2.9.4
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2017-10-17 6:38 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-17 6:38 [PATCH] perf buildid-cache: option -p does not delete anything Thomas Richter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).