Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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.data.old)
Perf session creation failed.

$ perf record ls
Can't remove old data: Unknown file found (perf.data.old)
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: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
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>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/20190224190656.30163-8-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Jiri Olsa and committed by
Arnaldo Carvalho de Melo
ccb7a71d 5021fc4e

+18 -3
+18 -3
tools/perf/util/data.c
··· 41 41 return 0; 42 42 43 43 if (!stat(data->path, &st) && st.st_size) { 44 - /* TODO check errors properly */ 45 44 char oldname[PATH_MAX]; 45 + int ret; 46 + 46 47 snprintf(oldname, sizeof(oldname), "%s.old", 47 48 data->path); 48 - rm_rf_perf_data(oldname); 49 - rename(data->path, oldname); 49 + 50 + ret = rm_rf_perf_data(oldname); 51 + if (ret) { 52 + pr_err("Can't remove old data: %s (%s)\n", 53 + ret == -2 ? 54 + "Unknown file found" : strerror(errno), 55 + oldname); 56 + return -1; 57 + } 58 + 59 + if (rename(data->path, oldname)) { 60 + pr_err("Can't move data: %s (%s to %s)\n", 61 + strerror(errno), 62 + data->path, oldname); 63 + return -1; 64 + } 50 65 } 51 66 52 67 return 0;