lib9: use opendir/readdir to read directories

getdirentries(2) has been deprecated on macOS since 10.5 (ten releases ago).
Using it requires disabling 64-bit inodes, but that in turn makes binaries
incompatible with some dynamic libraries, most notably ASAN.

At some point getdirentries(2) will actually be removed.

For both these reasons, switch to opendir/readdir.
A little clunky since we have to keep the DIR* hidden away
to preserve the int fd interfaces, but it lets us remove a bunch
of OS-specific code too.
This commit is contained in:
Russ Cox 2020-05-17 20:02:07 -04:00
parent 16f60479e1
commit 8cb7308f3a
2 changed files with 188 additions and 187 deletions

View file

@ -39,9 +39,6 @@ extern "C" {
# define _ALL_SOURCE
# undef HAS_SYS_TERMIOS
#endif
#if defined(__APPLE__)
# define _DARWIN_NO_64_BIT_INODE /* Snow Leopard */
#endif
#define _LARGEFILE64_SOURCE 1
#define _FILE_OFFSET_BITS 64