Created attachment 266843 [details] Git patch (works against current and 14.3) I just burned a couple of Blu Ray data disks. Since I don't trust optical media that much, I thought I should check. So... > mount /mnt/bluray > diff -rq /mnt/bluray originaldata/ No output, so everything good, isn't it? Hadn't I by chance seen some ahci MEDIUM ERROR (uncorrectable error) in the logs I would have stored these disks away and could only hope I wouldn't ever need them! Let's check again... > diff -rqs /mnt/bluray originaldata/ No output??? > mkdir newdata/ > cp -R /mnt/bluray/* newdata/ > cp: /mnt/bluray/file1: Input/output error > cp: /mnt/bluray/file2: Input/output error > cp: /mnt/bluray/file4: Input/output error > ... So I had to conclude that diff silently ignores files when an underlying hardware error happens and cannot be trusted!!! For comparison: > gdiff -rq /mnt/bluray originaldata/ gdiff: /mnt/bluray/file1: Input/output error Now I wonder how many of my optical disk were not readable when I put them away. IMO this is so bad it should deserve an EN. The patch I'm attaching is not perfect (at this point in the code, we don't know which of the two files failed), but at least gives an hint something is wrong. Perhaps someone can come up with a better solution, but if that takes times, I think this is better than a silent failure.
Good finding, this should be MFC'ed.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=55f160fb07eaee977c89bdee7bdd83f4d21f5adf commit 55f160fb07eaee977c89bdee7bdd83f4d21f5adf Author: Dag-Erling Smørgrav <des@FreeBSD.org> AuthorDate: 2026-02-05 14:39:39 +0000 Commit: Dag-Erling Smørgrav <des@FreeBSD.org> CommitDate: 2026-02-05 14:39:39 +0000 diff: Print an error message on I/O error If an error occurs while atomizing either file, immediately print an error message using the error code returned by the atomizer, and set the error bit in the exit status. PR: 292198 MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: thj, kevans Differential Revision: https://reviews.freebsd.org/D55109 usr.bin/diff/diffreg_new.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=f8c12e6e3874cdd353fb16785da6f4e7eb134cd9 commit f8c12e6e3874cdd353fb16785da6f4e7eb134cd9 Author: Dag-Erling Smørgrav <des@FreeBSD.org> AuthorDate: 2026-02-05 17:41:56 +0000 Commit: Dag-Erling Smørgrav <des@FreeBSD.org> CommitDate: 2026-02-05 19:40:35 +0000 diff: Report I/O errors in Stone algorithm In the legacy Stone algorithm, we do a first pass over the files to check if they're identical before we start diffing them. That code would correctly set the exit status if an I/O error was encountered, but would not emit an error message. Do so. PR: 292198 MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: thj Differential Revision: https://reviews.freebsd.org/D55125 usr.bin/diff/diffreg.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
A commit in branch stable/15 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=cbd16002358677d06e8e43b23ed202da2b3c930c commit cbd16002358677d06e8e43b23ed202da2b3c930c Author: Dag-Erling Smørgrav <des@FreeBSD.org> AuthorDate: 2026-02-05 17:41:56 +0000 Commit: Dag-Erling Smørgrav <des@FreeBSD.org> CommitDate: 2026-02-10 14:24:09 +0000 diff: Report I/O errors in Stone algorithm In the legacy Stone algorithm, we do a first pass over the files to check if they're identical before we start diffing them. That code would correctly set the exit status if an I/O error was encountered, but would not emit an error message. Do so. PR: 292198 MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: thj Differential Revision: https://reviews.freebsd.org/D55125 (cherry picked from commit f8c12e6e3874cdd353fb16785da6f4e7eb134cd9) usr.bin/diff/diffreg.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
A commit in branch stable/15 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=07f25fa320af9dfd452c740127e941d4328ba6d8 commit 07f25fa320af9dfd452c740127e941d4328ba6d8 Author: Dag-Erling Smørgrav <des@FreeBSD.org> AuthorDate: 2026-02-05 14:39:39 +0000 Commit: Dag-Erling Smørgrav <des@FreeBSD.org> CommitDate: 2026-02-10 14:24:08 +0000 diff: Print an error message on I/O error If an error occurs while atomizing either file, immediately print an error message using the error code returned by the atomizer, and set the error bit in the exit status. PR: 292198 MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: thj, kevans Differential Revision: https://reviews.freebsd.org/D55109 (cherry picked from commit 55f160fb07eaee977c89bdee7bdd83f4d21f5adf) usr.bin/diff/diffreg_new.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
A commit in branch stable/14 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=37ceb8794c22d88a41e261d23d347bc7ac08b2c8 commit 37ceb8794c22d88a41e261d23d347bc7ac08b2c8 Author: Dag-Erling Smørgrav <des@FreeBSD.org> AuthorDate: 2026-02-05 17:41:56 +0000 Commit: Dag-Erling Smørgrav <des@FreeBSD.org> CommitDate: 2026-02-10 14:24:20 +0000 diff: Report I/O errors in Stone algorithm In the legacy Stone algorithm, we do a first pass over the files to check if they're identical before we start diffing them. That code would correctly set the exit status if an I/O error was encountered, but would not emit an error message. Do so. PR: 292198 MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: thj Differential Revision: https://reviews.freebsd.org/D55125 (cherry picked from commit f8c12e6e3874cdd353fb16785da6f4e7eb134cd9) usr.bin/diff/diffreg.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=641366df41d8e2a3bde877b712a08de8a49a76ee commit 641366df41d8e2a3bde877b712a08de8a49a76ee Author: Dag-Erling Smørgrav <des@FreeBSD.org> AuthorDate: 2026-02-05 17:41:56 +0000 Commit: Dag-Erling Smørgrav <des@FreeBSD.org> CommitDate: 2026-02-10 14:24:30 +0000 diff: Report I/O errors in Stone algorithm In the legacy Stone algorithm, we do a first pass over the files to check if they're identical before we start diffing them. That code would correctly set the exit status if an I/O error was encountered, but would not emit an error message. Do so. PR: 292198 MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: thj Differential Revision: https://reviews.freebsd.org/D55125 (cherry picked from commit f8c12e6e3874cdd353fb16785da6f4e7eb134cd9) usr.bin/diff/diffreg.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
A commit in branch releng/14.4 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=3c10ed2ba3aaef386e57e6078d6d8421429a55d7 commit 3c10ed2ba3aaef386e57e6078d6d8421429a55d7 Author: Dag-Erling Smørgrav <des@FreeBSD.org> AuthorDate: 2026-02-05 17:41:56 +0000 Commit: Colin Percival <cperciva@FreeBSD.org> CommitDate: 2026-02-11 06:14:50 +0000 diff: Report I/O errors in Stone algorithm In the legacy Stone algorithm, we do a first pass over the files to check if they're identical before we start diffing them. That code would correctly set the exit status if an I/O error was encountered, but would not emit an error message. Do so. Approved by: re (cperciva) PR: 292198 MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: thj Differential Revision: https://reviews.freebsd.org/D55125 (cherry picked from commit f8c12e6e3874cdd353fb16785da6f4e7eb134cd9) (cherry picked from commit 37ceb8794c22d88a41e261d23d347bc7ac08b2c8) usr.bin/diff/diffreg.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)