Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp2876202ima; Sun, 3 Feb 2019 08:34:14 -0800 (PST) X-Google-Smtp-Source: ALg8bN7zbJHQQSSRELe4wV+dxpSJfdMM+ktx9JiDPLNbpE6a5fk6yyiGWBu2/SOE4vE1c7oebDiF X-Received: by 2002:a63:b649:: with SMTP id v9mr43509873pgt.436.1549211654014; Sun, 03 Feb 2019 08:34:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549211653; cv=none; d=google.com; s=arc-20160816; b=lhA9JIxD45CEMyY6CJ56xuqc+iFcPGF1jqS5Ms98ywTzyzlXmyEdaBCp8L/WMOKTdW +Mk5Ma7xkkcFj9x0LDd+xHHgf8LJ932J2iWlZU4xWVN/+EmzxtbTclltTVKEt+80vWl6 9mTVaqCPstFufGlLgQGyV3i+JqVnrIgdJIYbtPE0boDTQ11beCslcpFBwhzxYwykNWaQ lxrRlajPgsi69rkf/VNHcR7uB7HbTyhCTQlGAx2yYdJOtW3oljuk1GEriMHa3bKl6PvP YB3+a4sEKqbCTVEpvEOtxX31Iap1dvjmqfA6rCFn3ApK17MDe8W4vjoQS/5AEvpYLXjp 1zGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=nbmW2DuRmR2sbxKGvI2HWrAbIshEm1ch2OKZT6lqnkM=; b=DhFNLtlqeJGWN9JxDvH31su2RphYmestViMiPeSHpTWk9a/zorJzz9uKyk+fePZusF aPeut/8P6KB3GjarueqrXUdKGJhfbGXcGVHFnqIyLX3gFk1ApFku8d9xcjT5KSIWiLXn BKxd2yDtpyYCVet4PR6e4jiR25zCY8njx2BbD6k2m7vXGnk3zNeuPoQcxOd+N/coUdcy KS1ZwabJuoMwtdfz7BFYkO3V83ynva5dkQj87J1i2IzJpFVlTUoRH+6VFG+HjD8qr2dU 96loN3jkcocVUG4xVUbhmBtG6fijFrRADEFE2FRZCcwy8rqHZ95JfIB0r0Ndra9ndtsr 3Wwg== 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t12si13459732plr.311.2019.02.03.08.33.58; Sun, 03 Feb 2019 08:34:13 -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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728216AbfBCPa1 (ORCPT + 99 others); Sun, 3 Feb 2019 10:30:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44336 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726463AbfBCPaZ (ORCPT ); Sun, 3 Feb 2019 10:30:25 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 87B11C057F33; Sun, 3 Feb 2019 15:30:25 +0000 (UTC) Received: from krava.redhat.com (ovpn-204-46.brq.redhat.com [10.40.204.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id CEAE55C238; Sun, 3 Feb 2019 15:30:22 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Adrian Hunter , Andi Kleen , Stephane Eranian , Alexey Budankov Subject: [PATCH 01/14] perf tools: Make rm_rf to remove single file Date: Sun, 3 Feb 2019 16:30:05 +0100 Message-Id: <20190203153018.9650-2-jolsa@kernel.org> In-Reply-To: <20190203153018.9650-1-jolsa@kernel.org> References: <20190203153018.9650-1-jolsa@kernel.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Sun, 03 Feb 2019 15:30:25 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. + */ + return unlink(path); + } while ((d = readdir(dir)) != NULL && !ret) { struct stat statbuf; -- 2.17.2