Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp4924967ima; Tue, 5 Feb 2019 03:41:18 -0800 (PST) X-Google-Smtp-Source: AHgI3IbNH1f/lGITO+qu/XUw4XkKDgfENfM2SlFF6SdRRiP+q6zj6Qvf9TdK5ptSoIUQF8qPtoIM X-Received: by 2002:a17:902:b489:: with SMTP id y9mr4740277plr.193.1549366878214; Tue, 05 Feb 2019 03:41:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549366878; cv=none; d=google.com; s=arc-20160816; b=Bt8uiDhSQ78vLwnLqzTIzSNs2vCxZJ5YgRPAcM2eJkj8jWRF9bxYdfCLFW3Sq+SINq k+Mv+qSSCfShOfdd3AUGqlHl7SRgj+NRfz5bjuv4fqg3oFo2iS7p5MhAIYvq7iP48XJA JnkmW9m/6zE3ndhwl4S6i3iRINjZPm3o8bvVtVhXtBMk0N827dh5j2qaOqiUZ+kRO5cT VSs7kQSp+XtVR0digMHuRmrSHsOvNneXwlws/eLMd/GC4fxzEAFgaeJ+T6A8G1Y8KgEr w+/tiJUTAeZUijgVdKPhl/v2+CbnG5txgg2+T8V4SeehKPfx8FHNInGlsMDKF/P18ii1 Oo8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject; bh=QdFbd8W8TMrQYsE2i8kstjcwOfJNz+R3V6JaPUoQQEw=; b=izTS8oSLC2InU9MNUPX8abP/YEDteYtsglnqzA5EzKpVgt9Ub+Da7mFj5jge9sku7u 3wm7Dn54s4CfhaImGn7NVz2yEf+ewHuKmEsUXRRGwJvw83rsyG3Aw/Z7v/7Wcas8IQZS Wbn/+uZr19/zMS0wtAyq1OVmt9jo8IQ+ja/VqOIabiS9Zlj2HuLUSg0HwGA3S4DfxUor fPe7RJxSfFleScw5WBdAokAWfoFmz/hriW6L0CU18Q1k1hejMNqMcMYkVT4PLpjN9HAy w++2pjSJEcB9SteWSumAvQBM64BWFv6QrnUnH7lWLSMHPovxXFhXE8ttSXCKzK5aMyAw wVxA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e35si420870pgb.548.2019.02.05.03.41.02; Tue, 05 Feb 2019 03:41:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728815AbfBELdO (ORCPT + 99 others); Tue, 5 Feb 2019 06:33:14 -0500 Received: from mga04.intel.com ([192.55.52.120]:59615 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725947AbfBELdO (ORCPT ); Tue, 5 Feb 2019 06:33:14 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Feb 2019 03:33:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,563,1539673200"; d="scan'208";a="140808117" Received: from linux.intel.com ([10.54.29.200]) by fmsmga002.fm.intel.com with ESMTP; 05 Feb 2019 03:33:13 -0800 Received: from [10.125.252.139] (abudanko-mobl.ccr.corp.intel.com [10.125.252.139]) by linux.intel.com (Postfix) with ESMTP id B9D3158044E; Tue, 5 Feb 2019 03:33:10 -0800 (PST) Subject: Re: [PATCH 01/14] perf tools: Make rm_rf to remove single file To: Jiri Olsa , Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Adrian Hunter , Andi Kleen , Stephane Eranian References: <20190203153018.9650-1-jolsa@kernel.org> <20190203153018.9650-2-jolsa@kernel.org> From: Alexey Budankov Organization: Intel Corp. Message-ID: <6c505cd6-9b49-5c47-8e8d-5b1fa68d1a69@linux.intel.com> Date: Tue, 5 Feb 2019 14:33:06 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 MIME-Version: 1.0 In-Reply-To: <20190203153018.9650-2-jolsa@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03.02.2019 18:30, Jiri Olsa wrote: > Let rm_rf remove file if it's provided by path. > > Link: http://lkml.kernel.org/n/tip-whhp3ej5795l9dc86xfyyp74@git.kernel.org > Signed-off-by: Jiri Olsa > --- > tools/perf/util/util.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c > index 320b0fef249a..58b8d6a8bfbc 100644 > --- a/tools/perf/util/util.c > +++ b/tools/perf/util/util.c > @@ -125,8 +125,14 @@ int rm_rf(const char *path) > char namebuf[PATH_MAX]; > > dir = opendir(path); > - if (dir == NULL) > - return 0; > + if (dir == NULL) { > + /* > + * The path does not exist or is not directory, > + * so there's no harm to try remove it. This way > + * rm_rf will work over single file. > + */ This can also happen due to lack of fds or memory. Not sure file still has to be deleted in these cases. - Alexey > + return unlink(path); > + } > > while ((d = readdir(dir)) != NULL && !ret) { > struct stat statbuf; >