diff options
author | Dave Brolley <brolley@redhat.com> | 2009-06-22 11:37:08 -0400 |
---|---|---|
committer | Dave Brolley <brolley@redhat.com> | 2009-06-22 11:37:08 -0400 |
commit | d6454850dd3c9d74b700924b56378c4c9ab9fa57 (patch) | |
tree | 6665a24339ca689b1156ea7e93d4f93811c3f794 /runtime/staprun/common.c | |
parent | d729143af5242b17645d3f405141918940680894 (diff) | |
parent | 4116c576d5654287b0af598aee4a14eb2af73224 (diff) | |
download | systemtap-steved-d6454850dd3c9d74b700924b56378c4c9ab9fa57.tar.gz systemtap-steved-d6454850dd3c9d74b700924b56378c4c9ab9fa57.tar.xz systemtap-steved-d6454850dd3c9d74b700924b56378c4c9ab9fa57.zip |
Merge branch 'master' of git://sources.redhat.com/git/systemtap
Diffstat (limited to 'runtime/staprun/common.c')
-rw-r--r-- | runtime/staprun/common.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/runtime/staprun/common.c b/runtime/staprun/common.c index 644dfa53..010cab12 100644 --- a/runtime/staprun/common.c +++ b/runtime/staprun/common.c @@ -67,6 +67,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; |