]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
ls: avoid ENOENT from readdir() on FreeBSD 14
authorPádraig Brady <P@draigBrady.com>
Tue, 26 Mar 2024 18:27:00 +0000 (18:27 +0000)
committerPádraig Brady <P@draigBrady.com>
Tue, 26 Mar 2024 18:57:32 +0000 (18:57 +0000)
* 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

index d5964173271af4bfce4269fb9188d643d0886c6e..f5ac98df7d872c7fce30b3de68b7617300c5a792 100644 (file)
--- 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))