chiark / gitweb /
bootchart: ask for --rel when failed to initialize graph start time
authorKarel Zak <kzak@redhat.com>
Thu, 31 Jul 2014 08:15:40 +0000 (10:15 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 3 Aug 2014 05:12:53 +0000 (01:12 -0400)
We always read system uptime before log start time. So the uptime
should be always smaller number, except it includes system suspend
time. It seems better to ask for --rel and exit() than try to be
smart and try to recovery from this situation or generate huge
messy graphs.

src/bootchart/bootchart.c

index fc00b4e3f2df888fa1fcf27ffeff770d29f0375d..5683025b1970df3f16da846326f70c2713c68fb8 100644 (file)
@@ -350,6 +350,14 @@ int main(int argc, char *argv[]) {
 
         log_uptime();
 
+        if (graph_start < 0.0) {
+                fprintf(stderr,
+                        "Failed to setup graph start time.\n\nThe system uptime "
+                        "probably includes time that the system was suspended. "
+                        "Use --rel to bypass this issue.\n");
+                exit (EXIT_FAILURE);
+        }
+
         has_procfs = access("/proc/vmstat", F_OK) == 0;
 
         LIST_HEAD_INIT(head);