summaryrefslogtreecommitdiffstats
path: root/runtime/staprun/common.c
diff options
context:
space:
mode:
authorMasami Hiramatsu <mhiramat@redhat.com>2009-06-19 18:19:51 -0400
committerMasami Hiramatsu <mhiramat@redhat.com>2009-06-19 18:19:51 -0400
commitd3584129c20e4246ed5fe53b0f14105d8b7fa212 (patch)
tree731afa819636340de20934fcc66b8067431b61c9 /runtime/staprun/common.c
parent54bc8f42438e7efc62c5dd2b39618ccd6c953cdd (diff)
downloadsystemtap-steved-d3584129c20e4246ed5fe53b0f14105d8b7fa212.tar.gz
systemtap-steved-d3584129c20e4246ed5fe53b0f14105d8b7fa212.tar.xz
systemtap-steved-d3584129c20e4246ed5fe53b0f14105d8b7fa212.zip
Fix on-file flight recorder mode bugs on old kernel.
* runtime/staprun/common.c (make_outfile_name): Moved from relay.c, fix not to open /dev/null.XXX output files, and add 'bulk' argument for bulkmode. * runtime/staprun/relay.c (make_outfile_name): Moved to common.c. * runtime/staprun/relay_old.c (open_oldoutfile): Fix to use fopen() and store FILE * to percpu_tmpfile[cpu].
Diffstat (limited to 'runtime/staprun/common.c')
-rw-r--r--runtime/staprun/common.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/runtime/staprun/common.c b/runtime/staprun/common.c
index c67ce340..5c4a8431 100644
--- a/runtime/staprun/common.c
+++ b/runtime/staprun/common.c
@@ -66,6 +66,33 @@ int stap_strfloctime(char *buf, size_t max, const char *fmt, time_t t)
return (int)ret;
}
+int make_outfile_name(char *buf, int max, int fnum, int cpu, time_t t, int bulk)
+{
+ int len;
+ if (PATH_MAX < max)
+ max = PATH_MAX;
+ len = stap_strfloctime(buf, max, outfile_name, t);
+ if (len < 0) {
+ err("Invalid FILE name format\n");
+ return -1;
+ }
+ /* special case: for testing we sometimes want to write to /dev/null */
+ if (strcmp(outfile_name, "/dev/null") == 0) {
+ strcpy(buf, "/dev/null");
+ } else {
+ if (bulk) {
+ if (snprintf_chk(&buf[len], max - len, "_cpu%d.%d",
+ cpu, fnum))
+ return -1;
+ } else {
+ /* stream mode */
+ if (snprintf_chk(&buf[len], max - len, ".%d", fnum))
+ return -1;
+ }
+ }
+ return 0;
+}
+
void parse_args(int argc, char **argv)
{
int c;