From: Pádraig Brady
Date: Tue, 26 Mar 2024 18:27:00 +0000 (+0000) Subject: ls: avoid ENOENT from readdir() on FreeBSD 14 X-Git-Tag: v9.5~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6e2b4769cc0690075dfda0a297fab043411b7c7c;p=thirdparty%2Fcoreutils.git 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 --- 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))