From: Boucman Date: Wed, 3 Jan 2018 14:52:13 +0000 (+0100) Subject: fix systemd-analyze time when default.target is not reached (#7764) X-Git-Tag: v237~160 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=da933f7dcfab1cc891ae0c8acd4f382935dc5e98;p=thirdparty%2Fsystemd.git fix systemd-analyze time when default.target is not reached (#7764) Also, better error messages. --- diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c index f5146f8ce72..dce6dd61dd9 100644 --- a/src/analyze/analyze.c +++ b/src/analyze/analyze.c @@ -529,7 +529,7 @@ static int pretty_boot_time(sd_bus *bus, char **_buf) { "ActiveEnterTimestampMonotonic", &activated_time); if (r < 0) { - log_info_errno(r, "default.target seems not to be started. Continuing..."); + log_info_errno(r, "Could not get time to reach default.target. Continuing..."); activated_time = USEC_INFINITY; } @@ -549,8 +549,15 @@ static int pretty_boot_time(sd_bus *bus, char **_buf) { size = strpcpyf(&ptr, size, "%s (userspace) ", format_timespan(ts, sizeof(ts), t->finish_time - t->userspace_time, USEC_PER_MSEC)); strpcpyf(&ptr, size, "= %s", format_timespan(ts, sizeof(ts), t->firmware_time + t->finish_time, USEC_PER_MSEC)); - if (unit_id && activated_time != USEC_INFINITY) + if (unit_id && (activated_time > 0 && activated_time != USEC_INFINITY)) size = strpcpyf(&ptr, size, "\n%s reached after %s in userspace", unit_id, format_timespan(ts, sizeof(ts), activated_time - t->userspace_time, USEC_PER_MSEC)); + else if (unit_id && activated_time == 0) + size = strpcpyf(&ptr, size, "\n%s was never reached", unit_id); + else if (unit_id && activated_time == USEC_INFINITY) + size = strpcpyf(&ptr, size, "\nCould not get time to reach %s.",unit_id); + else if (!unit_id) + size = strpcpyf(&ptr, size, "\ncould not find default.target"); + ptr = strdup(buf); if (!ptr)