summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.cz>2015-06-04 16:49:00 +0200
committerDavid Sterba <dsterba@suse.cz>2015-06-04 16:50:15 +0200
commit65cc6883c0594f0132d400a5beac4c4fc1fd7bce (patch)
treeaa7f060452e670caf890df7f7aa2baf4a8a996f1
parent4f43aaf4aac13cc0d52302ff294c49e3b43f0e62 (diff)
btrfs-progs: scrub: more friendly duration format in status
scrub status for d4dc0da9-e8cc-4bfe-9b6f-2dcf8e0754f5 scrub started at Sat Jan 1 00:00:01 UTC 2000 and finished after 00:43:05 total bytes scrubbed: 111.17GiB with 0 errors Signed-off-by: David Sterba <dsterba@suse.cz>
-rw-r--r--cmds-scrub.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/cmds-scrub.c b/cmds-scrub.c
index 06c2a306..1f37d17e 100644
--- a/cmds-scrub.c
+++ b/cmds-scrub.c
@@ -229,6 +229,8 @@ static void _print_scrub_ss(struct scrub_stats *ss)
{
char t[4096];
struct tm tm;
+ time_t seconds;
+ unsigned hours;
if (!ss || !ss->t_start) {
printf("\tno stats available\n");
@@ -245,18 +247,21 @@ static void _print_scrub_ss(struct scrub_stats *ss)
t[sizeof(t) - 1] = '\0';
printf("\tscrub started at %s", t);
}
+
+ seconds = ss->duration;
+ hours = ss->duration / (60 * 60);
+ gmtime_r(&seconds, &tm);
+ strftime(t, sizeof(t), "%M:%S", &tm);
if (ss->finished && !ss->canceled) {
- printf(" and finished after %llu seconds\n",
- ss->duration);
+ printf(" and finished after %02u:%s\n", hours, t);
} else if (ss->canceled) {
- printf(" and was aborted after %llu seconds\n",
- ss->duration);
+ printf(" and was aborted after %02u:%s\n", hours, t);
} else {
if (ss->in_progress)
- printf(", running for %llu seconds\n", ss->duration);
+ printf(", running for %02u:%s\n", hours, t);
else
- printf(", interrupted after %llu seconds, not running\n",
- ss->duration);
+ printf(", interrupted after %02u:%s, not running\n",
+ hours, t);
}
}