git: d21ce74dcce6 - main - Register the bad read before bailing on terminal errors.

Poul-Henning Kamp phk at FreeBSD.org
Tue Feb 2 12:02:50 UTC 2021


The branch main has been updated by phk:

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

commit d21ce74dcce6f8b69451b3b2dd291d35cbb70609
Author:     Poul-Henning Kamp <phk at FreeBSD.org>
AuthorDate: 2021-02-02 12:01:38 +0000
Commit:     Poul-Henning Kamp <phk at FreeBSD.org>
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();


More information about the dev-commits-src-all mailing list