Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp174603pxb; Wed, 18 Nov 2020 01:13:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJzgDhx3o5GUumCpbn1vLHksRuxgy+gkP2lvEou/EYat/IOopkziFsTEFwmb3lTKf+A1TuLm X-Received: by 2002:a17:906:1408:: with SMTP id p8mr22736126ejc.548.1605690804028; Wed, 18 Nov 2020 01:13:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605690804; cv=none; d=google.com; s=arc-20160816; b=Ar4KJn2AUvsoIW5G+dd7stx/bCzdGJMBYKBEIRsMPmijdfMcjM/g4xVeWFRI52x57T ZAHNk5q0M8R16MfMu/8tjfZfI1duvuv2XMT7l2CCgdqxzP4962kI8pvb8tcOzpvbAxKD XWGil1Po/IfRXezye4yVFJCwCndyVvb6m4Slcy0oquTllaH/e1pRvGIQEhWOxr4rNIMX WGDD6XsdeiWtJcPJ+LHPa8PqZDatA9gHN6LvMo+cOO4NvuorVWtOQi8yxm/0RPJz8RjZ G4ZDUkcl2XZZXhodF1WcSCfsH+5hZVuKx/7yIk9oT42QzyzvQhIF3I/CR7mbU+aAgads BVnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=IenbdPhxUN8brxJqNOuUgnVQ/injsj1TCtnNbMXKNLU=; b=T0mffJLWUNfkzyw52D/1URY/mQESdHOEAROcPVr6oF8HzJEfLsbrn5rbcau6zOEB9W //uDoKf4p73Lye/17U81xl3037gtWFjVQ7Ly8ZD4Gy7czH/sX/fB8voc0rgQcFoT5kzw AbPUSm5IT4GI36/A40pViSoj3gRzqOeJyVE08D0ac83qriIrfOH3A5tRQAdT87uAjzJG 3VBdVKSZ8P5Apx0XCO+eCLJjxYnqVSg9hMXLzkSZW6Geazv8YlKr8tVXrDHwXzEhvEoC c2TXST3YG7O59DiQRB0WOh4ydcn+QKToPlR3ARtTkmcSQ4kosRwbwiP20EqWis4AasOd Y+QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Tq1Kp3mn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g19si189952ejz.473.2020.11.18.01.13.01; Wed, 18 Nov 2020 01:13:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Tq1Kp3mn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726950AbgKRJLf (ORCPT + 99 others); Wed, 18 Nov 2020 04:11:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:36904 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725767AbgKRJLe (ORCPT ); Wed, 18 Nov 2020 04:11:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605690693; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=IenbdPhxUN8brxJqNOuUgnVQ/injsj1TCtnNbMXKNLU=; b=Tq1Kp3mnEJoe6yIMtzJZdh+rEHlD8fLWnGtdI5esCmqin6Ac+uPyAJtfCbw/lhRgMDgxw5 lAqwQVQ++SCiYRnVOMroFSIvQrh3LQ7toP1x7Wm16bx3v1hvQxQ0OCMo3ZE5GHG1WPVboN H7iTBFpdhzBS6v73kb6LCnryboUQuq8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-446-MBEwqdxHOB-E55Prs2kafA-1; Wed, 18 Nov 2020 04:11:31 -0500 X-MC-Unique: MBEwqdxHOB-E55Prs2kafA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 374E1D8EC1; Wed, 18 Nov 2020 09:11:29 +0000 (UTC) Received: from krava (unknown [10.40.193.155]) by smtp.corp.redhat.com (Postfix) with SMTP id E0DB2196FD; Wed, 18 Nov 2020 09:11:25 +0000 (UTC) Date: Wed, 18 Nov 2020 10:11:24 +0100 From: Jiri Olsa To: Ian Rogers Cc: Jiri Olsa , Arnaldo Carvalho de Melo , lkml , Peter Zijlstra , Ingo Molnar , Mark Rutland , Namhyung Kim , Alexander Shishkin , Michael Petlan , Song Liu , Stephane Eranian , Alexey Budankov , Andi Kleen , Adrian Hunter Subject: Re: [PATCH 09/24] perf tools: Add check for existing link in buildid dir Message-ID: <20201118091124.GA1414446@krava> References: <20201117110053.1303113-1-jolsa@kernel.org> <20201117110053.1303113-10-jolsa@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 17, 2020 at 01:23:09PM -0800, Ian Rogers wrote: > On Tue, Nov 17, 2020 at 3:01 AM Jiri Olsa wrote: > > > When adding new build id link we fail if the link is already > > there. Adding check for existing link and output debug message > > that the build id is already linked. > > > > Signed-off-by: Jiri Olsa > > --- > > tools/perf/util/build-id.c | 15 ++++++++++++++- > > 1 file changed, 14 insertions(+), 1 deletion(-) > > > > diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c > > index 7d9ecc37849c..ef9a31b54ba2 100644 > > --- a/tools/perf/util/build-id.c > > +++ b/tools/perf/util/build-id.c > > @@ -754,8 +754,21 @@ 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); > > + goto out_free; > > + } > > > > readlink needs null termination, such as: > https://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git/tree/tools/perf/util/build-id.c?h=perf/core#n212 will fix, thanks jirka > > Thanks, > Ian > > + if (strcmp(tmp, path)) { > > + pr_debug("build <%s> already linked to %s\n", > > + sbuild_id, linkname); > > + } > > + err = 0; > > + } > > > > /* Update SDT cache : error is just warned */ > > if (realname && > > -- > > 2.26.2 > > > >