From dfe40aec1c2e651fdb3b62b0bcae52a5dfb1aa8d Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 15 Oct 2017 21:11:46 +0200 Subject: [PATCH] ls: Print current duration of incomplete snapshots. Currently the duration of incomplete (and orphaned) snapshots is shown as 0:00. It's more interesting to see for how long the snapshot is already being created, so print the difference of the current time and the start time instead. Fix an overlong line and a whitespace issue while at it. --- dss.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dss.c b/dss.c index 3e626ab..122472e 100644 --- a/dss.c +++ b/dss.c @@ -1683,13 +1683,17 @@ static int com_ls(void) int i; struct snapshot_list sl; struct snapshot *s; + int64_t now = get_current_time(); dss_get_snapshot_list(&sl); FOR_EACH_SNAPSHOT(s, i, &sl) { - int64_t d = 0; + int64_t d; if (s->flags & SS_COMPLETE) d = (s->completion_time - s->creation_time) / 60; - dss_msg("%u\t%s\t%3" PRId64 ":%02" PRId64 "\n", s->interval, s->name, d/60, d%60); + else + d = (now - s->creation_time) / 60; + dss_msg("%u\t%s\t%3" PRId64 ":%02" PRId64 "\n", s->interval, + s->name, d / 60, d % 60); } free_snapshot_list(&sl); return 1; -- 2.39.2