summaryrefslogtreecommitdiff
path: root/src/bootchart/svg.c
diff options
context:
space:
mode:
authorHarald Hoyer <harald@redhat.com>2013-02-14 11:26:05 +0100
committerAuke Kok <auke-jan.h.kok@intel.com>2013-02-14 11:55:23 -0800
commitb823b5e272d07d31c12625a268e8d563289a4db5 (patch)
tree4431fcfb05a2e1de766b9c5dab9ef5301ca23c5c /src/bootchart/svg.c
parent1fd961211df69ce672252d543bf4777738647048 (diff)
bootchart: more fixes for bootchart in the initramfs
Diffstat (limited to 'src/bootchart/svg.c')
-rw-r--r--src/bootchart/svg.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/bootchart/svg.c b/src/bootchart/svg.c
index 6ad7348ecb..dc55cb3797 100644
--- a/src/bootchart/svg.c
+++ b/src/bootchart/svg.c
@@ -28,6 +28,8 @@
#include <limits.h>
#include <unistd.h>
#include <sys/utsname.h>
+#include <sys/stat.h>
+#include <fcntl.h>
#include "bootchart.h"
#include "util.h"
@@ -151,10 +153,12 @@ static void svg_title(void)
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");
@@ -167,8 +171,9 @@ static void svg_title(void)
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);
@@ -184,7 +189,8 @@ static void svg_title(void)
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")) {