summaryrefslogtreecommitdiff
path: root/lib/ext2fs/progress.c
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2014-06-12 12:07:34 +0100
committerRichard Maw <richard.maw@codethink.co.uk>2014-06-12 12:07:34 +0100
commit485edc675200ff3097cec521c357441a1c2d9b0d (patch)
tree7edee2fc5e1fb60caa90f3bb26b1becde9691b99 /lib/ext2fs/progress.c
parent1ab0ea88057e922a89c6b8feebeb62c57e40f8de (diff)
parent5f4b406b03dc9fa27c78184df5b1d501e373ca01 (diff)
downloade2fsprogs-485edc675200ff3097cec521c357441a1c2d9b0d.tar.gz
Merge 'baserock/richardmaw/yakshave/util-linux-blkid' into baserock/morphbaserock/morph
Reviewed-by: Lars Wirzenius Reviewed-by: Sam Thursfield
Diffstat (limited to 'lib/ext2fs/progress.c')
-rw-r--r--lib/ext2fs/progress.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/ext2fs/progress.c b/lib/ext2fs/progress.c
index 37d15096..8c9a6f1d 100644
--- a/lib/ext2fs/progress.c
+++ b/lib/ext2fs/progress.c
@@ -14,7 +14,10 @@
#include "ext2fs.h"
#include "ext2fsP.h"
+#include <time.h>
+
static char spaces[80], backspaces[80];
+static time_t last_update;
static int int_log10(unsigned int arg)
{
@@ -42,11 +45,11 @@ void ext2fs_numeric_progress_init(ext2_filsys fs,
spaces[sizeof(spaces)-1] = 0;
memset(backspaces, '\b', sizeof(backspaces)-1);
backspaces[sizeof(backspaces)-1] = 0;
- progress->skip_progress = 0;
+
+ memset(progress, 0, sizeof(*progress));
if (getenv("E2FSPROGS_SKIP_PROGRESS"))
progress->skip_progress++;
- memset(progress, 0, sizeof(*progress));
/*
* Figure out how many digits we need
@@ -58,16 +61,23 @@ void ext2fs_numeric_progress_init(ext2_filsys fs,
fputs(label, stdout);
fflush(stdout);
}
+ last_update = 0;
}
void ext2fs_numeric_progress_update(ext2_filsys fs,
struct ext2fs_numeric_progress_struct * progress,
__u64 val)
{
+ time_t now;
+
if (!(fs->flags & EXT2_FLAG_PRINT_PROGRESS))
return;
if (progress->skip_progress)
return;
+ now = time(0);
+ if (now == last_update)
+ return;
+ last_update = now;
printf("%*llu/%*llu", progress->log_max, val,
progress->log_max, progress->max);