Skip to content

Commit

Permalink
perf record: Rename perf.data to perf.data.old if --force/-f is used
Browse files Browse the repository at this point in the history
Suggested-by: Steven Rostedt <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
Cc: Frédéric Weisbecker <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Paul Mackerras <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
acmel authored and Ingo Molnar committed Dec 15, 2009
1 parent c8829c7 commit b38d346
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,10 +421,19 @@ static int __cmd_record(int argc, const char **argv)
signal(SIGINT, sig_handler);

if (!stat(output_name, &st) && st.st_size) {
if (!force && !append_file) {
fprintf(stderr, "Error, output file %s exists, use -A to append or -f to overwrite.\n",
output_name);
exit(-1);
if (!force) {
if (!append_file) {
pr_err("Error, output file %s exists, use -A "
"to append or -f to overwrite.\n",
output_name);
exit(-1);
}
} else {
char oldname[PATH_MAX];
snprintf(oldname, sizeof(oldname), "%s.old",
output_name);
unlink(oldname);
rename(output_name, oldname);
}
} else {
append_file = 0;
Expand Down

0 comments on commit b38d346

Please sign in to comment.