* src/ls.c (print_dir): Fix bug: file_failure can set errno to
something other than EOVERFLOW but the code assumed it didn’t.
Also, omit ENOENT bug workaround with glibc 2.3 and later,
for consistency with Gnulib.
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))
}
}
}
- else if (errno != 0)
+ else
{
+ int err = errno;
+ if (err == 0)
+ break;
+ /* Some readdir()s do not absorb ENOENT (dir deleted but open).
+ This bug was fixed in glibc 2.3 (2002). */
+#if ! (2 < __GLIBC__ + (3 <= __GLIBC_MINOR__))
+ if (err == ENOENT)
+ break;
+#endif
file_failure (command_line_arg, _("reading directory %s"), name);
- if (errno != EOVERFLOW)
+ if (err != EOVERFLOW)
break;
}
- else
- break;
/* When processing a very large directory, and since we've inhibited
interrupts, this loop would take so long that ls would be annoyingly