diff options
Diffstat (limited to 'lib/ext2fs/progress.c')
-rw-r--r-- | lib/ext2fs/progress.c | 14 |
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); |