X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fbootchart%2Fbootchart.c;h=7affacfdbfebb01e685d1584ec18a464a75bc627;hp=fb95c6b807351c46a7631978c929e8b7d2be97eb;hb=e93450c6c053d7499971a2b1310e893978f67f74;hpb=f2f85884caac671da84256acb44148df9a4dca70 diff --git a/src/bootchart/bootchart.c b/src/bootchart/bootchart.c index fb95c6b80..7affacfdb 100644 --- a/src/bootchart/bootchart.c +++ b/src/bootchart/bootchart.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -32,10 +33,12 @@ #include #include #include +#include #include "bootchart.h" #include "util.h" +#include "fileio.h" double graph_start; double log_start; @@ -50,6 +53,7 @@ double interval; FILE *of = NULL; int overrun = 0; static int exiting = 0; +int sysfd=-1; /* graph defaults */ int entropy = 0; @@ -78,6 +82,7 @@ static void signal_handler(int sig) int main(int argc, char *argv[]) { + _cleanup_free_ char *build = NULL; struct sigaction sig; struct ps_struct *ps; char output_file[PATH_MAX]; @@ -272,6 +277,15 @@ int main(int argc, char *argv[]) of = fopen(output_file, "w"); } + if (sysfd < 0) { + sysfd = open("/sys", O_RDONLY); + } + + if (!build) { + parse_env_file("/etc/os-release", NEWLINE, + "PRETTY_NAME", &build, + NULL); + } /* wait for /proc to become available, discarding samples */ if (!(graph_start > 0.0)) @@ -330,7 +344,6 @@ int main(int argc, char *argv[]) if (ps->smaps) fclose(ps->smaps); } - closedir(proc); if (!of) { t = time(NULL); @@ -344,11 +357,14 @@ int main(int argc, char *argv[]) exit (EXIT_FAILURE); } - svg_do(); + svg_do(build); fprintf(stderr, "bootchartd: Wrote %s\n", output_file); fclose(of); + closedir(proc); + close(sysfd); + /* nitpic cleanups */ ps = ps_first; while (ps->next_ps) {