2009-09-02 Eric Blake <ebb9@byu.net>
+ backupfile, chdir-long, fts, savedir: make safer
+ * lib/backupfile.c (includes): Use "dirent--.h", since
+ numbered_backup can write to stderr during readdir.
+ * lib/savedir.c (includes): Likewise.
+ * lib/chdir-long.c (includes): Use "fcntl--.h", since openat
+ emulation can write to stderr on failure.
+ * lib/fts.c (includes) [!_LIBC]: Likewise for opendir and openat.
+ * lib/getcwd.c: Document why opendir_safer is unused.
+ * lib/glob.c: Likewise.
+ * lib/scandir.c: Likewise.
+ * lib/openat-proc.c: Likewise, for open_safer.
+ * modules/backupfile (Depends-on): Add dirent-safer.
+ * modules/savedir (Depends-on): Likewise.
+ * modules/fts (Depends-on): Add dirent-safer and openat-safer.
+ * modules/chdir-long (Depends-on): Add openat-safer.
+
+ openat-safer: new module
+ * modules/openat-safer: New file.
+ * lib/openat-safer.c: Likewise.
+ * m4/fcntl-safer.m4 (gl_OPENAT_SAFER): New macro.
+ * lib/fcntl-safer.h (openat_safer): Declare.
+ * lib/fcntl--.h (openat): Override.
+ * MODULES.html.sh (File descriptor based I/O): Mention it.
+ * lib/openat.h: Add double-inclusion guards.
+ * lib/openat.c (includes): Only include "fcntl-safer.h", not
+ "fcntl--.h", so we can implement openat.
+ * modules/openat-safer-tests: New test.
+ * tests/test-openat-safer.c: New file.
+
+ dirent-safer: new module
+ * modules/dirent-safer: New file.
+ * lib/dirent--.h: Likewise.
+ * lib/dirent-safer.h: Likewise.
+ * lib/opendir-safer.c: Likewise.
+ * m4/dirent-safer.m4: Likewise.
+ * MODULES.html.sh (Enhancements for POSIX:2008): Mention it.
+ * modules/dirent-safer-tests: New test.
+ * tests/test-dirent-safer.c: New file.
+ * lib/fdopendir.c (includes): Ensure fdopendir is also safe.
+
+ fdopendir: optimize on mingw
+ * lib/unistd.in.h (_gl_directory_name): New prototype.
+ * lib/fchdir.c (_gl_directory_name): Implement it.
+ (fchdir): Use it to simplify implementation.
+ * lib/fdopendir.c (fdopendir) [REPLACE_FCHDIR]: Use metadata from
+ fchdir, when available, to avoid calling [f]chdir().
+
fdopendir: split into its own module
* lib/openat.c (fdopendir): Move...
* lib/fdopendir.c: ...into new file.