Register the bad read before bailing on terminal errors.
This way running recoverdisk in a loop will not get stuck on a bad block which causes the disk or SD card detach.
This commit is contained in:
parent
40407d3998
commit
d21ce74dcc
@ -149,12 +149,10 @@ static void
|
||||
set_verbose(void)
|
||||
{
|
||||
struct winsize wsz;
|
||||
time_t t0;
|
||||
|
||||
if (!isatty(STDIN_FILENO) || ioctl(STDIN_FILENO, TIOCGWINSZ, &wsz))
|
||||
return;
|
||||
verbose = 1;
|
||||
t0 = time(NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -587,6 +585,13 @@ if (!(random() & 0xf)) {
|
||||
lp->start, sz, lp->state, strerror(error));
|
||||
if (verbose)
|
||||
report(lp, sz);
|
||||
if (fdw >= 0 && strlen(unreadable_pattern)) {
|
||||
fill_buf(buf, sz, unreadable_pattern);
|
||||
write_buf(fdw, buf, sz, lp->start);
|
||||
}
|
||||
new_lump(lp->start, sz, lp->state + 1);
|
||||
lp->start += sz;
|
||||
lp->len -= sz;
|
||||
if (error == EINVAL) {
|
||||
printf("Try with -b 131072 or lower ?\n");
|
||||
aborting = 1;
|
||||
@ -597,13 +602,6 @@ if (!(random() & 0xf)) {
|
||||
aborting = 1;
|
||||
break;
|
||||
}
|
||||
if (fdw >= 0 && strlen(unreadable_pattern)) {
|
||||
fill_buf(buf, sz, unreadable_pattern);
|
||||
write_buf(fdw, buf, sz, lp->start);
|
||||
}
|
||||
new_lump(lp->start, sz, lp->state + 1);
|
||||
lp->start += sz;
|
||||
lp->len -= sz;
|
||||
}
|
||||
if (aborting)
|
||||
save_worklist();
|
||||
|
Loading…
Reference in New Issue
Block a user