* m4/fchdir.m4 (gl_FUNC_FCHDIR): Set appropriate witnesses.
* m4/sys_stat_h.m4 (gl_SYS_STAT_H_DEFAULTS): Add REPLACE_FSTAT.
* m4/dirent_h.m4 (gl_DIRENT_H_DEFAULTS): Add REPLACE_OPENDIR,
REPLACE_CLOSEDIR.
* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Add REPLACE_DUP.
* modules/sys_stat (Makefile.am): Substitute correct witness.
* modules/dirent (Makefile.am): Likewise.
* modules/unistd (Makefile.am): Likewise.
* lib/dirent.in.h (opendir, closedir): Use better witnesses.
* lib/unistd.in.h (dup): Likewise.
* lib/sys_stat.in.h (fstat): Likewise.
Signed-off-by: Eric Blake <ebb9@byu.net>
2009-09-15 Eric Blake <ebb9@byu.net>
+ fchdir: improve use of replacement functions
+ * m4/fchdir.m4 (gl_FUNC_FCHDIR): Set appropriate witnesses.
+ * m4/sys_stat_h.m4 (gl_SYS_STAT_H_DEFAULTS): Add REPLACE_FSTAT.
+ * m4/dirent_h.m4 (gl_DIRENT_H_DEFAULTS): Add REPLACE_OPENDIR,
+ REPLACE_CLOSEDIR.
+ * m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Add REPLACE_DUP.
+ * modules/sys_stat (Makefile.am): Substitute correct witness.
+ * modules/dirent (Makefile.am): Likewise.
+ * modules/unistd (Makefile.am): Likewise.
+ * lib/dirent.in.h (opendir, closedir): Use better witnesses.
+ * lib/unistd.in.h (dup): Likewise.
+ * lib/sys_stat.in.h (fstat): Likewise.
+
maint: ignore gnulib-tool temp files
* .gitignore: Ignore files created during gnulib-tool --test.
/* Declare overridden functions. */
-#if @REPLACE_FCHDIR@
-# define opendir rpl_opendir
-extern DIR * opendir (const char *);
+#if @REPLACE_CLOSEDIR@
# define closedir rpl_closedir
extern int closedir (DIR *);
#endif
-/* Declare other POSIX functions. */
-
#if @GNULIB_DIRFD@
# if !@HAVE_DECL_DIRFD@ && !defined dirfd
/* Return the file descriptor associated with the given directory stream,
fdopendir (f))
#endif
+#if @REPLACE_OPENDIR@
+# define opendir rpl_opendir
+extern DIR * opendir (const char *);
+#endif
+
#if @GNULIB_SCANDIR@
/* Scan the directory DIR, calling FILTER on each directory entry.
Entries for which FILTER returns nonzero are individually malloc'd,
mknodat (f, n, m, d))
#endif
-#if @REPLACE_FCHDIR@
+#if @REPLACE_FSTAT@
# define fstat rpl_fstat
extern int fstat (int fd, struct stat *buf);
#endif
close (f))
#endif
+#if @REPLACE_DUP@
+# define dup rpl_dup
+extern int dup (int);
+#endif
#if @GNULIB_DUP2@
# if @REPLACE_DUP2@
#if @GNULIB_FCHDIR@
# if @REPLACE_FCHDIR@
-
/* Change the process' current working directory to the directory on which
the given file descriptor is open.
Return 0 if successful, otherwise -1 and errno set.
<http://www.opengroup.org/susv3xsh/fchdir.html>. */
extern int fchdir (int /*fd*/);
-# define dup rpl_dup
-extern int dup (int);
-
/* Gnulib internal hooks needed to maintain the fchdir metadata. */
extern int _gl_register_fd (int fd, const char *filename);
extern void _gl_unregister_fd (int fd);
-# dirent_h.m4 serial 4
+# dirent_h.m4 serial 5
dnl Copyright (C) 2008-2009 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
HAVE_FDOPENDIR=1; AC_SUBST([HAVE_FDOPENDIR])
HAVE_SCANDIR=1; AC_SUBST([HAVE_SCANDIR])
HAVE_ALPHASORT=1; AC_SUBST([HAVE_ALPHASORT])
+ REPLACE_CLOSEDIR=0; AC_SUBST([REPLACE_CLOSEDIR])
+ REPLACE_OPENDIR=0; AC_SUBST([REPLACE_OPENDIR])
DIRENT_H=''; AC_SUBST([DIRENT_H])
])
-# fchdir.m4 serial 9
+# fchdir.m4 serial 10
dnl Copyright (C) 2006-2009 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
gl_PREREQ_FCHDIR
AC_DEFINE([REPLACE_FCHDIR], [1],
[Define to 1 if gnulib's fchdir() replacement is used.])
+ dnl We must also replace anything that can manipulate a directory fd,
+ dnl to keep our bookkeeping up-to-date. We don't have to replace
+ dnl fstatat, since no platform has fstatat but lacks fchdir.
REPLACE_FSTAT=1
+ REPLACE_OPENDIR=1
+ REPLACE_CLOSEDIR=1
+ REPLACE_DUP=1
gl_REPLACE_OPEN
gl_REPLACE_CLOSE
gl_REPLACE_DUP2
-# sys_stat_h.m4 serial 14 -*- Autoconf -*-
+# sys_stat_h.m4 serial 15 -*- Autoconf -*-
dnl Copyright (C) 2006-2009 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
HAVE_MKDIRAT=1; AC_SUBST([HAVE_MKDIRAT])
HAVE_MKFIFOAT=1; AC_SUBST([HAVE_MKFIFOAT])
HAVE_MKNODAT=1; AC_SUBST([HAVE_MKNODAT])
+ REPLACE_FSTAT=0; AC_SUBST([REPLACE_FSTAT])
REPLACE_FSTATAT=0; AC_SUBST([REPLACE_FSTATAT])
REPLACE_LSTAT=0; AC_SUBST([REPLACE_LSTAT])
REPLACE_MKDIR=0; AC_SUBST([REPLACE_MKDIR])
-# unistd_h.m4 serial 25
+# unistd_h.m4 serial 26
dnl Copyright (C) 2006-2009 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
HAVE_UNLINKAT=1; AC_SUBST([HAVE_UNLINKAT])
REPLACE_CHOWN=0; AC_SUBST([REPLACE_CHOWN])
REPLACE_CLOSE=0; AC_SUBST([REPLACE_CLOSE])
+ REPLACE_DUP=0; AC_SUBST([REPLACE_DUP])
REPLACE_DUP2=0; AC_SUBST([REPLACE_DUP2])
REPLACE_FCHDIR=0; AC_SUBST([REPLACE_FCHDIR])
REPLACE_FCHOWNAT=0; AC_SUBST([REPLACE_FCHOWNAT])
-e 's|@''HAVE_FDOPENDIR''@|$(HAVE_FDOPENDIR)|g' \
-e 's|@''HAVE_SCANDIR''@|$(HAVE_SCANDIR)|g' \
-e 's|@''HAVE_ALPHASORT''@|$(HAVE_ALPHASORT)|g' \
- -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \
+ -e 's|@''REPLACE_CLOSEDIR''@|$(REPLACE_CLOSEDIR)|g' \
+ -e 's|@''REPLACE_OPENDIR''@|$(REPLACE_OPENDIR)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
< $(srcdir)/dirent.in.h; \
} > $@-t && \
-e 's|@''HAVE_MKDIRAT''@|$(HAVE_MKDIRAT)|g' \
-e 's|@''HAVE_MKFIFOAT''@|$(HAVE_MKFIFOAT)|g' \
-e 's|@''HAVE_MKNODAT''@|$(HAVE_MKNODAT)|g' \
- -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \
+ -e 's|@''REPLACE_FSTAT''@|$(REPLACE_FSTAT)|g' \
-e 's|@''REPLACE_FSTATAT''@|$(REPLACE_FSTATAT)|g' \
-e 's|@''REPLACE_LSTAT''@|$(REPLACE_LSTAT)|g' \
-e 's|@''REPLACE_MKDIR''@|$(REPLACE_MKDIR)|g' \
-e 's|@''HAVE_SYS_PARAM_H''@|$(HAVE_SYS_PARAM_H)|g' \
-e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \
-e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \
+ -e 's|@''REPLACE_DUP''@|$(REPLACE_DUP)|g' \
-e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \
-e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \
-e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \