From d3584129c20e4246ed5fe53b0f14105d8b7fa212 Mon Sep 17 00:00:00 2001 From: Masami Hiramatsu Date: Fri, 19 Jun 2009 18:19:51 -0400 Subject: 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]. --- runtime/staprun/common.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'runtime/staprun/common.c') 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; -- cgit