The branch main has been updated by phk:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=d21ce74dcce6f8b69451b3b2dd291d35cbb70609

commit d21ce74dcce6f8b69451b3b2dd291d35cbb70609
Author:     Poul-Henning Kamp <[email protected]>
AuthorDate: 2021-02-02 12:01:38 +0000
Commit:     Poul-Henning Kamp <[email protected]>
CommitDate: 2021-02-02 12:01:38 +0000

    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.
---
 sbin/recoverdisk/recoverdisk.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/sbin/recoverdisk/recoverdisk.c b/sbin/recoverdisk/recoverdisk.c
index 8c4aabebc76f..35d7adc7a5c3 100644
--- a/sbin/recoverdisk/recoverdisk.c
+++ b/sbin/recoverdisk/recoverdisk.c
@@ -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();
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-main
To unsubscribe, send any mail to "[email protected]"

Reply via email to