aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Habouzit <pierre.habouzit@intersec.com>2009-08-07 08:16:01 -0400
committerIngo Molnar <mingo@elte.hu>2009-08-09 06:54:40 -0400
commit266e0e219888420a1a7cafc82e82891cf7b5a979 (patch)
tree12a0d8c29552d800cfd44ff4b6e44f0b6f42e7c3
parent7eac7e9e726c1b136bd7e0ad6671ce315f48bb18 (diff)
perf record: Fix the -A UI for empty or non-existent perf.data
1. Ignore the -A argument if there is no perf.data file 2. Treat an empty file like a non existent file. Else, perf will try to read the perf.data header, and fail with an error. Treating an empty file like a non-existent file makes sense, since an interupted (as in SIGKILLed) perf could leave such files around, and you don't want to annoy the user with errors for files with no data in it. Signed-off-by: Pierre Habouzit <pierre.habouzit@intersec.com> Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--tools/perf/builtin-record.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 90c98082af10..0345aad8eba5 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -525,10 +525,14 @@ static int __cmd_record(int argc, const char **argv)
525 signal(SIGCHLD, sig_handler); 525 signal(SIGCHLD, sig_handler);
526 signal(SIGINT, sig_handler); 526 signal(SIGINT, sig_handler);
527 527
528 if (!stat(output_name, &st) && !force && !append_file) { 528 if (!stat(output_name, &st) && st.st_size) {
529 fprintf(stderr, "Error, output file %s exists, use -A to append or -f to overwrite.\n", 529 if (!force && !append_file) {
530 output_name); 530 fprintf(stderr, "Error, output file %s exists, use -A to append or -f to overwrite.\n",
531 exit(-1); 531 output_name);
532 exit(-1);
533 }
534 } else {
535 append_file = 0;
532 } 536 }
533 537
534 flags = O_CREAT|O_RDWR; 538 flags = O_CREAT|O_RDWR;