aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--TODO1
-rw-r--r--deadshred.c12
2 files changed, 9 insertions, 4 deletions
diff --git a/TODO b/TODO
index 797110b..ff4552a 100644
--- a/TODO
+++ b/TODO
@@ -2,6 +2,5 @@ Add `-n iterations`
Add shred map for continuing later (print to stdout on SIGTERM)
Enhance progress printout with:
- exact bytes count
bad sections (count, bytes)
shredded bytes per seconds
diff --git a/deadshred.c b/deadshred.c
index 5f8f36b..84a5184 100644
--- a/deadshred.c
+++ b/deadshred.c
@@ -152,10 +152,11 @@ print_progress(int done)
char subbuf2[256];
sprintf(i == 0 ? buf1 : buf2,
- "%.2lf %% (%s, %s) of %s (%s) shredded\033[K\n%s",
- 100. * (double)shredded / (double)total_size,
+ "%ji bytes (%s, %s, %.2lf %%) of %s (%s) shredded\033[K\n%s",
+ (intmax_t)shredded,
humansize1000(shredded, subbuf1),
humansize1024(shredded, subbuf2),
+ 100. * (double)shredded / (double)total_size,
total_size_1000,
total_size_1024,
done ? "" : "\033[A");
@@ -174,9 +175,13 @@ shredspan(int fd, const struct span *span, const char *fname)
{
off_t off;
ssize_t r;
+ int update_progress_delay = 0;
for (off = span->start; off < span->end;) {
- print_progress(0);
+ if (!update_progress_delay--) {
+ update_progress_delay = 1000; /* TOOD use half a second instead */
+ print_progress(0);
+ }
if (lseek(fd, off, SEEK_SET) < 0)
eprintf("lseek %s %ji SEEK_SET\n", fname, (intmax_t)off);
ensure_random(span->blocksize);
@@ -184,6 +189,7 @@ shredspan(int fd, const struct span *span, const char *fname)
if (r < 0) {
if (errno != EINTR)
off = add_span(off, span->end, span->blocksize == 1U ? 1U : span->blocksize);
+ update_progress_delay = 0;
continue;
}
off += (off_t)r;