diff options
author | Clark Williams <williams@redhat.com> | 2010-03-19 14:39:44 -0500 |
---|---|---|
committer | Clark Williams <williams@redhat.com> | 2010-03-19 14:39:44 -0500 |
commit | ffebccf9f9b9df6803a50d3e4aba0aacba0d6e3e (patch) | |
tree | b903974f7c403deb83bceebc868cb9e0c5df925e | |
parent | 2ef575b81b0c267216398cc537b5e1a3c3129c7b (diff) | |
download | rt-tests-ffebccf9f9b9df6803a50d3e4aba0aacba0d6e3e.tar.gz |
handle ftrace difference between 2.6.24 and 2.6.33
Somewhere between 2.6.24 and 2.6.33, the tracing_on field was
added to the debugfs tracing dir. If it exists use it to turn
tracing on and off; if not use tracing_enabled.
Signed-off-by: Clark Williams <williams@redhat.com>
-rw-r--r-- | src/cyclictest/cyclictest.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c index 1c00e2b..92b7514 100644 --- a/src/cyclictest/cyclictest.c +++ b/src/cyclictest/cyclictest.c @@ -306,21 +306,42 @@ void traceopt(char *option) } +static int +trace_file_exists(char *name) +{ + struct stat sbuf; + char *tracing_prefix = get_debugfileprefix(); + char path[MAX_PATH]; + strcat(strcpy(path, tracing_prefix), name); + return stat(path, &sbuf) ? 0 : 1; +} + void tracing(int on) { if (on) { switch (kernelversion) { case KV_26_LT18: gettimeofday(0,(struct timezone *)1); break; case KV_26_LT24: prctl(0, 1); break; - case KV_26_CURR: setkernvar("tracing_on", "1"); break; + case KV_26_CURR: + if (trace_file_exists("tracing_on")) + setkernvar("tracing_on", "1"); + else + setkernvar("tracing_enabled", "1"); + break; + default: break; } } else { switch (kernelversion) { case KV_26_LT18: gettimeofday(0,0); break; case KV_26_LT24: prctl(0, 0); break; - case KV_26_CURR: setkernvar("tracing_on", "0"); break; - default: break; + case KV_26_CURR: + if (trace_file_exists("tracing_on")) + setkernvar("tracing_on", "0"); + else + setkernvar("tracing_enabled", "0"); + break; + default: break; } } } |