bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fchdir on mingw


From: Eric Blake
Subject: Re: fchdir on mingw
Date: Tue, 15 Sep 2009 21:50:51 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Eric Blake on 9/1/2009 10:55 AM:
> 
> Eric Blake (5):
>       fchdir: fix off-by-one bug in previous patch
>       fchdir: simplify error handling, and support dup3
>       fchdir: use more consistent macro convention

This particular patch wasn't quite consistent with other replacement
macros.  I'm pushing this followup:

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkqwYJsACgkQ84KuGfSFAYAOJgCeN3uOMkcSL183t6YteqTe5u0K
9nEAoNkHZTfaxabjuCryKU/HG7hEsb0U
=eKlF
-----END PGP SIGNATURE-----
>From c9dd0005fe00602d13c3d54f0834655b1e769520 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Tue, 15 Sep 2009 15:54:43 -0600
Subject: [PATCH] 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.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog         |   13 +++++++++++++
 lib/dirent.in.h   |   11 ++++++-----
 lib/sys_stat.in.h |    2 +-
 lib/unistd.in.h   |    8 ++++----
 m4/dirent_h.m4    |    4 +++-
 m4/fchdir.m4      |    8 +++++++-
 m4/sys_stat_h.m4  |    3 ++-
 m4/unistd_h.m4    |    3 ++-
 modules/dirent    |    3 ++-
 modules/sys_stat  |    2 +-
 modules/unistd    |    1 +
 11 files changed, 42 insertions(+), 16 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 322aca5..e58b782 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
 2009-09-15  Eric Blake  <address@hidden>

+       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.

diff --git a/lib/dirent.in.h b/lib/dirent.in.h
index 8930765..6da77d9 100644
--- a/lib/dirent.in.h
+++ b/lib/dirent.in.h
@@ -35,15 +35,11 @@ extern "C" {

 /* 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 address@hidden@ && !defined dirfd
 /* Return the file descriptor associated with the given directory stream,
@@ -75,6 +71,11 @@ extern DIR *fdopendir (int fd);
      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,
diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h
index b0ea92d..869cb0f 100644
--- a/lib/sys_stat.in.h
+++ b/lib/sys_stat.in.h
@@ -369,7 +369,7 @@ int mknodat (int fd, char const *file, mode_t mode, dev_t 
dev);
      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
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index f191412..553fb06 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -231,6 +231,10 @@ extern int close (int);
      close (f))
 #endif

+#if @REPLACE_DUP@
+# define dup rpl_dup
+extern int dup (int);
+#endif

 #if @GNULIB_DUP2@
 # if @REPLACE_DUP2@
@@ -312,7 +316,6 @@ extern int euidaccess (const char *filename, int mode);

 #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.
@@ -320,9 +323,6 @@ extern int euidaccess (const char *filename, int mode);
    <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);
diff --git a/m4/dirent_h.m4 b/m4/dirent_h.m4
index 06fffef..16d8a02 100644
--- a/m4/dirent_h.m4
+++ b/m4/dirent_h.m4
@@ -1,4 +1,4 @@
-# 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,
@@ -41,5 +41,7 @@ AC_DEFUN([gl_DIRENT_H_DEFAULTS],
   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])
 ])
diff --git a/m4/fchdir.m4 b/m4/fchdir.m4
index 6597be0..f0e4dc0 100644
--- a/m4/fchdir.m4
+++ b/m4/fchdir.m4
@@ -1,4 +1,4 @@
-# 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,
@@ -16,7 +16,13 @@ AC_DEFUN([gl_FUNC_FCHDIR],
     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
diff --git a/m4/sys_stat_h.m4 b/m4/sys_stat_h.m4
index 8b62902..4c01807 100644
--- a/m4/sys_stat_h.m4
+++ b/m4/sys_stat_h.m4
@@ -1,4 +1,4 @@
-# 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,
@@ -63,6 +63,7 @@ AC_DEFUN([gl_SYS_STAT_H_DEFAULTS],
   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])
diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4
index 7347e38..e83dad3 100644
--- a/m4/unistd_h.m4
+++ b/m4/unistd_h.m4
@@ -1,4 +1,4 @@
-# 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,
@@ -88,6 +88,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
   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])
diff --git a/modules/dirent b/modules/dirent
index 3eb7411..454ac48 100644
--- a/modules/dirent
+++ b/modules/dirent
@@ -32,7 +32,8 @@ dirent.h: dirent.in.h
              -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; \
        } > address@hidden && \
diff --git a/modules/sys_stat b/modules/sys_stat
index 93bc70a..0747c4f 100644
--- a/modules/sys_stat
+++ b/modules/sys_stat
@@ -40,7 +40,7 @@ sys/stat.h: sys_stat.in.h
              -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' \
diff --git a/modules/unistd b/modules/unistd
index 37ecaaa..6bf5338 100644
--- a/modules/unistd
+++ b/modules/unistd
@@ -80,6 +80,7 @@ unistd.h: unistd.in.h
              -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' \
-- 
1.6.5.rc1


reply via email to

[Prev in Thread] Current Thread [Next in Thread]