]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bootchart: parse /etc/os-release rather than system-release
authorHarald Hoyer <harald@redhat.com>
Thu, 14 Feb 2013 10:26:07 +0000 (11:26 +0100)
committerAuke Kok <auke-jan.h.kok@intel.com>
Thu, 14 Feb 2013 19:59:16 +0000 (11:59 -0800)
Also parse it early, so that we can get it in the initramfs.

src/bootchart/bootchart.c
src/bootchart/bootchart.h
src/bootchart/svg.c

index e34c08a5eb54f16bb71e570f991ff4fb6c3464c0..7affacfdbfebb01e685d1584ec18a464a75bc627 100644 (file)
@@ -82,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];
@@ -280,6 +281,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();
@@ -350,7 +357,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);
index 6b11fd8b8e00cf1574bc9592de4d219ec8ff8813..84e94209987d950a1659e31e97bc5a8f1da3a2d9 100644 (file)
@@ -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);
index dc55cb3797a7fdf8813dc7fdb7a223e0a251a765..414d7af9b98451584362f367c397c53e4ebe505c 100644 (file)
@@ -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;
@@ -201,14 +200,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",
@@ -1053,7 +1044,7 @@ static void svg_top_ten_pss(void)
 }
 
 
-void svg_do(void)
+void svg_do(const char *build)
 {
         struct ps_struct *ps;
 
@@ -1106,7 +1097,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");