prev = 0;
for (cc = 1, i = 0; i < nsectors && nbytes > 0; i += step, cc++) {
- if (backward)
- src -= step_bytes, dst -= step_bytes;
-
- DBG(MISC, ul_debug("#%05zu: src=%ju dst=%ju", cc, src, dst));
if (nbytes < step_bytes) {
- DBG(MISC, ul_debug(" aligning step from %ju to %ju",
- step_bytes, nbytes));
+ DBG(MISC, ul_debug("aligning step #%05zu from %ju to %ju",
+ cc, step_bytes, nbytes));
step_bytes = nbytes;
}
nbytes -= step_bytes;
+ if (backward)
+ src -= step_bytes, dst -= step_bytes;
+
+ DBG(MISC, ul_debug("#%05zu: src=%ju dst=%ju", cc, src, dst));
+
if (!sf->noact) {
/* read source */
if (lseek(fd, src, SEEK_SET) == (off_t) -1 ||
fputc(' ', stdout);
fflush(stdout);
fputc('\r', stdout);
+
+ if (i > nsectors)
+ /* see for() above; @i has to be greater than @nsectors
+ * on success due to i += step */
+ i = nsectors;
+
fprintf(stdout, _("Moved %ju from %ju sectors (%.0f%%)."),
i, nsectors,
100.0 / ((double) nsectors/(i+1)));