summaryrefslogtreecommitdiff
path: root/src/bootchart/store.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bootchart/store.c')
-rw-r--r--src/bootchart/store.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/src/bootchart/store.c b/src/bootchart/store.c
index e0719838d5..cedcba88ed 100644
--- a/src/bootchart/store.c
+++ b/src/bootchart/store.c
@@ -57,27 +57,22 @@ double gettime_ns(void) {
return (n.tv_sec + (n.tv_nsec / 1000000000.0));
}
-void log_uptime(void) {
- _cleanup_fclose_ FILE *f = NULL;
- char str[32];
- double uptime;
-
- f = fopen("/proc/uptime", "re");
-
- if (!f)
- return;
- if (!fscanf(f, "%s %*s", str))
- return;
-
- uptime = strtod(str, NULL);
+static double gettime_up(void) {
+ struct timespec n;
- log_start = gettime_ns();
+ clock_gettime(CLOCK_BOOTTIME, &n);
+ return (n.tv_sec + (n.tv_nsec / 1000000000.0));
+}
- /* start graph at kernel boot time */
+void log_uptime(void) {
if (arg_relative)
- graph_start = log_start;
- else
+ graph_start = log_start = gettime_ns();
+ else {
+ double uptime = gettime_up();
+
+ log_start = gettime_ns();
graph_start = log_start - uptime;
+ }
}
static char *bufgetline(char *buf) {