Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp5055443ima; Tue, 5 Feb 2019 05:47:08 -0800 (PST) X-Google-Smtp-Source: AHgI3IbAstrNCmlI3sh9j2JWNrCabwkRL7L+FCeK/b6jQSSqLChLP3aFyXgqIj63VA+udBjlSik/ X-Received: by 2002:a17:902:b489:: with SMTP id y9mr5277937plr.193.1549374428275; Tue, 05 Feb 2019 05:47:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549374428; cv=none; d=google.com; s=arc-20160816; b=Hy7SrMNFCLSiexyPnB/bkYko/PWJC0UTktO9xA5fK8xIK8cSlZd4f+lBaL5lVVW1PE 23FdwX9nnu2GPe5sH27I9rK+9Fx3hLb5IyC7aVjffwb6tpDWd4aZuN0CUatu5kpcTToj WrSFwphe7DATICXx1/VrQsPJQrYPP4zdaolCt4IHGjLE+AhSDkzN9iEMISxx57G1nPXd 7Gbank3L+nH42jyN/NO27vdeyx1caNwMmt40dQBKJaTzfbp6usUJ6yA5n+TaAdo1Ui0a zS4mScgYPgMSWOP8ae9Xviekwk8iDw5s2prtnqfelVt0l8TygHH3Hobhpq0IQ36M/80U PDLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=KoRsXRfVeZtqWZ9UsHRDHpR69l76fX51f0E7he/KcXU=; b=h3EMxUMrOXA5JyfIWNPN40NHhbN0a6ng+mDya/5mo3zGQMWD8rDEytLrL8LLIbO1ij iVAsH1meEGcuxK22W3LSz4gq2W0B7bGW2iNr0eHOztVQXOTyPpz5uPyq2954uJZskWWr weUDaerHXQBKAi9bWFOQDKtz7tmk44489dbgazj/UdAzMIFN0rgCOk+Bw7jG02A5qpg1 rRE0Scn9UvWUF0nZiE8lRbyP4lsBDo2sIiuYxsCTlKmmZOwj3nlZLzVPjnJUnETmzG5T S1qUFEevjUdmdVHr6i2VJC5cFto29KVCAwL8bfTes+DFmuytaQv8hy/MAeQB4wbeiEyd 4OsQ== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b6si3152271pgg.2.2019.02.05.05.46.52; Tue, 05 Feb 2019 05:47:08 -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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729591AbfBENi5 (ORCPT + 99 others); Tue, 5 Feb 2019 08:38:57 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49150 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729363AbfBENi5 (ORCPT ); Tue, 5 Feb 2019 08:38:57 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ED57E19CBF3; Tue, 5 Feb 2019 13:38:56 +0000 (UTC) Received: from krava (unknown [10.43.17.224]) by smtp.corp.redhat.com (Postfix) with SMTP id 9D1F783B85; Tue, 5 Feb 2019 13:38:54 +0000 (UTC) Date: Tue, 5 Feb 2019 14:38:53 +0100 From: Jiri Olsa To: Alexey Budankov Cc: Jiri Olsa , Arnaldo Carvalho de Melo , lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Adrian Hunter , Andi Kleen , Stephane Eranian Subject: Re: [PATCH 01/14] perf tools: Make rm_rf to remove single file Message-ID: <20190205133853.GG4794@krava> References: <20190203153018.9650-1-jolsa@kernel.org> <20190203153018.9650-2-jolsa@kernel.org> <6c505cd6-9b49-5c47-8e8d-5b1fa68d1a69@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6c505cd6-9b49-5c47-8e8d-5b1fa68d1a69@linux.intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 05 Feb 2019 13:38:57 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 05, 2019 at 02:33:06PM +0300, Alexey Budankov wrote: > > 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. ok, will do proper error check thanks, jirka > > - Alexey > > > + return unlink(path); > > + } > > > > while ((d = readdir(dir)) != NULL && !ret) { > > struct stat statbuf; > >