lkml.org 
[lkml]   [2020]   [Sep]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    Date
    SubjectRe: [PATCH 07/26] perf tools: Add check for existing link in buildid dir
    On Mon, Sep 14, 2020 at 6:05 AM Jiri Olsa <jolsa@kernel.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@kernel.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

    > + 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..

    Thanks
    Namhyung


    > +
    > + unlink(linkname);
    > +
    > + if (symlink(tmp, linkname))
    > + goto out_free;
    > + }
    > + err = 0;
    > + }
    >
    > /* Update SDT cache : error is just warned */
    > if (realname &&
    > --
    > 2.26.2
    >

    \
     
     \ /
      Last update: 2020-09-14 07:55    [W:4.417 / U:0.004 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site