diff options
author | Feng Tang <feng.tang@intel.com> | 2012-10-29 23:56:07 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-10-29 09:56:59 -0400 |
commit | e84ba4e26833991d1c1c15a592b1474ee2b6dfdb (patch) | |
tree | a73d2b23c722ac3c1bbf08c075d124ccbe510ec7 /tools/perf/util/header.c | |
parent | cdbab7c201ab38f7b8d248ebf289025381166526 (diff) |
perf header: Add is_perf_magic() func
With this function, other modules can basically check whether a file is
a legal perf data file by checking its first 8 bytes against all
possible perf magic numbers.
Change the function name from check_perf_magic to more meaningful
is_perf_magic as suggested by acme.
Signed-off-by: Feng Tang <feng.tang@intel.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1351569369-26732-7-git-send-email-feng.tang@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/header.c')
-rw-r--r-- | tools/perf/util/header.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 514ed1bd41a2..195a47a8f052 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -2341,6 +2341,16 @@ static int try_all_pipe_abis(uint64_t hdr_sz, struct perf_header *ph) | |||
2341 | return -1; | 2341 | return -1; |
2342 | } | 2342 | } |
2343 | 2343 | ||
2344 | bool is_perf_magic(u64 magic) | ||
2345 | { | ||
2346 | if (!memcmp(&magic, __perf_magic1, sizeof(magic)) | ||
2347 | || magic == __perf_magic2 | ||
2348 | || magic == __perf_magic2_sw) | ||
2349 | return true; | ||
2350 | |||
2351 | return false; | ||
2352 | } | ||
2353 | |||
2344 | static int check_magic_endian(u64 magic, uint64_t hdr_sz, | 2354 | static int check_magic_endian(u64 magic, uint64_t hdr_sz, |
2345 | bool is_pipe, struct perf_header *ph) | 2355 | bool is_pipe, struct perf_header *ph) |
2346 | { | 2356 | { |