[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-5021fc4e8c7c3be6f8735eff76fb2520485fcec4@git.kernel.org>
Date: Thu, 28 Feb 2019 00:02:06 -0800
From: tip-bot for Jiri Olsa <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: adrian.hunter@...el.com, hpa@...or.com, jolsa@...nel.org,
tglx@...utronix.de, alexey.budankov@...ux.intel.com,
peterz@...radead.org, mingo@...nel.org, eranian@...gle.com,
namhyung@...nel.org, ak@...ux.intel.com, acme@...hat.com,
alexander.shishkin@...ux.intel.com, linux-kernel@...r.kernel.org
Subject: [tip:perf/core] perf data: Make check_backup work over directories
Commit-ID: 5021fc4e8c7c3be6f8735eff76fb2520485fcec4
Gitweb: https://git.kernel.org/tip/5021fc4e8c7c3be6f8735eff76fb2520485fcec4
Author: Jiri Olsa <jolsa@...nel.org>
AuthorDate: Sun, 24 Feb 2019 20:06:42 +0100
Committer: Arnaldo Carvalho de Melo <acme@...hat.com>
CommitDate: Mon, 25 Feb 2019 10:35:19 -0300
perf data: Make check_backup work over directories
Change check_backup() to call rm_rf_perf_data() instead of unlink() to
work over directory paths.
Also move the call earlier in the code, before we fork for file/dir, so
it can backup also directory data.
Signed-off-by: Jiri Olsa <jolsa@...nel.org>
Cc: Adrian Hunter <adrian.hunter@...el.com>
Cc: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Cc: Alexey Budankov <alexey.budankov@...ux.intel.com>
Cc: Andi Kleen <ak@...ux.intel.com>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Stephane Eranian <eranian@...gle.com>
Link: http://lkml.kernel.org/r/20190224190656.30163-7-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
tools/perf/util/data.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c
index e16d06ed1100..bbf9a299615e 100644
--- a/tools/perf/util/data.c
+++ b/tools/perf/util/data.c
@@ -37,12 +37,15 @@ static int check_backup(struct perf_data *data)
{
struct stat st;
+ if (perf_data__is_read(data))
+ return 0;
+
if (!stat(data->path, &st) && st.st_size) {
/* TODO check errors properly */
char oldname[PATH_MAX];
snprintf(oldname, sizeof(oldname), "%s.old",
data->path);
- unlink(oldname);
+ rm_rf_perf_data(oldname);
rename(data->path, oldname);
}
@@ -95,9 +98,6 @@ static int open_file_write(struct perf_data *data)
int fd;
char sbuf[STRERR_BUFSIZE];
- if (check_backup(data))
- return -1;
-
fd = open(data->file.path, O_CREAT|O_RDWR|O_TRUNC|O_CLOEXEC,
S_IRUSR|S_IWUSR);
@@ -141,6 +141,9 @@ int perf_data__open(struct perf_data *data)
if (!data->path)
data->path = "perf.data";
+ if (check_backup(data))
+ return -1;
+
return open_file_dup(data);
}
Powered by blists - more mailing lists