#include <limits.h>
#include <unistd.h>
#include <sys/utsname.h>
+#include <sys/stat.h>
+#include <fcntl.h>
#include "bootchart.h"
#include "util.h"
svg("<!-- such as Chrome, Chromium, or Firefox. Other applications that -->\n");
svg("<!-- render these files properly but more slowly are ImageMagick, gimp, -->\n");
svg("<!-- inkscape, etc. To display the files on your system, just point -->\n");
- svg("<!-- your browser to file:///var/log/ and click. This bootchart was -->\n\n");
+ svg("<!-- your browser to file:///run/log/ and click. This bootchart was -->\n\n");
svg("<!-- generated by bootchart version %s, running with options: -->\n", VERSION);
svg("<!-- hz=\"%f\" n=\"%d\" -->\n", hz, len);
}
-static void svg_title(void)
+static void svg_title(const char *build)
{
char cmdline[256] = "";
char filename[PATH_MAX];
char model[256] = "Unknown";
char date[256] = "Unknown";
char cpu[256] = "Unknown";
- char build[256] = "Unknown";
char *c;
FILE *f;
time_t t;
+ int fd;
struct utsname uts;
/* grab /proc/cmdline */
- f = fopen("/proc/cmdline", "r");
+ fd = openat(procfd, "cmdline", O_RDONLY);
+ f = fdopen(fd, "r");
if (f) {
if (!fgets(cmdline, 255, f))
sprintf(cmdline, "Unknown");
strncpy(rootbdev, &c[10], 3);
rootbdev[3] = '\0';
}
- sprintf(filename, "/sys/block/%s/device/model", rootbdev);
- f = fopen(filename, "r");
+ sprintf(filename, "block/%s/device/model", rootbdev);
+ fd = openat(sysfd, filename, O_RDONLY);
+ f = fdopen(fd, "r");
if (f) {
if (!fgets(model, 255, f))
fprintf(stderr, "Error reading disk model for %s\n", rootbdev);
strftime(date, sizeof(date), "%a, %d %b %Y %H:%M:%S %z", localtime(&t));
/* CPU type */
- f = fopen("/proc/cpuinfo", "r");
+ fd = openat(procfd, "cpuinfo", O_RDONLY);
+ f = fdopen(fd, "r");
if (f) {
while (fgets(buf, 255, f)) {
if (strstr(buf, "model name")) {
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",
}
-void svg_do(void)
+void svg_do(const char *build)
{
struct ps_struct *ps;
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");