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.
+ * modules/fdopendir: New module.
+ * m4/fdopendir.m4 (gl_FUNC_FDOPENDIR): New file.
+ * modules/openat (Depends-on): Add fdopendir.
+ * m4/openat.m4 (gl_FUNC_OPENAT): No longer need to check for
+ fdopendir here.
+ * modules/savedir (Depends-on): Only need fdopendir, not full
+ openat.
+ * lib/savedir.c (include): Use <dirent.h>, not "openat.h".
+ * lib/openat.h (fdopendir): Drop prototype.
+ * lib/dirent.in.h (fdopendir): Provide prototype.
+ * m4/dirent_h.m4 (gl_DIRENT_H_DEFAULTS): Add replacements.
+ * modules/dirent (Makefile.am): Substitute them.
+ * MODULES.html.sh (File system functions): Mention it.
+ * doc/posix-functions/fdopendir.texi (fdopendir): Likewise.
+ * modules/fdopendir-tests: New file.
+ * tests/test-fdopendir.c: Likewise.
+
fchdir: use more consistent macro convention
* lib/fcntl.in.h (_gl_register_fd): Move declaration to unistd.
* lib/sys_stat.in.h (rpl_fstat): Declare via make-time