bug-gnulib
[Top][All Lists]
Advanced

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

Re: make openat declarations consistent


From: Eric Blake
Subject: Re: make openat declarations consistent
Date: Sun, 06 Sep 2009 21:01:37 -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 Bruno Haible on 9/6/2009 3:14 PM:
> Additionally, this patch fixes a bug: gl_FUNC_OPENAT did not AC_REQUIRE
> gl_OPENAT_DEFAULTS. So it could happen that gl_FUNC_OPENAT gets expanded
> before gl_UNISTD_H_DEFAULTS, and then the variable GNULIB_OPENAT would have
> the value 0 instead of 1.

faccessat and symlinkat had the same bug.  Pushing this followup, along
with some doc fixes.

- --
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/

iEYEARECAAYFAkqkd5EACgkQ84KuGfSFAYAlJgCfTAOLWqTjXyLVAcnv4set2BXo
vWoAoNA29DQqhURHJU95wVv/D4v7PaHu
=8xhk
-----END PGP SIGNATURE-----
From aa686284617c4695252f39a67c20dee5a28a8408 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Sun, 6 Sep 2009 20:53:59 -0600
Subject: [PATCH 1/2] faccessat, symlinkat: continue cleanup of previous patch

* m4/symlinkat.m4 (gl_FUNC_SYMLINKAT): Ensure dependency order.
* m4/faccessat.m4 (gl_FUNC_FACCESSAT): Likewise.
* modules/unistd (Makefile.am): Substitute GNULIB_READLINKAT.
* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Offer GNULIB_READLINKAT.
* modules/symlinkat (configure.ac): Set GNULIB_READLINKAT.
* lib/unistd.in.h (readlinkat): Declare if GNULIB_READLINKAT is
set.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog         |   11 +++++++++++
 lib/unistd.in.h   |   10 +++++++---
 m4/faccessat.m4   |    3 ++-
 m4/symlinkat.m4   |    3 ++-
 m4/unistd_h.m4    |    3 ++-
 modules/symlinkat |    1 +
 modules/unistd    |    1 +
 7 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f587cc4..e5ebf06 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2009-09-06  Eric Blake  <address@hidden>
+
+       faccessat, symlinkat: continue cleanup of previous patch
+       * m4/symlinkat.m4 (gl_FUNC_SYMLINKAT): Ensure dependency order.
+       * m4/faccessat.m4 (gl_FUNC_FACCESSAT): Likewise.
+       * modules/unistd (Makefile.am): Substitute GNULIB_READLINKAT.
+       * m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Offer GNULIB_READLINKAT.
+       * modules/symlinkat (configure.ac): Set GNULIB_READLINKAT.
+       * lib/unistd.in.h (readlinkat): Declare if GNULIB_READLINKAT is
+       set.
+
 2009-09-06  Bruno Haible  <address@hidden>

        * lib/sys_stat.in.h (fchmodat): Declare if GNULIB_FCHMODAT is set.
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index ed25f69..6503529 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -193,15 +193,19 @@ int faccessat (int fd, char const *file, int mode, int 
flag);
 # if address@hidden@
 int symlinkat (char const *contents, int fd, char const *file);
 # endif
-# if address@hidden@
-ssize_t readlinkat (int fd, char const *file, char *buf, size_t len);
-# endif
 #elif defined GNULIB_POSIXCHECK
 # undef symlinkat
 # define symlinkat(c,d,n)                           \
     (GL_LINK_WARNING ("symlinkat is not portable - " \
                       "use gnulib module symlinkat for portability"), \
      symlinkat (c, d, n))
