From: Harald Hoyer <har...@redhat.com> Also parse it early, so that we can get it in the initramfs. --- src/bootchart/bootchart.c | 9 ++++++++- src/bootchart/bootchart.h | 2 +- src/bootchart/svg.c | 15 +++------------ 3 files changed, 12 insertions(+), 14 deletions(-)
diff --git a/src/bootchart/bootchart.c b/src/bootchart/bootchart.c index 43e8fdc..1c14c33 100644 --- a/src/bootchart/bootchart.c +++ b/src/bootchart/bootchart.c @@ -81,6 +81,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]; @@ -279,6 +280,12 @@ int main(int argc, char *argv[]) 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)) log_uptime(); @@ -349,7 +356,7 @@ int main(int argc, char *argv[]) exit (EXIT_FAILURE); } - svg_do(); + svg_do(build); fprintf(stderr, "bootchartd: Wrote %s\n", output_file); fclose(of); diff --git a/src/bootchart/bootchart.h b/src/bootchart/bootchart.h index 6b11fd8..84e9420 100644 --- a/src/bootchart/bootchart.h +++ b/src/bootchart/bootchart.h @@ -124,4 +124,4 @@ extern double gettime_ns(void); extern void log_uptime(void); extern void log_sample(int sample); -extern void svg_do(void); +extern void svg_do(const char *build); diff --git a/src/bootchart/svg.c b/src/bootchart/svg.c index 7fdcd01..f8a3776 100644 --- a/src/bootchart/svg.c +++ b/src/bootchart/svg.c @@ -140,7 +140,7 @@ static void svg_header(void) } -static void svg_title(void) +static void svg_title(const char *build) { char cmdline[256] = ""; char filename[PATH_MAX]; @@ -149,7 +149,6 @@ static void svg_title(void) char model[256] = "Unknown"; char date[256] = "Unknown"; char cpu[256] = "Unknown"; - char build[256] = "Unknown"; char *c; FILE *f; time_t t; @@ -202,14 +201,6 @@ static void svg_title(void) fclose(f); } - /* Build - 1st line from /etc/system-release */ - f = fopen("/etc/system-release", "r"); - if (f) { - if (fgets(buf, 255, f)) - strncpy(build, buf, 255); - fclose(f); - } - svg("<text class=\"t1\" x=\"0\" y=\"30\">Bootchart for %s - %s</text>\n", uts.nodename, date); svg("<text class=\"t2\" x=\"20\" y=\"50\">System: %s %s %s %s</text>\n", @@ -1054,7 +1045,7 @@ static void svg_top_ten_pss(void) } -void svg_do(void) +void svg_do(const char *build) { struct ps_struct *ps; @@ -1107,7 +1098,7 @@ void svg_do(void) svg("</g>\n\n"); svg("<g transform=\"translate(10, 0)\">\n"); - svg_title(); + svg_title(build); svg("</g>\n\n"); svg("<g transform=\"translate(10,200)\">\n"); -- 1.8.1 _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel