提交 b38d3464 编写于 作者: A Arnaldo Carvalho de Melo 提交者: Ingo Molnar

perf record: Rename perf.data to perf.data.old if --force/-f is used

Suggested-by: NSteven Rostedt <rostedt@goodmis.org>
Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1260828571-3613-2-git-send-email-acme@infradead.org>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
上级 c8829c7a
...@@ -421,10 +421,19 @@ static int __cmd_record(int argc, const char **argv) ...@@ -421,10 +421,19 @@ static int __cmd_record(int argc, const char **argv)
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
if (!stat(output_name, &st) && st.st_size) { if (!stat(output_name, &st) && st.st_size) {
if (!force && !append_file) { if (!force) {
fprintf(stderr, "Error, output file %s exists, use -A to append or -f to overwrite.\n", if (!append_file) {
output_name); pr_err("Error, output file %s exists, use -A "
exit(-1); "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 { } else {
append_file = 0; append_file = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册