From: tip-bot for Pierre Habouzit <pierre.habouzit@intersec.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, paulus@samba.org, hpa@zytor.com,
mingo@redhat.com, a.p.zijlstra@chello.nl,
pierre.habouzit@intersec.com, tglx@linutronix.de, mingo@elte.hu
Subject: [tip:perfcounters/urgent] perf record: Fix the -A UI for empty or non-existent perf.data
Date: Fri, 7 Aug 2009 15:10:05 GMT [thread overview]
Message-ID: <tip-7e6649a1a2dd0774160dc4f8d5db762ac3678ba0@git.kernel.org> (raw)
In-Reply-To: <1249647361-11582-3-git-send-email-pierre.habouzit@intersec.com>
Commit-ID: 7e6649a1a2dd0774160dc4f8d5db762ac3678ba0
Gitweb: http://git.kernel.org/tip/7e6649a1a2dd0774160dc4f8d5db762ac3678ba0
Author: Pierre Habouzit <pierre.habouzit@intersec.com>
AuthorDate: Fri, 7 Aug 2009 14:16:01 +0200
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Fri, 7 Aug 2009 17:08:17 +0200
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>
LKML-Reference: <1249647361-11582-3-git-send-email-pierre.habouzit@intersec.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
tools/perf/builtin-record.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 6da0992..afbfb9d 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -524,10 +524,14 @@ static int __cmd_record(int argc, const char **argv)
signal(SIGCHLD, sig_handler);
signal(SIGINT, sig_handler);
- if (!stat(output_name, &st) && !force && !append_file) {
- fprintf(stderr, "Error, output file %s exists, use -A to append or -f to overwrite.\n",
- output_name);
- exit(-1);
+ 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);
+ }
+ } else {
+ append_file = 0;
}
flags = O_CREAT|O_RDWR;
next prev parent reply other threads:[~2009-08-07 15:10 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-07 12:15 perf-record fix and UI improvement Pierre Habouzit
2009-08-07 12:16 ` [PATCH 1/2] perf util: do_read should fail on EOF instead of busy-looping Pierre Habouzit
2009-08-07 12:16 ` [PATCH 2/2] perf-record: improve -A UI for empty or non-existent perf.data Pierre Habouzit
2009-08-07 15:10 ` tip-bot for Pierre Habouzit [this message]
2009-08-07 15:09 ` [tip:perfcounters/urgent] perf util: Fix do_read() to fail on EOF instead of busy-looping tip-bot for Pierre Habouzit
2009-08-07 12:28 ` perf-record fix and UI improvement Pierre Habouzit
2009-08-07 13:01 ` Peter Zijlstra
2009-08-07 13:59 ` Pierre Habouzit
2009-08-07 15:09 ` Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-7e6649a1a2dd0774160dc4f8d5db762ac3678ba0@git.kernel.org \
--to=pierre.habouzit@intersec.com \
--cc=a.p.zijlstra@chello.nl \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mingo@redhat.com \
--cc=paulus@samba.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®