From 6e2b4769cc0690075dfda0a297fab043411b7c7c Mon Sep 17 00:00:00 2001 From: =?utf8?q?P=C3=A1draig=20Brady?=
Date: Tue, 26 Mar 2024 18:27:00 +0000 Subject: [PATCH] ls: avoid ENOENT from readdir() on FreeBSD 14 * src/ls.c (print_dir): readdir() on FreeBSD 14 was seen to pass ENOENT through. ENOENT in this context means "Directory unlinked but still open". Reported by Bruno Haible with tests/ls/removed-directory.sh --- src/ls.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ls.c b/src/ls.c index d596417327..f5ac98df7d 100644 --- a/src/ls.c +++ b/src/ls.c @@ -3061,6 +3061,9 @@ print_dir (char const *name, char const *realname, bool command_line_arg) and when readdir simply finds that there are no more entries. */ errno = 0; next = readdir (dirp); + /* Some readdir()s do not absorb ENOENT (dir deleted but open). */ + if (errno == ENOENT) + errno = 0; if (next) { if (! file_ignored (next->d_name)) -- 2.47.2