openat: provide more convenience names
authorEric Blake <ebb9@byu.net>
Mon, 7 Sep 2009 11:28:13 +0000 (05:28 -0600)
committerEric Blake <ebb9@byu.net>
Mon, 7 Sep 2009 11:28:13 +0000 (05:28 -0600)
* modules/faccessat (configure.ac): Add C witness.
* lib/unistd.in.h (readlinkat): Fix typo.
* lib/openat.h (statat, lstatat, accessat, euidaccessat): New
convenience wrappers.
* top/maint.mk (sc_prohibit_openat_without_use): Allow these
wrappers in syntax checks.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
lib/openat.h
lib/unistd.in.h
modules/faccessat
top/maint.mk

index 04e5cc1956d5cb4ab3a2f4c5fd9fa6fc6d55496f..f7ac99c4e778d4b167c8666583851a280fb37410 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2009-09-07  Eric Blake  <ebb9@byu.net>
+
+       openat: provide more convenience names
+       * modules/faccessat (configure.ac): Add C witness.
+       * lib/unistd.in.h (readlinkat): Fix typo.
+       * lib/openat.h (statat, lstatat, accessat, euidaccessat): New
+       convenience wrappers.
+       * top/maint.mk (sc_prohibit_openat_without_use): Allow these
+       wrappers in syntax checks.
+
 2009-09-06  Eric Blake  <ebb9@byu.net>
 
        doc: fix comments in recent patches
index 1d8596fd86b589845c13a0f5d2a6f0e90bc9663f..433b9983dffc9531925a02a8d7b0e32762f55a98 100644 (file)
@@ -81,4 +81,34 @@ lchmodat (int fd, char const *file, mode_t mode)
   return fchmodat (fd, file, mode, AT_SYMLINK_NOFOLLOW);
 }
 
+static inline int
+statat (int fd, char const *name, struct stat *st)
+{
+  return fstatat (fd, name, st, 0);
+}
+
+static inline int
+lstatat (int fd, char const *name, struct stat *st)
+{
+  return fstatat (fd, name, st, AT_SYMLINK_NOFOLLOW);
+}
+
+#if GNULIB_FACCESSAT
+/* For now, there are no wrappers named laccessat or leuidaccessat,
+   since gnulib doesn't support faccessat(,AT_SYMLINK_NOFOLLOW) and
+   since access rights on symlinks are of limited utility.  */
+
+static inline int
+accessat (int fd, char const *file, int mode)
+{
+  return faccessat (fd, file, mode, 0);
+}
+
+static inline int
+euidaccessat (int fd, char const *file, int mode)
+{
+  return faccessat (fd, file, mode, AT_EACCESS);
+}
+#endif
+
 #endif /* _GL_HEADER_OPENAT */
index 6503529115bb5b98522655e62d7586ef239fd5be..902b02592509eacfae0f1d7089c1e4c5dd81c9fe 100644 (file)
@@ -208,7 +208,7 @@ ssize_t readlinkat (int fd, char const *file, char *buf, size_t len);
 #elif defined GNULIB_POSIXCHECK
 # undef readlinkat
 # define readlinkat(d,n,b,l)                        \
-    (GL_LINK_WARNING ("faccessat is not portable - " \
+    (GL_LINK_WARNING ("readlinkat is not portable - " \
                       "use gnulib module symlinkat for portability"), \
      readlinkat (d, n, b, l))
 #endif
index d7737bac9df63494ad7068ab0528279a535d941c..92d818556b8428fa6653b3620ba3a6aedab22a88 100644 (file)
@@ -14,6 +14,7 @@ unistd
 
 configure.ac:
 gl_FUNC_FACCESSAT
+gl_MODULE_INDICATOR([faccessat])
 gl_UNISTD_MODULE_INDICATOR([faccessat])
 
 Makefile.am:
index 45bc0c9c1b8d84f6e021e28a709e91e81d7a1702..c0c3f271fedbf7e844e23ef7723942333898c520 100644 (file)
@@ -295,7 +295,7 @@ sc_prohibit_root_dev_ino_without_use:
 
 sc_prohibit_openat_without_use:
        @h='"openat.h"' \
-       re='\<(openat_(permissive|needs_fchdir|(save|restore)_fail)|l?ch(own|mod)at)\>' \
+       re='\<(openat_(permissive|needs_fchdir|(save|restore)_fail)|l?(stat|ch(own|mod))at|(euid)?accessat)\>' \
          $(_header_without_use)
 
 # Prohibit the inclusion of c-ctype.h without an actual use.