+#endif
+
+#if @GNULIB_READLINKAT@
+# if address@hidden@
+ssize_t readlinkat (int fd, char const *file, char *buf, size_t len);
+# endif
+#elif defined GNULIB_POSIXCHECK
 # undef readlinkat
 # define readlinkat(d,n,b,l)                        \
     (GL_LINK_WARNING ("faccessat is not portable - " \
diff --git a/m4/faccessat.m4 b/m4/faccessat.m4
index 250d97b..0aa9526 100644
--- a/m4/faccessat.m4
+++ b/m4/faccessat.m4
@@ -1,4 +1,4 @@
-# serial 2
+# serial 3
 # See if we need to provide faccessat replacement.

 dnl Copyright (C) 2009 Free Software Foundation, Inc.
@@ -12,6 +12,7 @@ AC_DEFUN([gl_FUNC_FACCESSAT],
 [
   AC_REQUIRE([gl_FUNC_OPENAT])
   AC_REQUIRE([gl_FUNC_EUIDACCESS])
+  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
   AC_CHECK_FUNCS_ONCE([access])
   AC_CHECK_FUNCS_ONCE([faccessat])
diff --git a/m4/symlinkat.m4 b/m4/symlinkat.m4
index 50d9954..93980d5 100644
--- a/m4/symlinkat.m4
+++ b/m4/symlinkat.m4
@@ -1,4 +1,4 @@
-# serial 1
+# serial 2
 # See if we need to provide symlinkat/readlinkat replacement.

 dnl Copyright (C) 2009 Free Software Foundation, Inc.
@@ -11,6 +11,7 @@ dnl with or without modifications, as long as this notice is 
preserved.
 AC_DEFUN([gl_FUNC_SYMLINKAT],
 [
   AC_REQUIRE([gl_FUNC_OPENAT])
+  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
   AC_CHECK_FUNCS_ONCE([symlink symlinkat readlinkat])
   if test $ac_cv_func_symlinkat = no; then
diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4
index d9781f7..84f0755 100644
--- a/m4/unistd_h.m4
+++ b/m4/unistd_h.m4
@@ -1,4 +1,4 @@
-# unistd_h.m4 serial 23
+# unistd_h.m4 serial 24
 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,
@@ -55,6 +55,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
   GNULIB_LSEEK=0;            AC_SUBST([GNULIB_LSEEK])
   GNULIB_PIPE2=0;            AC_SUBST([GNULIB_PIPE2])
   GNULIB_READLINK=0;         AC_SUBST([GNULIB_READLINK])
+  GNULIB_READLINKAT=0;       AC_SUBST([GNULIB_READLINKAT])
   GNULIB_SLEEP=0;            AC_SUBST([GNULIB_SLEEP])
   GNULIB_SYMLINKAT=0;        AC_SUBST([GNULIB_SYMLINKAT])
   GNULIB_UNISTD_H_GETOPT=0;  AC_SUBST([GNULIB_UNISTD_H_GETOPT])
diff --git a/modules/symlinkat b/modules/symlinkat
index 7f8506f..2da3ba4 100644
--- a/modules/symlinkat
+++ b/modules/symlinkat
@@ -15,6 +15,7 @@ unistd
 configure.ac:
 gl_FUNC_SYMLINKAT
 gl_UNISTD_MODULE_INDICATOR([symlinkat])
+gl_UNISTD_MODULE_INDICATOR([readlinkat])

 Makefile.am:

diff --git a/modules/unistd b/modules/unistd
index fbcb50e..1f8b29e 100644
--- a/modules/unistd
+++ b/modules/unistd
@@ -48,6 +48,7 @@ unistd.h: unistd.in.h
              -e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|g' \
              -e 's|@''GNULIB_PIPE2''@|$(GNULIB_PIPE2)|g' \
              -e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \
+             -e 's|@''GNULIB_READLINKAT''@|$(GNULIB_READLINKAT)|g' \
              -e 's|@''GNULIB_SLEEP''@|$(GNULIB_SLEEP)|g' \
              -e 's|@''GNULIB_SYMLINKAT''@|$(GNULIB_SYMLINKAT)|g' \
              -e 's|@''GNULIB_UNISTD_H_GETOPT''@|$(GNULIB_UNISTD_H_GETOPT)|g' \
-- 
1.6.3.3.334.g916e1


From d4356ced2b562ac55101ab23a5321114c41e0eda Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Sun, 6 Sep 2009 20:21:28 -0600
Subject: [PATCH 2/2] doc: fix comments in recent patches

* lib/faccessat.c: Mention correct function.
* lib/fchmodat.c: Likewise.
* lib/fchownat.c: Likewise.
* lib/symlinkat.c: Likewise.
* doc/posix-headers/fcntl.texi (fcntl.h): Cygwin 1.7 has AT_*
constants.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog                    |    8 ++++++++
 doc/posix-headers/fcntl.texi |    3 ++-
 lib/faccessat.c              |    6 +++---
 lib/fchmodat.c               |    4 ++--
 lib/fchownat.c               |    4 ++--
 lib/symlinkat.c              |    4 ++--
 6 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e5ebf06..04e5cc1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2009-09-06  Eric Blake  <address@hidden>

+       doc: fix comments in recent patches
+       * lib/faccessat.c: Mention correct function.
+       * lib/fchmodat.c: Likewise.
+       * lib/fchownat.c: Likewise.
+       * lib/symlinkat.c: Likewise.
+       * doc/posix-headers/fcntl.texi (fcntl.h): Cygwin 1.7 has AT_*
+       constants.
+
        faccessat, symlinkat: continue cleanup of previous patch
        * m4/symlinkat.m4 (gl_FUNC_SYMLINKAT): Ensure dependency order.
        * m4/faccessat.m4 (gl_FUNC_FACCESSAT): Likewise.
diff --git a/doc/posix-headers/fcntl.texi b/doc/posix-headers/fcntl.texi
index 55d3ccf..340cf28 100644
--- a/doc/posix-headers/fcntl.texi
+++ b/doc/posix-headers/fcntl.texi
@@ -30,7 +30,8 @@ fcntl.h
 @samp{AT_FDCWD}, @samp{AT_EACCESS}, @samp{AT_SYMLINK_NOFOLLOW},
 @samp{AT_SYMLINK_FOLLOW}, and @samp{AT_REMOVEDIR}
 are not defined on many platforms:
-glibc 2.3.6, MacOS X 10.3, FreeBSD 6.0, NetBSD 3.0, OpenBSD 3.8, AIX 5.1, 
HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 8, Cygwin, mingw, Interix 3.5, BeOS.
+glibc 2.3.6, MacOS X 10.3, FreeBSD 6.0, NetBSD 3.0, OpenBSD 3.8, AIX
+5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 8, Cygwin 1.5.x, mingw, Interix 
3.5, BeOS.

 @item
 @samp{AT_FDCWD} is defined with a value too large for an @code{int} on some
diff --git a/lib/faccessat.c b/lib/faccessat.c
index a449b02..42479c7 100644
--- a/lib/faccessat.c
+++ b/lib/faccessat.c
@@ -34,9 +34,9 @@

 /* Invoke access or euidaccess on file, FILE, using mode MODE, in the directory
    open on descriptor FD.  If possible, do it without changing the
-   working directory.  Otherwise, resort to using save_cwd/fchdir,
-   then mkdir/restore_cwd.  If either the save_cwd or the restore_cwd
-   fails, then give a diagnostic and exit nonzero.
+   working directory.  Otherwise, resort to using save_cwd/fchdir, then
+   (access|euidaccess)/restore_cwd.  If either the save_cwd or the
+   restore_cwd fails, then give a diagnostic and exit nonzero.
    Note that this implementation only supports AT_EACCESS, although some
    native versions also support AT_SYMLINK_NOFOLLOW.  */

diff --git a/lib/fchmodat.c b/lib/fchmodat.c
index cc2776e..53cafe0 100644
--- a/lib/fchmodat.c
+++ b/lib/fchmodat.c
@@ -37,8 +37,8 @@ static int lchmod (char const *f, mode_t m) { errno = ENOSYS; 
return -1; }
    Invoke chmod or lchmod on file, FILE, using mode MODE, in the directory
    open on descriptor FD.  If possible, do it without changing the
    working directory.  Otherwise, resort to using save_cwd/fchdir,
-   then mkdir/restore_cwd.  If either the save_cwd or the restore_cwd
-   fails, then give a diagnostic and exit nonzero.
+   then (chmod|lchmod)/restore_cwd.  If either the save_cwd or the
+   restore_cwd fails, then give a diagnostic and exit nonzero.
    Note that an attempt to use a FLAG value of AT_SYMLINK_NOFOLLOW
    on a system without lchmod support causes this function to fail.  */

diff --git a/lib/fchownat.c b/lib/fchownat.c
index ba5d86b..6da3537 100644
--- a/lib/fchownat.c
+++ b/lib/fchownat.c
@@ -35,8 +35,8 @@
    directory open on descriptor FD.  If FLAG is AT_SYMLINK_NOFOLLOW, then
    use lchown, otherwise, use chown.  If possible, do it without changing
    the working directory.  Otherwise, resort to using save_cwd/fchdir,
-   then mkdir/restore_cwd.  If either the save_cwd or the restore_cwd
-   fails, then give a diagnostic and exit nonzero.  */
+   then (chown|lchown)/restore_cwd.  If either the save_cwd or the
+   restore_cwd fails, then give a diagnostic and exit nonzero.  */

 #define AT_FUNC_NAME fchownat
 #define AT_FUNC_F1 lchown
diff --git a/lib/symlinkat.c b/lib/symlinkat.c
index 6c1c1d5..6fe752f 100644
--- a/lib/symlinkat.c
+++ b/lib/symlinkat.c
@@ -68,7 +68,7 @@ symlinkat_reversed (int fd, char const *file, char const 
*contents);
 /* Create a symlink FILE, in the directory open on descriptor FD,
    holding CONTENTS.  If possible, do it without changing the
    working directory.  Otherwise, resort to using save_cwd/fchdir,
-   then mkdir/restore_cwd.  If either the save_cwd or the restore_cwd
+   then symlink/restore_cwd.  If either the save_cwd or the restore_cwd
    fails, then give a diagnostic and exit nonzero.  */

 int
@@ -90,7 +90,7 @@ symlinkat (char const *contents, int fd, char const *file)
 /* Read the contents of symlink FILE into buffer BUF of size LEN, in the
    directory open on descriptor FD.  If possible, do it without changing
    the working directory.  Otherwise, resort to using save_cwd/fchdir,
-   then mkdir/restore_cwd.  If either the save_cwd or the restore_cwd
+   then readlink/restore_cwd.  If either the save_cwd or the restore_cwd
    fails, then give a diagnostic and exit nonzero.  */

 #define AT_FUNC_NAME readlinkat
-- 
1.6.3.3.334.g916e1


reply via email to

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