From: tip-bot for Jiri Olsa <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: mingo@kernel.org, peterz@infradead.org, acme@redhat.com,
tglx@linutronix.de, alexander.shishkin@linux.intel.com,
ak@linux.intel.com, hpa@zytor.com,
alexey.budankov@linux.intel.com, linux-kernel@vger.kernel.org,
jolsa@kernel.org, namhyung@kernel.org
Subject: [tip:perf/core] perf tools: Make rm_rf() remove single file
Date: Wed, 27 Feb 2019 23:47:51 -0800 [thread overview]
Message-ID: <tip-b4409ae112caa6315f6ee678e953b9fc93e6919c@git.kernel.org> (raw)
In-Reply-To: <20190220122800.864-7-jolsa@kernel.org>
Commit-ID: b4409ae112caa6315f6ee678e953b9fc93e6919c
Gitweb: https://git.kernel.org/tip/b4409ae112caa6315f6ee678e953b9fc93e6919c
Author: Jiri Olsa <jolsa@kernel.org>
AuthorDate: Wed, 20 Feb 2019 13:28:00 +0100
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 20 Feb 2019 17:09:28 -0300
perf tools: Make rm_rf() remove single file
Let rm_rf() remove a file if it's provided by path, not just
directories.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20190220122800.864-7-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/util.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 320b0fef249a..3ee410fc047a 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -120,16 +120,26 @@ int mkdir_p(char *path, mode_t mode)
int rm_rf(const char *path)
{
DIR *dir;
- int ret = 0;
+ int ret;
struct dirent *d;
char namebuf[PATH_MAX];
+ struct stat statbuf;
+ /* Do not fail if there's no file. */
+ ret = lstat(path, &statbuf);
+ if (ret)
+ return 0;
+
+ /* Try to remove any file we get. */
+ if (!(statbuf.st_mode & S_IFDIR))
+ return unlink(path);
+
+ /* We have directory in path. */
dir = opendir(path);
if (dir == NULL)
- return 0;
+ return -1;
while ((d = readdir(dir)) != NULL && !ret) {
- struct stat statbuf;
if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, ".."))
continue;
prev parent reply other threads:[~2019-02-28 7:48 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-20 12:27 [PATCH 0/6] perf tools: Assorted fixes Jiri Olsa
2019-02-20 12:27 ` [PATCH 1/6] perf tools: Don't report zero period samples for slave events Jiri Olsa
2019-02-28 7:44 ` [tip:perf/core] perf session: " tip-bot for Jiri Olsa
2019-02-20 12:27 ` [PATCH 2/6] perf tools: Force sample_type " Jiri Olsa
2019-02-28 7:45 ` [tip:perf/core] perf evsel: " tip-bot for Jiri Olsa
2019-02-20 12:27 ` [PATCH 3/6] perf script: Allow +- operator for type specific fields option Jiri Olsa
2019-02-28 7:45 ` [tip:perf/core] " tip-bot for Jiri Olsa
2019-02-20 12:27 ` [PATCH 4/6] perf tools: Add missing new line into pr_debug call Jiri Olsa
2019-02-20 19:23 ` Arnaldo Carvalho de Melo
2019-02-28 7:46 ` [tip:perf/core] perf bpf-event: " tip-bot for Jiri Olsa
2019-02-20 12:27 ` [PATCH 5/6] perf tools: Increase debug leve for cpu_map__snprint verbose output Jiri Olsa
2019-02-28 7:47 ` [tip:perf/core] perf cpumap: Increase debug level " tip-bot for Jiri Olsa
2019-02-20 12:28 ` [PATCH 6/6] perf tools: Make rm_rf to remove single file Jiri Olsa
2019-02-28 7:47 ` tip-bot for Jiri Olsa [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-b4409ae112caa6315f6ee678e953b9fc93e6919c@git.kernel.org \
--to=tipbot@zytor.com \
--cc=acme@redhat.com \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=alexey.budankov@linux.intel.com \
--cc=hpa@zytor.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome