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: 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@kernel.org>
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-7-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

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

+7 -4
+7 -4
tools/perf/util/data.c
··· 37 37 { 38 38 struct stat st; 39 39 40 + if (perf_data__is_read(data)) 41 + return 0; 42 + 40 43 if (!stat(data->path, &st) && st.st_size) { 41 44 /* TODO check errors properly */ 42 45 char oldname[PATH_MAX]; 43 46 snprintf(oldname, sizeof(oldname), "%s.old", 44 47 data->path); 45 - unlink(oldname); 48 + rm_rf_perf_data(oldname); 46 49 rename(data->path, oldname); 47 50 } 48 51 ··· 98 95 int fd; 99 96 char sbuf[STRERR_BUFSIZE]; 100 97 101 - if (check_backup(data)) 102 - return -1; 103 - 104 98 fd = open(data->file.path, O_CREAT|O_RDWR|O_TRUNC|O_CLOEXEC, 105 99 S_IRUSR|S_IWUSR); 106 100 ··· 140 140 141 141 if (!data->path) 142 142 data->path = "perf.data"; 143 + 144 + if (check_backup(data)) 145 + return -1; 143 146 144 147 return open_file_dup(data); 145 148 }