[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200914201803.GT1714160@krava>
Date: Mon, 14 Sep 2020 22:18:03 +0200
From: Jiri Olsa <jolsa@...hat.com>
To: Namhyung Kim <namhyung@...nel.org>
Cc: Jiri Olsa <jolsa@...nel.org>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
lkml <linux-kernel@...r.kernel.org>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Ingo Molnar <mingo@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Michael Petlan <mpetlan@...hat.com>,
Song Liu <songliubraving@...com>,
"Frank Ch. Eigler" <fche@...hat.com>,
Ian Rogers <irogers@...gle.com>,
Stephane Eranian <eranian@...gle.com>,
Alexey Budankov <alexey.budankov@...ux.intel.com>,
Andi Kleen <ak@...ux.intel.com>,
Adrian Hunter <adrian.hunter@...el.com>
Subject: Re: [PATCH 07/26] perf tools: Add check for existing link in buildid
dir
On Mon, Sep 14, 2020 at 02:54:36PM +0900, Namhyung Kim wrote:
> On Mon, Sep 14, 2020 at 6:05 AM Jiri Olsa <jolsa@...nel.org> wrote:
> >
> > When adding new build id link we fail if the link is already
> > there. Adding check for existing link and warn/replace the
> > link with new target.
> >
> > Signed-off-by: Jiri Olsa <jolsa@...nel.org>
> > ---
> > tools/perf/util/build-id.c | 20 +++++++++++++++++++-
> > 1 file changed, 19 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
> > index bdee4e08e60d..ecdc167aa1a0 100644
> > --- a/tools/perf/util/build-id.c
> > +++ b/tools/perf/util/build-id.c
> > @@ -751,8 +751,26 @@ int build_id_cache__add_s(const char *sbuild_id, const char *name,
> > tmp = dir_name + strlen(buildid_dir) - 5;
> > memcpy(tmp, "../..", 5);
> >
> > - if (symlink(tmp, linkname) == 0)
> > + if (symlink(tmp, linkname) == 0) {
> > err = 0;
> > + } else if (errno == EEXIST) {
> > + char path[PATH_MAX];
> > +
> > + if (readlink(linkname, path, sizeof(path)) == -1) {
> > + pr_err("Cant read link: %s\n", linkname);
>
> typo
ok
>
> > + goto out_free;
> > + }
> > + if (strcmp(tmp, path)) {
> > + pr_err("Inconsistent .debug record, updating [%s]\n",
> > + linkname);
>
> But isn't it ok to copy a binary to another location?
> There can be multiple binaries with the same build-id..
ah true.. perhaps just debug message would be good in here
previou code failed in this case, but I think we do not check on
return value in upper layer
thanks,
jirka
Powered by blists - more mailing lists