Commit ccb7a71d authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo
Browse files

perf data: Fail check_backup in case of error

And display the error message from removing the old data file:

  $ perf record ls
  Can't remove old data: Permission denied (
  Perf session creation failed.

  $ perf record ls
  Can't remove old data: Unknown file found (
  Perf session creation failed.

Not sure how to make fail the rename (after we successfully remove the
destination file/dir) to show the message, anyway let's have it there.
Signed-off-by: default avatarJiri Olsa <>
Tested-by: default avatarArnaldo Carvalho de Melo <>
Cc: Adrian Hunter <>
Cc: Alexander Shishkin <>
Cc: Alexey Budankov <>
Cc: Andi Kleen <>
Cc: Namhyung Kim <>
Cc: Peter Zijlstra <>
Cc: Stephane Eranian <>

Signed-off-by: default avatarArnaldo Carvalho de Melo <>
parent 5021fc4e
......@@ -41,12 +41,27 @@ static int check_backup(struct perf_data *data)
return 0;
if (!stat(data->path, &st) && st.st_size) {
/* TODO check errors properly */
char oldname[PATH_MAX];
int ret;
snprintf(oldname, sizeof(oldname), "%s.old",
rename(data->path, oldname);
ret = rm_rf_perf_data(oldname);
if (ret) {
pr_err("Can't remove old data: %s (%s)\n",
ret == -2 ?
"Unknown file found" : strerror(errno),
return -1;
if (rename(data->path, oldname)) {
pr_err("Can't move data: %s (%s to %s)\n",
data->path, oldname);
return -1;
return 0;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment