Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 25 Nov 2025 18:17:40 +0000
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Cc:        Matt Jacobson <mhjacobson@me.com>
Subject:   git: 4c8bf76893a8 - main - fdread: Fix logic bug when reading by sector
Message-ID:  <6925f2c4.e4ef.50f3b32a@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by imp:

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

commit 4c8bf76893a8b39eda15f91d1515c6bf6a02a9a6
Author:     Matt Jacobson <mhjacobson@me.com>
AuthorDate: 2025-11-25 01:30:10 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2025-11-25 18:17:26 +0000

    fdread: Fix logic bug when reading by sector
    
    When reading by sector (because reading a whole track failed), we can
    accidentally fall into the "should not happen" path, which both
    (a) emits a spurious error message and (b) fouls up our position
    accounting going forward.  Ensure we do not inappropriately fall into
    that path.
    
    Avoid obscuring the "short after" message in cases where it happens.
    
    Signed-off-by: Matt Jacobson <mhjacobson@me.com>
    Reviewed by: imp
    Pull Request: https://github.com/freebsd/freebsd-src/pull/1897
---
 usr.sbin/fdread/fdread.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/usr.sbin/fdread/fdread.c b/usr.sbin/fdread/fdread.c
index ee8548699783..02dbaf98da8c 100644
--- a/usr.sbin/fdread/fdread.c
+++ b/usr.sbin/fdread/fdread.c
@@ -275,12 +275,13 @@ doread(int fd, FILE *of, const char *_devname)
 				errx(EX_OSERR, "unexpected read() result: %d",
 				     rv);
 			}
+			continue;
 		}
 		if ((unsigned)rv < tracksize) {
 			/* should not happen */
 			nbytes += rv;
 			if (!quiet)
-				fprintf(stderr, "\nshort after %5d KB\r",
+				fprintf(stderr, "\nshort after %5d KB\n",
 					nbytes / 1024);
 			fwrite(trackbuf, sizeof(unsigned char), rv, of);
 			fflush(of);


help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6925f2c4.e4ef.50f3b32a>