]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bootchart: use get_proc_field and PROC_CPUINFO_MODEL 1415/head
authorAaro Koskinen <aaro.koskinen@nokia.com>
Wed, 30 Sep 2015 12:57:55 +0000 (15:57 +0300)
committerAaro Koskinen <aaro.koskinen@nokia.com>
Wed, 30 Sep 2015 12:57:55 +0000 (15:57 +0300)
Use get_proc_field and PROC_CPUINFO_MODEL to get the CPU type. Also don't
fail if it missing, instead restore the old behaviour and print "Unknown".

Fixes the following error seen with v225 on powerpc:

Unable to read module name from cpuinfo.
Error generating svg file: No such file or directory

src/bootchart/svg.c

index c66f12e3a6fcb2c7aa00e250c5e74ffacdd09b26..db5fc863b0fee84910f49024bb5875c8544e1acf 100644 (file)
@@ -30,6 +30,7 @@
 #include <sys/utsname.h>
 #include <fcntl.h>
 
+#include "architecture.h"
 #include "util.h"
 #include "fileio.h"
 #include "macro.h"
@@ -147,7 +148,7 @@ static int svg_title(FILE *of, const char *build, int pscount, double log_start,
         _cleanup_free_ char *model = NULL;
         _cleanup_free_ char *buf = NULL;
         char date[256] = "Unknown";
-        char *cpu;
+        const char *cpu;
         char *c;
         time_t t;
         int r;
@@ -188,20 +189,11 @@ static int svg_title(FILE *of, const char *build, int pscount, double log_start,
         assert_se(r > 0);
 
         /* CPU type */
-        r = read_full_file("/proc/cpuinfo", &buf, NULL);
+        r = get_proc_field("/proc/cpuinfo", PROC_CPUINFO_MODEL, "\n", &buf);
         if (r < 0)
-                return log_error_errno(r, "Unable to read cpuinfo: %m");
-
-        cpu = strstr(buf, "model name");
-        if (!cpu) {
-                log_error("Unable to read module name from cpuinfo.\n");
-                return -ENOENT;
-        }
-
-        cpu += 13;
-        c = strchr(cpu, '\n');
-        if (c)
-                *c = '\0';
+                cpu = "Unknown";
+        else
+                cpu = buf;
 
         fprintf(of, "<text class=\"t1\" x=\"0\" y=\"30\">Bootchart for %s - %s</text>\n",
                 uts.nodename, date);