git: 86b4df97d0fc - main - cat: report copy_file_range() errors with the read filename

From: Kyle Evans <kevans_at_FreeBSD.org>
Date: Sat, 14 Dec 2024 04:33:14 UTC
The branch main has been updated by kevans:

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

commit 86b4df97d0fc6980242e6d047390047c8c7be7dc
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2024-12-14 04:32:54 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2024-12-14 04:32:54 +0000

    cat: report copy_file_range() errors with the read filename
    
    The error may be due to an error while writing, but it's more helpful to
    report what we were trying to from rather than "stdout" for these
    errors.  Noticed because of what happens now when `cat` gets an EISDIR
    for reading from a dirfd:
    
    kevans@ifrit:~$ cat /etc
    cat: stdout: Is a directory
    
    which, after this change, becomes:
    
    kevans@aarch64-dev:~$ cat /etc
    cat: /etc: Is a directory
    
    Reviewed by:    allanjude, des, mm
    Differential Revision:  https://reviews.freebsd.org/D41784
---
 bin/cat/cat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/cat/cat.c b/bin/cat/cat.c
index 3e7974e5f334..c4c04fb3fff6 100644
--- a/bin/cat/cat.c
+++ b/bin/cat/cat.c
@@ -271,7 +271,7 @@ scanfiles(char *argv[], int cooked __unused)
 				    errno == EISDIR)
 					raw_cat(fd);
 				else
-					err(1, "stdout");
+					err(1, "%s", filename);
 			}
 #else
 			raw_cat(fd);